/* ==========================================================================
   anueci - Design System Modern, Dynamic & Premium (Vanilla CSS)
   ========================================================================== */

/* Thème Clair par Défaut */
:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --secondary: #0f172a;
    --accent: #f97316;
    --accent-hover: #ea580c;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --input-bg: #ffffff;
    --radius: 12px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Thème Sombre */
body.dark-mode {
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --input-bg: #0f172a;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: #0369a1;
}

/* Header & Navigation */
.site-header {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo "anueci" SVG dynamique */
.logo-link {
    display: inline-flex;
    align-items: center;
}

.logo-img {
    height: 46px;
    width: auto;
    display: block;
}

.logo-dark {
    display: none;
}

body.dark-mode .logo-light {
    display: none;
}

body.dark-mode .logo-dark {
    display: block;
}

.nav-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    list-style: none;
}

.nav-links a {
    color: var(--text-muted);
    font-weight: 500;
}

.nav-links a:hover {
    color: var(--text-main);
}

.nav-links a.active {
    color: var(--primary) !important;
    font-weight: 700 !important;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.25rem;
}

.nav-links a.btn-primary.active {
    border-bottom: none !important;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.45);
}

/* Forcer la couleur du texte sur les boutons de navigation (ex: Administration) */
.nav-links a.btn-primary, .btn-primary {
    background: var(--primary) !important;
    color: #ffffff !important;
}

.nav-links a.btn-primary:hover, .btn-primary:hover {
    background: var(--primary-hover) !important;
    color: #ffffff !important;
}

.nav-links a.btn-accent, .btn-accent {
    background: var(--accent) !important;
    color: #ffffff !important;
}

/* Bouton basculeur de thème */
.theme-toggle-btn {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    max-width: 40px;
    max-height: 40px;
    flex-shrink: 0;
    aspect-ratio: 1 / 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

/* Hero Section */
.hero {
    background: var(--bg-card);
    padding: 4rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.hero h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.75rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.hero p {
    color: var(--text-muted);
    font-size: 1.15rem;
    max-width: 650px;
    margin: 0 auto 2rem auto;
}

/* Formulaires & Champs de Saisie */
input, select, textarea, .form-control, .search-input {
    background-color: var(--input-bg) !important;
    color: var(--text-main) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus, .form-control:focus, .search-input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

select option {
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
}

.search-form {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f5f9;
    padding: 0.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

body.dark-mode .search-form {
    background: #1e293b;
}

.search-form .search-input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    border: none !important;
    background: var(--input-bg) !important;
    border-radius: 10px;
    font-size: 1.05rem;
    padding: 0.85rem 1.25rem;
}

.search-form .btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 0.85rem 2rem;
    font-size: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.75rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

html {
    scrollbar-gutter: stable;
}

/* Layout Containers */
.container {
    max-width: 1200px;
    width: 90%;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
    box-sizing: border-box;
    flex: 1;
}

/* Enterprise Grid & Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    background: rgba(2, 132, 199, 0.12);
    color: var(--primary);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-right: 0.35rem;
    margin-bottom: 0.35rem;
}

/* Layout & Formulaires Admin */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.admin-filter-form {
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
}

.admin-filter-form input,
.admin-filter-form select {
    flex: 1 1 180px;
    min-width: 140px;
}

.admin-filter-form .btn {
    flex: 0 0 auto;
}

.admin-card-form {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.admin-card-form form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.admin-card-form form input {
    flex: 1 1 200px;
}

.admin-card-form form .btn {
    flex: 0 0 auto;
}

/* Tables Admin */
table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-main);
}

th {
    background: var(--bg-main);
    color: var(--text-muted);
    padding: 1rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Single View / Fiche */
.fiche-header {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
}

.fiche-title {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.contact-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.phone-list {
    list-style: none;
    margin-top: 0.5rem;
}

.phone-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-color);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 3rem;
}

.page-link {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Bouton Flottant Rond pour les Cookies */
.cookie-trigger-btn {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    transition: var(--transition);
}

.cookie-trigger-btn:hover {
    transform: scale(1.15) rotate(15deg);
}

/* Modal déroulant pour les Cookies */
.cookie-banner {
    position: fixed;
    bottom: 5rem;
    left: 1.5rem;
    max-width: 420px;
    width: calc(100vw - 3rem);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 1rem;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Footer */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Responsive Mobile & Tablettes */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

.table-responsive {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    margin-bottom: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
    }
    .header-container { flex-direction: column; gap: 0.75rem; padding: 0.75rem 1rem; }
    .nav-links { flex-wrap: wrap; justify-content: center; gap: 0.75rem; font-size: 0.9rem; }
    .hero { padding: 2.5rem 1rem; }
    .hero h1 { font-size: 1.85rem; }
    .hero p { font-size: 1rem; }
    .search-form { flex-direction: column; padding: 0.75rem; width: 100%; }
    .search-form .search-input { width: 100%; text-align: center; }
    .search-form .btn { width: 100%; }
    .container { padding: 0 1rem; margin: 1rem auto; max-width: 100% !important; box-sizing: border-box; }
    .grid { grid-template-columns: 1fr; gap: 1rem; }
    .card { padding: 1.25rem; }
    .fiche-header { padding: 1.25rem; }
    .fiche-title { font-size: 1.6rem; }
    .pagination { flex-wrap: wrap; gap: 0.35rem; }
    .page-link { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
    table { min-width: 600px; }

    /* Adaptations Mobile Spécifiques Administration */
    .admin-header { flex-direction: column; align-items: stretch; gap: 1rem; width: 100%; max-width: 100%; }
    .admin-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); width: 100%; gap: 0.5rem; }
    .admin-actions .btn { width: 100%; text-align: center; justify-content: center; font-size: 0.85rem; padding: 0.6rem 0.5rem; box-sizing: border-box; }
    
    .admin-filter-form,
    .admin-card-form {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .admin-filter-form input, 
    .admin-filter-form select, 
    .admin-filter-form .btn,
    .admin-card-form form input, 
    .admin-card-form form select, 
    .admin-card-form form .btn { 
        width: 100% !important; 
        min-width: 0 !important; 
        max-width: 100% !important; 
        flex: none !important;
        box-sizing: border-box !important;
    }
}

@media (max-width: 480px) {
    .hero h1 { font-size: 1.5rem; }
    .btn { padding: 0.65rem 1.25rem; font-size: 0.9rem; }
}

/* ==========================================================================
   STYLING LAYOUT ADMIN & SIDEBAR LATÉRALE
   ========================================================================== */
.admin-layout {
    display: flex;
    height: calc(100vh - 65px);
    max-height: calc(100vh - 65px);
    overflow: hidden;
    background: var(--bg-main);
}

.admin-sidebar {
    width: 250px;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    padding: 0.85rem 0.65rem;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.2s ease-in-out;
}

.sidebar-header {
    padding: 0 0.35rem 0.65rem 0.35rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.65rem;
}

.sidebar-brand {
    font-family: 'Outfit', sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.sidebar-brand span {
    color: var(--accent);
}

.sidebar-badge {
    font-size: 0.62rem;
    background: var(--primary);
    color: #fff;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.65rem;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.86rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: 0.5px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    flex: 1;
}

.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.8px;
    padding: 0.45rem 0.6rem 0.12rem 0.6rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.38rem 0.65rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.88rem;
    border-radius: 6px;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
    background: var(--bg-main);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--primary);
    color: #ffffff !important;
    font-weight: 600;
}

.nav-icon {
    font-size: 1rem;
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-logout {
    color: #ef4444 !important;
}

.nav-logout:hover {
    background: #fef2f2 !important;
}

.admin-main-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    min-width: 0;
}

.admin-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Pills pour la page de doublons */
.filter-pills {
    display: flex;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.35rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.pill-btn {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.15s ease;
}

.pill-btn:hover {
    color: var(--text-main);
}

.pill-btn.active {
    background: var(--primary);
    color: #fff !important;
}

@media (max-width: 992px) {
    .admin-layout {
        flex-direction: column;
        height: auto;
        max-height: none;
        overflow: visible;
    }
    .admin-sidebar {
        width: 100%;
        height: auto;
        overflow-y: visible;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .nav-section-title {
        display: none;
    }
    .admin-main-content {
        padding: 1rem;
        height: auto;
        overflow-y: visible;
    }
}

