/* ==========================================================================
   MEDICAL SHOP - ADMIN DASHBOARD DESIGN SYSTEM (v1.6.1)
   ========================================================================== */

:root {
    /* Brand Colors - Harmonized with Logo v1.6 (Guinée Green) */
    --primary: #10B981;     /* Vert Guinée */
    --secondary: #EF4444;   /* Rouge Médical */
    --accent: #F59E0B;      /* Orange Shop */
    --text-dark: #1E293B;   
    --text-muted: #64748B;  
    
    /* Backgrounds & Borders */
    --bg-main: #F3F4F6;     /* Clean light gray for dashboard background */
    --bg-card: #FFFFFF;     /* Pure white for cards */
    --border: #E2E8F0;      /* Slate 200 */
    --border-light: #F1F5F9;/* Slate 100 */

    /* Functional Colors (Signals) */
    --success: #10B981;     /* Emerald 500 */
    --success-bg: #D1FAE5;
    --danger: #EF4444;      /* Red 500 */
    --danger-bg: #FEE2E2;
    --warning: #F59E0B;     /* Amber 500 */
    --warning-bg: #FEF3C7;
    --info: #3B82F6;        /* Blue 500 */
    --info-bg: #DBEAFE;

    /* Geometry */
    --sidebar-width: 260px;
    --header-height: 80px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Shadows - Green tinted for v1.6 harmony */
    --shadow-sm: 0 1px 2px 0 rgba(16, 185, 129, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(16, 185, 129, 0.08), 0 2px 4px -2px rgba(16, 185, 129, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(16, 185, 129, 0.1), 0 4px 6px -4px rgba(16, 185, 129, 0.05);
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */

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

body.admin-body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-dark);
    background-color: var(--bg-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    display: flex;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

/* ==========================================================================
   LAYOUT: SIDEBAR
   ========================================================================== */

.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--primary);
    color: white;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border);
}

.sidebar-header img {
    height: 40px;
    object-fit: contain;
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    padding: 24px 0;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.4);
    font-weight: 700;
    padding: 0 24px;
    margin-bottom: 12px;
    margin-top: 24px;
}
.nav-section-title:first-child { margin-top: 0; }

.sidebar-nav ul li a {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: rgba(255,255,255,0.7);
    font-size: 0.95rem;
    font-weight: 500;
}

.sidebar-nav ul li a i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 12px;
    color: rgba(255,255,255,0.5);
    transition: var(--transition);
}

.sidebar-nav ul li a:hover,
.sidebar-nav ul li a.active {
    background-color: rgba(255,255,255,0.05);
    color: white;
    border-right: 3px solid var(--secondary);
}

.sidebar-nav ul li a:hover i,
.sidebar-nav ul li a.active i {
    color: var(--secondary);
}

.sidebar-footer {
    padding: 24px;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.admin-user-mini {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-user-mini img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.2);
}
.admin-user-info span { display: block; font-size: 0.9rem; font-weight: 600; }
.admin-user-info small { color: rgba(255,255,255,0.5); font-size: 0.75rem; }

/* ==========================================================================
   LAYOUT: MAIN CONTENT & HEADER
   ========================================================================== */

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.admin-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.header-left { display: flex; align-items: center; gap: 20px; }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-dark);
}

.search-box {
    position: relative;
    width: 300px;
}
.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.search-box input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-main);
    font-size: 0.9rem;
    transition: var(--transition);
}
.search-box input:focus {
    outline: none;
    border-color: var(--secondary);
    background: white;
}

.header-right { display: flex; align-items: center; gap: 24px; }

.header-icon-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
}
.header-icon-btn:hover { color: var(--primary); }
.header-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background: var(--danger);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
}

/* Page Content Area */
.admin-content {
    flex: 1;
    padding: 32px;
}

.page-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 32px;
}
.page-title h1 { font-size: 1.8rem; font-weight: 800; color: var(--primary); margin-bottom: 6px; }
.page-title p { color: var(--text-muted); font-size: 0.95rem; }

/* ==========================================================================
   COMPONENTS: STAT CARDS
   ========================================================================== */

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}
.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.stat-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}
.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.cyan { background: #ecfeff; color: #0891b2; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}
.stat-trend {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }
.stat-trend.neutral { color: var(--text-muted); }

/* ==========================================================================
   COMPONENTS: CHARTS & TABLES
   ========================================================================== */

.dashboard-main-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}
@media (min-width: 1200px) {
    .dashboard-main-grid { grid-template-columns: 2fr 1.2fr; }
}

.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.admin-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Base Table */
.table-responsive {
    overflow-x: auto;
}
.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}
.admin-table th {
    background: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
.admin-table th:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }

.admin-table td {
    padding: 16px;
    font-size: 0.95rem;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}
.admin-table tbody tr { transition: var(--transition); }
.admin-table tbody tr:hover { background-color: #f8fafc; }
.admin-table tbody tr:last-child td { border-bottom: none; }

.table-client-info { display: flex; align-items: center; gap: 12px; }
.table-client-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--bg-main); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--primary); font-size: 0.85rem; }
.table-client-name { font-weight: 600; color: var(--primary); display: block; }
.table-client-company { font-size: 0.8rem; color: var(--text-muted); }

/* Badges */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    display: inline-block;
}
.status-pending { background: var(--warning-bg); color: #d97706; }
.status-success { background: var(--success-bg); color: #059669; }
.status-info { background: var(--info-bg); color: #2563eb; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600;
    border: none; cursor: pointer; transition: var(--transition); text-decoration: none;
}
.btn-primary { background: var(--secondary); color: white; }
.btn-primary:hover { background: #dc2626; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(16,185,129,0.2); }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--text-dark); color: var(--text-dark); }
.btn-action { width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; background: var(--bg-main); color: var(--text-muted); font-size: 0.85rem; border: none; margin-right: 4px; }
.btn-action:hover { background: var(--border); color: var(--primary); }
.btn-action.edit:hover { background: #e0f2fe; color: #0284c7; }
.btn-action.delete:hover { background: #fee2e2; color: #dc2626; }

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE DRAWER)
   ========================================================================== */

@media (max-width: 900px) {
    .menu-toggle { display: block; }
    
    .admin-sidebar {
        transform: translateX(-100%);
        box-shadow: 10px 0 20px rgba(0,0,0,0.2);
    }
    
    .admin-sidebar.active {
        transform: translateX(0);
    }

    .admin-main { margin-left: 0; }
    
    .admin-header { padding: 0 20px; }
    .admin-content { padding: 20px; }
    
    .search-box { display: none; } /* Hide search on mobile header for space */
    
    .page-header-actions { flex-direction: column; align-items: flex-start; gap: 16px; }
}

/* Utility to darken background when mobile drawer is open */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 34, 74, 0.6); backdrop-filter: blur(2px);
    z-index: 999; opacity: 0; visibility: hidden; transition: var(--transition);
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ==========================================================================
   FORMS & UPLOAD COMPONENTS (PRODUCT MANAGEMENT)
   ========================================================================== */

.admin-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}
.admin-form-header {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) { .form-row { grid-template-columns: 1fr 1fr; } }
.form-row-3 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) { .form-row-3 { grid-template-columns: repeat(3, 1fr); } }

.form-label {
    display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.85rem; color: var(--text-dark);
}
.form-label span.req { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm); font-family: inherit; font-size: 0.95rem;
    color: var(--text-dark); background: #f8fafc; transition: all 0.2s ease;
}
.form-control:focus { outline: none; border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }

/* Switch Style */
.switch-wrapper { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-main); }
.switch-text { font-size: 0.9rem; font-weight: 600; color: var(--text-dark); }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--success); }
input:focus + .slider { box-shadow: 0 0 1px var(--success); }
input:checked + .slider:before { transform: translateX(20px); }

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: 30px; text-align: center;
    background: #f8fafc; cursor: pointer; transition: all 0.2s;
}
.upload-area:hover { border-color: var(--primary); background: #f0fdf4; }
.upload-icon { font-size: 2.5rem; color: var(--text-muted); margin-bottom: 12px; }
.upload-text { font-size: 0.95rem; color: var(--text-dark); font-weight: 600; margin-bottom: 4px; }
.upload-hint { font-size: 0.8rem; color: var(--text-muted); }

/* Filters Bar */
.filters-bar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
    background: var(--bg-card); padding: 16px 24px; border: 1px solid var(--border); border-radius: var(--radius-md);
    margin-bottom: 24px; box-shadow: var(--shadow-sm);
}
.filters-left, .filters-right { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Table Thumbnail */
.table-prod-img { width: 50px; height: 50px; border-radius: var(--radius-sm); object-fit: cover; border: 1px solid var(--border); }
