/* ============ RESET & BASE ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #6C63FF;
    --primary-dark: #564fd9;
    --secondary: #00BFA6;
    --danger: #FF5252;
    --warning: #FFB300;
    --info: #448AFF;
    --dark: #1a1a2e;
    --light: #f8f9fe;
    --white: #ffffff;
    --gray: #8e8e93;
    --gray-light: #e5e5ea;
    --success: #34C759;
    --sidebar-width: 260px;
    --header-height: 64px;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.08);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Cairo', sans-serif;
    background: var(--light);
    color: var(--dark);
    line-height: 1.6;
}
.hidden { display: none !important; }

/* ============ LOGIN ============ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}
.login-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow);
    text-align: center;
}
.login-card .logo { margin-bottom: 32px; }
.login-card .logo img { max-width: 80px; margin-bottom: 12px; }
.login-card .logo h1 { font-size: 24px; color: var(--dark); margin-bottom: 4px; }
.login-card .logo p { color: var(--gray); font-size: 14px; }
.login-form { text-align: right; }
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--gray-light);
    color: var(--dark);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.btn-secondary:hover { background: #d1d1d6; }
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.btn-danger:hover { background: #e04848; }
.btn-success {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: var(--success);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}
.btn-small { padding: 6px 12px; font-size: 13px; }
.error-msg {
    margin-top: 16px;
    padding: 12px;
    background: #ffebee;
    color: #c62828;
    border-radius: 8px;
    font-size: 14px;
}
.success-msg {
    margin-top: 16px;
    padding: 12px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 8px;
    font-size: 14px;
}
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ ADMIN LAYOUT ============ */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-left: 1px solid var(--gray-light);
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid var(--gray-light);
}
.sidebar-header img { max-width: 50px; }
.sidebar-header .logo-text { font-weight: 700; font-size: 18px; color: var(--primary); display: none; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--gray);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 4px;
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover, .nav-item.active {
    background: var(--primary);
    color: var(--white);
}
.nav-divider { height: 1px; background: var(--gray-light); margin: 16px 0; }
.nav-item.logout { color: var(--danger); margin-top: auto; }
.nav-item.logout:hover { background: var(--danger); color: var(--white); }

.main-content {
    flex: 1;
    margin-right: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.top-bar {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-bar h2 { font-size: 20px; font-weight: 600; }
.top-bar-actions span { color: var(--gray); font-size: 14px; }
.pages-container { flex: 1; padding: 28px; }
.page { display: none; }
.page.active { display: block; }

/* ============ STATS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}
.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 22px;
}
.stat-icon.blue { background: var(--primary); }
.stat-icon.green { background: var(--success); }
.stat-icon.orange { background: var(--warning); }
.stat-icon.purple { background: #7C4DFF; }
.stat-icon.red { background: var(--danger); }
.stat-icon.teal { background: var(--secondary); }
.stat-info h3 { font-size: 28px; font-weight: 700; color: var(--dark); }
.stat-info p { font-size: 13px; color: var(--gray); margin-top: 4px; }

/* ============ SECTIONS ============ */
.dashboard-sections {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}
.section-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.section-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--dark);
}

/* ============ TABLES ============ */
.table-container { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table thead th {
    background: var(--light);
    padding: 12px 16px;
    text-align: right;
    font-weight: 600;
    color: var(--gray);
    font-size: 13px;
    border-bottom: 1px solid var(--gray-light);
}
.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-light);
    color: var(--dark);
}
.data-table tbody tr:hover { background: rgba(108,99,255,0.04); }
.data-table img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.status-badge.pending { background: #fff3e0; color: #ef6c00; }
.status-badge.accepted { background: #e3f2fd; color: #1565c0; }
.status-badge.delivered { background: #e8f5e9; color: #2e7d32; }
.status-badge.cancelled { background: #ffebee; color: #c62828; }
.status-badge.new { background: #f3e5f5; color: #6a1b9a; }
.status-badge.read { background: var(--gray-light); color: var(--gray); }
.page-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-actions input, .page-actions select {
    padding: 10px 16px;
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    font-size: 14px;
    min-width: 200px;
    font-family: inherit;
}
.page-actions input:focus, .page-actions select:focus { outline: none; border-color: var(--primary); }

/* ============ CARDS GRID ============ */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.item-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}
.item-card img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    background: var(--gray-light);
}
.item-card .card-body { padding: 16px; }
.item-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.item-card p { font-size: 13px; color: var(--gray); margin-bottom: 12px; }
.card-actions { display: flex; gap: 8px; }

/* ============ MODAL ============ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--gray);
    cursor: pointer;
    line-height: 1;
}
.modal-body { padding: 24px; }

/* ============ NOTIFICATION FORM ============ */
.notification-form {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.notification-form h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--dark);
}

/* ============ IMAGE UPLOAD ============ */
.image-upload {
    border: 2px dashed var(--gray-light);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}
.image-upload:hover {
    border-color: var(--primary);
    background: rgba(108,99,255,0.04);
}
.image-upload i {
    font-size: 32px;
    color: var(--gray);
    margin-bottom: 8px;
}
.image-upload p {
    font-size: 14px;
    color: var(--gray);
}
.image-upload input[type="file"] {
    display: none;
}
.image-preview {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    margin-top: 12px;
    display: none;
}
.image-preview.show {
    display: block;
}
.upload-progress {
    width: 100%;
    height: 6px;
    background: var(--gray-light);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
    display: none;
}
.upload-progress.show {
    display: block;
}
.upload-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s;
    width: 0%;
}

/* ============ TOAST ============ */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: var(--white);
    padding: 14px 28px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 16px; }

/* ============ LOADING ============ */
.loading { text-align: center; padding: 40px; color: var(--gray); }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
    .sidebar { width: 70px; }
    .sidebar .nav-item span { display: none; }
    .sidebar-header .logo-text { display: block !important; }
    .main-content { margin-right: 70px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-sections { grid-template-columns: 1fr; }
    .page-actions { flex-direction: column; }
    .page-actions input, .page-actions select { width: 100%; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 24px; }
}
