/**
 * CSS Administration - D'Jolies
 * Styles pour l'interface admin
 */

/* ============================================================================
   VARIABLES CSS
   ============================================================================ */
:root {
    --primary-color: #d4a5a5;
    --primary-hover: #c49090;
    --secondary-color: #f5e6e6;
    --success-color: #4CAF50;
    --info-color: #2196F3;
    --warning-color: #FF9800;
    --danger-color: #f44336;
    --text-color: #333;
    --text-light: #666;
    --text-muted: #999;
    --border-color: #e0e0e0;
    --bg-light: #f9f9f9;
    --bg-dark: #2c2c2c;
    --sidebar-width: 260px;
    --topbar-height: 70px;
    --transition: all 0.3s ease;
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background: #f5f5f5;
}

/* ============================================================================
   LAYOUT ADMIN
   ============================================================================ */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s;
}

/* Sidebar collapsed */
body.sidebar-collapsed .admin-main {
    margin-left: 70px;
}

body.sidebar-collapsed .admin-sidebar {
    width: 70px;
}

/* ============================================================================
   SIDEBAR
   ============================================================================ */
.admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #ffffff;
    box-shadow: 2px 0 10px rgba(0,0,0,0.05);
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s;
    z-index: 1000;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--primary-color);
    font-size: 20px;
    font-weight: 700;
    transition: var(--transition);
}

.sidebar-logo i {
    font-size: 24px;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-light);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

/* Navigation */
.sidebar-nav {
    padding: 20px 0;
}

.nav-menu {
    list-style: none;
}

.nav-item {
    margin: 4px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    position: relative;
}

.nav-link i {
    font-size: 18px;
    width: 24px;
    text-align: center;
    color: var(--text-light);
    transition: var(--transition);
}

.nav-link span {
    flex: 1;
    white-space: nowrap;
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.nav-link:hover i {
    color: var(--primary-color);
}

.nav-item.active .nav-link {
    background: linear-gradient(90deg, var(--secondary-color) 0%, transparent 100%);
    color: var(--primary-color);
    font-weight: 600;
    border-left: 3px solid var(--primary-color);
}

.nav-item.active .nav-link i {
    color: var(--primary-color);
}

.nav-divider {
    padding: 16px 20px 8px 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.badge-primary {
    background: var(--primary-color);
    color: #fff;
}

.badge-danger {
    background: var(--danger-color);
    color: #fff;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* Sidebar collapsed state */
body.sidebar-collapsed .sidebar-logo-text,
body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .nav-divider span,
body.sidebar-collapsed .badge,
body.sidebar-collapsed .sidebar-footer {
    opacity: 0;
    display: none;
}

/* ============================================================================
   TOPBAR
   ============================================================================ */
.admin-topbar {
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 999;
}

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

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

.page-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

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

.topbar-item {
    position: relative;
}

.topbar-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-light);
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: var(--transition);
    position: relative;
}

.topbar-btn:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.notification-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--danger-color);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.topbar-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-user-btn:hover {
    background: var(--bg-light);
}

.user-avatar,
.user-avatar-large {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.user-avatar-large {
    width: 50px;
    height: 50px;
    font-size: 20px;
}

.user-name {
    font-weight: 500;
    color: var(--text-color);
}

/* Dropdowns */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 280px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
    z-index: 1000;
}

.dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.dropdown-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.dropdown-body {
    max-height: 400px;
    overflow-y: auto;
}

.dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--bg-light);
}

.dropdown-item i {
    font-size: 20px;
    margin-top: 2px;
}

.dropdown-item-content {
    flex: 1;
}

.dropdown-item-content strong {
    display: block;
    margin-bottom: 2px;
}

.dropdown-item-content small {
    color: var(--text-muted);
    font-size: 12px;
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

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

.user-info strong {
    display: block;
    margin-bottom: 2px;
}

.user-info small {
    color: var(--text-muted);
    font-size: 12px;
}

/* ============================================================================
   CONTENT AREA
   ============================================================================ */
.admin-content {
    padding: 30px;
    min-height: calc(100vh - var(--topbar-height));
}

.content-wrapper {
    max-width: 1400px;
}

/* Breadcrumb */
.breadcrumb {
    margin-bottom: 20px;
}

.breadcrumb ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.breadcrumb li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.breadcrumb li:not(:last-child)::after {
    content: '/';
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--text-light);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

.breadcrumb .active {
    color: var(--text-color);
    font-weight: 500;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease-out;
    position: relative;
}

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

@keyframes slideOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.alert i.alert-icon,
.alert .fas,
.alert .far {
    font-size: 20px;
}

.alert-message {
    flex: 1;
}

.alert-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 0;
    margin-left: auto;
}

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

.alert-success {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid var(--success-color);
}

.alert-danger,
.alert-error {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid var(--danger-color);
}

.alert-warning {
    background: #fff3e0;
    color: #ef6c00;
    border-left: 4px solid var(--warning-color);
}

.alert-info {
    background: #e3f2fd;
    color: #1565c0;
    border-left: 4px solid var(--info-color);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

.btn i {
    margin-right: 6px;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 165, 165, 0.3);
}

.btn-success {
    background: var(--success-color);
    color: #fff;
}

.btn-success:hover {
    background: #45a049;
}

.btn-danger {
    background: var(--danger-color);
    color: #fff;
}

.btn-danger:hover {
    background: #da190b;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
}

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

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    display: block;
}

/* ============================================================================
   FOOTER
   ============================================================================ */
.admin-footer {
    background: #fff;
    border-top: 1px solid var(--border-color);
    padding: 20px 30px;
    margin-top: 40px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-muted);
}

.footer-version {
    margin-left: 10px;
    padding: 2px 8px;
    background: var(--bg-light);
    border-radius: 4px;
    font-size: 11px;
}

.footer-session {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 1024px) {
    .admin-main {
        margin-left: 0;
    }

    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    body.sidebar-open .admin-sidebar {
        transform: translateX(0);
    }

    .sidebar-toggle-mobile {
        display: block;
    }

    /* FIX MENU MOBILE - Z-INDEX pour éviter conflit avec popup cookies */
    .admin-topbar {
        position: relative !important;
        z-index: 10000000 !important;
    }

    .sidebar-toggle-mobile {
        position: relative !important;
        z-index: 10000001 !important;
        pointer-events: auto !important;
        cursor: pointer !important;
    }

    /* Les clics sur l'icône à l'intérieur du bouton doivent passer au bouton */
    .sidebar-toggle-mobile * {
        pointer-events: none !important;
    }

    .admin-sidebar {
        z-index: 9999999 !important;
    }

    /* FIX : Empêcher sidebar-header de bloquer le bouton hamburger */
    .sidebar-header {
        pointer-events: none !important;
    }

    /* Mais permettre les clics sur les éléments à l'intérieur du header */
    .sidebar-header * {
        pointer-events: auto !important;
    }
}

@media (max-width: 768px) {
    .admin-content {
        padding: 20px 15px;
    }

    .admin-topbar {
        padding: 0 15px;
    }

    .page-title {
        font-size: 20px;
    }

    .user-name {
        display: none;
    }

    .footer-content {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

/* ============================================================================
   UTILITAIRES
   ============================================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-info { color: var(--info-color); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
