@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-alt: #f8f9fd;
    --primary: #1e2a5e;
    --primary-light: #2d3f8d;
    --primary-gradient: linear-gradient(135deg, #1e2a5e 0%, #2d3f8d 50%, #3b52a6 100%);
    --accent: #e84c3d;
    --accent-gradient: linear-gradient(135deg, #e84c3d, #f39c12);
    --success: #27ae60;
    --success-bg: #e8f8ee;
    --warning: #f39c12;
    --warning-bg: #fef6e4;
    --danger: #e74c3c;
    --danger-bg: #fde8e7;
    --info: #3498db;
    --text: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 20px;
    min-height: 100vh;
    line-height: 1.6;
}

.container { max-width: 1280px; margin: 0 auto; }

/* Page Title */
.page-title {
    padding: 16px 0 14px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-title span { font-size: 18px; font-weight: 700; color: var(--primary); }
.page-title small { font-size: 13px; color: var(--text-muted); font-weight: 400; }

/* Search Card */
.search-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: box-shadow 0.3s;
}

.search-section:hover { box-shadow: var(--shadow-lg); }

.search-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

.search-row .input-wrapper {
    flex: 1;
    min-width: 240px;
    position: relative;
}

.search-row .input-wrapper input[type="text"] {
    width: 100%;
    padding: 14px 48px 14px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    transition: all 0.3s;
    background: var(--surface-alt);
}

.search-row .input-wrapper input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30,42,94,0.1);
    background: var(--surface);
}

.search-row .input-wrapper::before {
    content: '🔍';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    opacity: 0.5;
}

.search-row .scan-hint {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    background: var(--surface-alt);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.filters select {
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    background: var(--surface-alt);
    min-width: 160px;
    flex: 1;
    transition: all 0.3s;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 36px;
}

.filters select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(30,42,94,0.1);
    background-color: var(--surface);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 0 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stats-bar span {
    background: var(--surface-alt);
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* Table Premium */
.table-wrapper {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }

thead th {
    background: var(--surface-alt);
    padding: 14px 16px;
    text-align: right;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    letter-spacing: 0.3px;
}

thead th:first-child { border-radius: 0 8px 0 0; }
thead th:last-child { border-radius: 8px 0 0 0; }

tbody tr {
    transition: all 0.2s;
    cursor: pointer;
}

tbody tr:hover { background: #eef1ff; transform: translateX(2px); }

tbody tr:active { transform: scale(0.99); }

tbody td { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; white-space: nowrap; }

tbody tr:last-child td { border-bottom: none; }

.barcode-cell {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--info);
    direction: ltr;
    display: inline-block;
    background: #eef2ff;
    padding: 2px 8px;
    border-radius: 4px;
}

.price { font-weight: 700; direction: ltr; display: inline-block; color: var(--text); }

.price::before { content: 'K.D '; font-size: 11px; color: var(--text-muted); font-weight: 400; }

.status-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.status-active { background: var(--success-bg); color: var(--success); }
.status-inactive { background: var(--danger-bg); color: var(--danger); }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 20px 16px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    font-size: 14px;
    font-family: var(--font);
    transition: all 0.2s;
    font-weight: 500;
}

.pagination button:hover { background: var(--surface-alt); border-color: var(--primary); color: var(--primary); }

.pagination button.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(30,42,94,0.3);
}

.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Detail Panel */
.detail-panel {
    display: none;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-right: 4px solid var(--primary);
    animation: slideIn 0.3s ease;
}

.detail-panel.open { display: block; }

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.detail-panel h3 {
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.detail-item {
    padding: 12px 16px;
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.detail-item:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(30,42,94,0.08); }

.detail-item label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 4px; font-weight: 500; }

.detail-item .value { font-size: 16px; font-weight: 700; color: var(--text); }

/* Spinner */
.spinner { display: none; text-align: center; padding: 48px; }

.spinner.show { display: block; }

.spinner::after {
    content: '';
    display: inline-block;
    width: 40px; height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}

.empty-state .icon { font-size: 56px; margin-bottom: 16px; opacity: 0.3; }

.empty-state p { font-size: 15px; }

/* Responsive Premium */
@media (max-width: 768px) {
    body { padding-left: 12px; padding-right: 12px; padding-bottom: 12px; }
    .search-section { padding: 16px; }
    .search-row .input-wrapper { min-width: 100%; }
    .filters select { min-width: 100%; }
    table { font-size: 13px; }
    thead th, tbody td { padding: 10px 12px; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
    .stats-bar span { font-size: 12px; }
}

@media (max-width: 480px) {
    .detail-grid { grid-template-columns: 1fr; }
    thead th:nth-child(4), thead th:nth-child(5),
    tbody td:nth-child(4), tbody td:nth-child(5) { display: none; }
}
