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

:root {
    --primary: #8951FF;
    --secondary: #0E43FB;
    --success: #14CA74;
    --danger: #FF5A65;
    --warning: #FDB52A;
    --info: #00C2FF;
    --bg-primary: #F7FAFC;
    --bg-secondary: #FFFFFF;
    --text-primary: #2D3748;
    --text-secondary: #4A5568;
    --border: #D9E1FA;
    --sidebar-bg: #0B1739;
    --sidebar-hover: #082366;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transition: all 0.3s ease;
    z-index: 1000;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.3s ease;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: white;
}

.nav-item.active {
    background: var(--sidebar-hover);
    color: white;
    border-left-color: var(--primary);
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    flex-shrink: 0;
}

.nav-text {
    overflow: hidden;
    transition: opacity 0.3s ease, width 0.3s ease;
}

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

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: 80px;
}

.sidebar.collapsed .sidebar-logo {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 24px 12px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 14px 12px;
}

.sidebar.collapsed .nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-footer {
    padding: 20px 12px;
}

/* Tooltip for collapsed sidebar */
.sidebar.collapsed .nav-item {
    position: relative;
}

.sidebar.collapsed .nav-item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--sidebar-bg);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    margin-left: 10px;
    z-index: 1001;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar.collapsed .nav-item:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    margin-left: 280px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 80px;
}

/* Topbar */
.topbar {
    background: var(--bg-secondary);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.topbar-left h1 {
    font-size: 24px;
    font-weight: 600;
}

.topbar-logo {
    max-height: 100px;
    max-width: 1000px;
    object-fit: contain;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-primary);
    padding: 10px 16px;
    border-radius: 8px;
    min-width: 300px;
}

.search-box i {
    color: var(--text-secondary);
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    flex: 1;
    font-size: 14px;
}

.icon-btn {
    position: relative;
    background: var(--bg-primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: var(--border);
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.profile-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.profile-menu:hover {
    background: var(--bg-primary);
}

.profile-menu img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.profile-menu:hover img {
    transform: scale(1.05);
}

/* Profile Link (simple version) */
.profile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.profile-link:hover {
    background: var(--bg-primary);
}

.profile-link img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.profile-link:hover img {
    transform: scale(1.05);
}

.profile-link span {
    font-weight: 500;
}

/* Profile Display (for Admin - no link) */
.profile-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    background: var(--bg-primary);
}

.profile-display img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.profile-display span {
    font-weight: 500;
}

.admin-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Sidebar Logout */
.logout-form {
    margin: 0;
    padding: 0;
}

.logout-btn {
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.logout-btn:hover {
    background: rgba(255, 90, 101, 0.15) !important;
    color: #FF5A65 !important;
}

.logout-btn i {
    color: inherit;
}

/* Dashboard Content */
.dashboard-content {
    padding: 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
    display: flex;
    gap: 20px;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.card-icon {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: white;
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.card-value {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.card-rate {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
}

.card-rate.up {
    color: var(--success);
}

.card-rate.down {
    color: var(--danger);
}

/* Cards 3 columns */
.cards-grid.cards-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Card Stats (FAFI / Reste) */
.card-stats {
    display: flex;
    gap: 16px;
    margin-top: 8px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--bg-primary);
}

.stat-item.success {
    color: var(--success);
}

.stat-item.success i {
    color: var(--success);
}

.stat-item.warning {
    color: var(--warning);
}

.stat-item.warning i {
    color: var(--warning);
}

.stat-item strong {
    font-weight: 600;
}

/* Charts Row */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chart-card.large {
    grid-column: span 1;
}

.chart-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.chart-placeholder {
    height: 200px;
    background: var(--bg-primary);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Products List */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.product-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.product-image {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.product-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.product-stock {
    font-size: 12px;
    color: var(--text-secondary);
}

.product-price {
    font-weight: 600;
    font-size: 16px;
}

/* Table */
.table-card {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.table-card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.table-container {
    overflow-x: auto;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th {
    text-align: left;
    padding: 12px;
    background: var(--bg-primary);
    font-weight: 500;
    font-size: 14px;
    color: var(--text-secondary);
}

.orders-table td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
}

.orders-table tr:last-child td {
    border-bottom: none;
}

.client-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.client-email {
    font-size: 12px;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.delivered {
    background: rgba(20, 202, 116, 0.1);
    color: var(--success);
}

.status-badge.canceled {
    background: rgba(255, 90, 101, 0.1);
    color: var(--danger);
}

.status-badge.pending {
    background: rgba(253, 181, 42, 0.1);
    color: var(--warning);
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header-left h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.record-count {
    font-size: 14px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.search-filter {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    min-width: 250px;
}

.search-filter i {
    color: var(--text-secondary);
}

.search-filter input {
    border: none;
    background: none;
    outline: none;
    flex: 1;
    font-size: 14px;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: #7a41e6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(137, 81, 255, 0.3);
}

.btn-secondary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.btn-pdf {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-pdf:hover {
    background: #b91c1c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-success {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-success:hover {
    background: #0fa968;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 202, 116, 0.3);
}

/* Filters Section */
.filters-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.filters-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 180px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-primary);
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(137, 81, 255, 0.1);
}

.filter-group .search-filter {
    min-width: auto;
    flex: 1;
}

.filters-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* Footer */
.app-footer {
    background: var(--sidebar-bg);
    color: rgba(255, 255, 255, 0.8);
    padding: 20px 32px;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-brand {
    font-weight: 700;
    font-size: 18px;
    color: white;
    background: linear-gradient(135deg, var(--primary) 0%, #00C2FF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.footer-separator {
    color: rgba(255, 255, 255, 0.3);
}

.footer-center {
    font-size: 14px;
}

.footer-center i {
    color: #ff5a65;
    animation: heartbeat 1.5s ease infinite;
}

.footer-center strong {
    color: white;
    font-weight: 600;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.footer-right {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-left, .footer-center, .footer-right {
        justify-content: center;
    }
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 14px 12px;
    background: var(--bg-primary);
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.data-table th.sortable:hover {
    background: var(--border);
}

.data-table th i {
    margin-left: 6px;
    font-size: 12px;
    opacity: 0.5;
}

.data-table th.sortable:hover i {
    opacity: 1;
}

.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--bg-primary);
}

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

/* Empty message */
.empty-message {
    text-align: center;
    padding: 60px 20px !important;
    color: var(--text-secondary);
}

.empty-message i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-message p {
    font-size: 16px;
    margin-top: 12px;
}

/* Avatar */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* Badge Types */
.badge-type {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-type.chef {
    background: rgba(137, 81, 255, 0.1);
    color: var(--primary);
}

.badge-type.assistant {
    background: rgba(79, 172, 254, 0.1);
    color: var(--info);
}

.badge-type.membre {
    background: rgba(67, 233, 123, 0.1);
    color: var(--success);
}

/* Badge Niveau (Élèves) */
.badge-niveau {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-niveau.louveteau {
    background: rgba(253, 181, 42, 0.15);
    color: #e6a000;
}

.badge-niveau.eclaireur {
    background: rgba(79, 172, 254, 0.15);
    color: var(--info);
}

.badge-niveau.routier {
    background: rgba(137, 81, 255, 0.15);
    color: var(--primary);
}

.badge-niveau.cheftaine {
    background: rgba(240, 147, 251, 0.15);
    color: #d946ef;
}

/* Action Buttons */
.actions-cell {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: var(--border);
    color: var(--primary);
}

.btn-icon.danger:hover {
    background: rgba(255, 90, 101, 0.1);
    color: var(--danger);
}

.btn-icon:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Table Footer */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.rows-per-page {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

.rows-per-page select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-secondary);
    font-size: 14px;
    cursor: pointer;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Alerts */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease;
    transition: opacity 0.3s ease;
}

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

.alert i {
    font-size: 20px;
}

.alert span {
    flex: 1;
}

.alert-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.alert-close:hover {
    opacity: 1;
}

.alert-success {
    background: rgba(20, 202, 116, 0.1);
    border: 1px solid rgba(20, 202, 116, 0.3);
    color: #0d8050;
}

.alert-success i {
    color: var(--success);
}

.alert-error {
    background: rgba(255, 90, 101, 0.1);
    border: 1px solid rgba(255, 90, 101, 0.3);
    color: #c43a47;
}

.alert-error i {
    color: var(--danger);
}

.alert-info {
    background: rgba(0, 194, 255, 0.1);
    border: 1px solid rgba(0, 194, 255, 0.3);
    color: #0077a3;
}

.alert-info i {
    color: var(--info);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 23, 57, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: flex-start;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    margin: auto;
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    background: var(--sidebar-bg);
    color: white;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h2 i {
    color: var(--primary);
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 28px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 28px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* Form styles */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group label .required {
    color: var(--danger);
}

.form-group input,
.form-group select {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(137, 81, 255, 0.1);
}

.form-group input::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.form-group select {
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1024px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
    
    .chart-card.large {
        grid-column: span 1;
    }
}

@media (max-width: 1200px) {
    .cards-grid.cards-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        width: 280px;
    }
    
    .sidebar.collapsed .sidebar-logo,
    .sidebar.collapsed .nav-text {
        opacity: 1;
        width: auto;
    }
    
    .sidebar.collapsed .sidebar-header,
    .sidebar.collapsed .nav-item {
        justify-content: flex-start;
        padding: 14px 20px;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .main-content.sidebar-collapsed {
        margin-left: 0;
    }
    
    .menu-toggle {
        display: block;
    }
    
    .sidebar-toggle {
        display: none;
    }
    
    .topbar {
        padding: 16px 20px;
    }
    
    .search-box {
        display: none;
    }
    
    .dashboard-content {
        padding: 20px;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
    }
    
    .cards-grid.cards-3 {
        grid-template-columns: 1fr;
    }
    
    .card-stats {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-content {
        margin: 10px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .modal-header {
        padding: 16px;
        border-radius: 12px 12px 0 0;
        flex-shrink: 0;
    }
    
    .modal-header h2 {
        font-size: 16px;
    }
    
    .modal-body {
        padding: 16px;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
    }
    
    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 8px;
        flex-shrink: 0;
        background: var(--bg-primary);
    }
    
    .modal-footer button {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px 12px;
        font-size: 14px;
    }
}

/* Small devices (large phones, 481px to 576px) */
@media (max-width: 576px) and (min-width: 481px) {
    .modal {
        padding: 10px;
        overflow-y: auto;
    }
    
    .modal-content {
        margin: 0;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        max-height: calc(100dvh - 20px);
        border-radius: 12px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .modal-header {
        padding: 16px;
        flex-shrink: 0;
    }
    
    .modal-body {
        padding: 16px;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
        max-height: calc(100vh - 160px);
        max-height: calc(100dvh - 160px);
    }
    
    .modal-footer {
        padding: 12px 16px;
        flex-shrink: 0;
        background: var(--bg-primary);
    }
}

/* Extra small devices (phones, less than 480px) */
@media (max-width: 480px) {
    .modal {
        padding: 0;
        align-items: flex-start;
        overflow-y: auto;
    }
    
    .modal-content {
        margin: 0;
        max-width: 100vw;
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile */
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .modal-header {
        padding: 14px 16px;
        border-radius: 0;
        flex-shrink: 0;
    }
    
    .modal-header h2 {
        font-size: 15px;
        gap: 8px;
    }
    
    .modal-close {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
    
    .modal-body {
        padding: 16px;
        padding-bottom: 20px;
        flex: 1;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        min-height: 0;
        /* Calculer la hauteur en tenant compte du header (~60px) et footer (~80px) */
        max-height: calc(100vh - 140px);
        max-height: calc(100dvh - 140px);
    }
    
    .modal-footer {
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        background: var(--bg-primary);
        border-top: 1px solid var(--border);
        flex-shrink: 0;
        z-index: 10;
    }
    
    .modal-footer button {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .form-group {
        margin-bottom: 14px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
        display: block;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 14px;
        font-size: 16px; /* Prevents zoom on iOS */
        width: 100%;
        box-sizing: border-box;
    }
    
    .form-row {
        gap: 0;
    }
}

