/**
 * CitationMaker - Styles
 * Design inspiré de Uplix.fr
 */

/* ============================================
   VARIABLES & RESET
   ============================================ */

:root {
    /* Charte Uplix (charte-uplix.md §2) */
    --up-blue: #0169E6;
    --up-blue-dk: #113D8A;
    --up-navy: #0A2A5E;
    --up-yellow: #FCCE24;
    --up-coral: #FF5D45;
    --up-green: #00BB52;
    --up-line: #E4E4EE;
    --up-tint: #E8F0FD;      /* fond de l'élément actif de la sidebar */

    --primary: var(--up-blue);
    --primary-dark: var(--up-blue-dk);
    --secondary: var(--up-coral);
    --secondary-dark: #E84A33;
    --background: #F5F6FA;
    --white: #FFFFFF;
    --text: #1F2937;
    --text-light: #6B7280;
    --border: var(--up-line);
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, 0.08);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-w: 248px;
}

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

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    text-decoration: none;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
}

.logo:hover {
    opacity: 0.9;
}

.logo-img {
    height: 72px;
    width: auto;
    display: block;
}

.logo-text {
    color: var(--white);
    letter-spacing: -0.5px;
    font-size: 1.5rem;
    font-weight: 700;
}

.logo-version {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

.nav {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

/* Bouton Didactiel mis en avant */
.nav-didactiel {
    background: var(--secondary) !important;
    color: var(--white) !important;
    font-weight: 600 !important;
    border-radius: 20px !important;
    padding: 0.45rem 1rem !important;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
    animation: didactiel-glow 3s ease-in-out infinite;
}

.nav-didactiel:hover {
    background: var(--secondary-dark) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.5);
}

.nav-didactiel.active {
    background: var(--secondary-dark) !important;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.5);
}

@keyframes didactiel-glow {
    0%, 100% { box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4); }
    50% { box-shadow: 0 2px 16px rgba(255, 107, 53, 0.6); }
}

/* Dropdown navigation */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.9);
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.nav-dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
}

.nav-dropdown-toggle.active {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.nav-dropdown-arrow {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.nav-dropdown:hover .nav-dropdown-arrow {
    transform: rotate(180deg);
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.35rem;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 340px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-5px);
    transition: all 0.2s ease;
    z-index: 200;
    border: 1px solid var(--border);
    overflow: hidden;
    white-space: nowrap;
}

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

.nav-dropdown-item {
    display: block;
    padding: 0.7rem 1rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

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

.nav-dropdown-item.active {
    background: linear-gradient(135deg, #EBF5FF 0%, #DBEAFE 100%);
    color: var(--primary);
    font-weight: 600;
    border-left-color: var(--primary);
}

.nav-dropdown-item + .nav-dropdown-item {
    border-top: 1px solid var(--border);
}

.nav-dropdown-right .nav-dropdown-menu {
    left: auto;
    right: 0;
}

.nav-logout {
    color: var(--secondary);
}

.nav-logout:hover {
    background: var(--secondary);
    color: var(--white);
}

.nav-locked {
    color: #94A3B8 !important;
    cursor: not-allowed !important;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.78rem;
    pointer-events: none;
}

/* API Quota Badge */
.api-quota {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    color: white;
    margin-left: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.api-quota:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.02);
}

.api-quota-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
}

.api-quota-icon svg {
    width: 14px;
    height: 14px;
}

.api-quota-info {
    display: flex;
    align-items: baseline;
    gap: 1px;
    font-weight: 600;
}

.api-quota-count {
    font-size: 0.9375rem;
    font-weight: 700;
}

.api-quota-separator {
    opacity: 0.6;
    font-weight: 400;
}

.api-quota-total {
    font-size: 0.75rem;
    opacity: 0.8;
}

.api-quota-bar {
    width: 40px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.api-quota-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease, background 0.3s ease;
}

/* Quota States */
.api-quota.quota-ok {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.4);
}

.api-quota.quota-ok .api-quota-bar-fill {
    background: linear-gradient(90deg, #10B981, #34D399);
}

.api-quota.quota-medium {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.4);
}

.api-quota.quota-medium .api-quota-bar-fill {
    background: linear-gradient(90deg, #F59E0B, #FBBF24);
}

.api-quota.quota-low {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
    animation: pulse-warning 2s infinite;
}

.api-quota.quota-low .api-quota-bar-fill {
    background: linear-gradient(90deg, #EF4444, #F87171);
}

@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* SerpApi Credits Badge (admin navbar) */
.serp-api-quota {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(99, 102, 241, 0.2);
    backdrop-filter: blur(10px);
    padding: 0.3rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    color: white;
    margin-left: 0.25rem;
    border: 1px solid rgba(99, 102, 241, 0.35);
    transition: all 0.3s ease;
    cursor: default;
    white-space: nowrap;
    position: relative;
}

.serp-api-quota:hover {
    background: rgba(99, 102, 241, 0.35);
    transform: scale(1.03);
}

.serp-api-quota svg {
    opacity: 0.8;
    flex-shrink: 0;
}

.serpq-count {
    font-weight: 700;
    font-size: 0.8rem;
}

.serpq-sep {
    opacity: 0.5;
    font-weight: 400;
}

.serpq-total {
    font-size: 0.7rem;
    opacity: 0.75;
}

.serpq-bar {
    width: 32px;
    height: 3px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    overflow: hidden;
    margin-left: 2px;
}

.serpq-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.serp-api-quota.serpq-ok {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.35);
}

.serp-api-quota.serpq-ok .serpq-bar-fill {
    background: linear-gradient(90deg, #818CF8, #A5B4FC);
}

.serp-api-quota.serpq-medium {
    background: rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 0.4);
}

.serp-api-quota.serpq-medium .serpq-bar-fill {
    background: linear-gradient(90deg, #F59E0B, #FBBF24);
}

.serp-api-quota.serpq-low {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
    animation: pulse-warning 2s infinite;
}

.serp-api-quota.serpq-low .serpq-bar-fill {
    background: linear-gradient(90deg, #EF4444, #F87171);
}

/* ============================================
   LAYOUT APPLICATION (espace connecté, façon Uplix)
   Sidebar blanche fixe à gauche + barre du haut + barre de titre
   ============================================ */

.app-layout {
    background: var(--background);
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--up-line);
    display: flex;
    flex-direction: column;
    padding: 1.1rem 0.9rem 0.9rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #D1D5DB transparent;
    z-index: 300;
}

.app-sidebar-brand {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
    padding: 0 0.4rem 1.1rem;
    text-decoration: none;
}

.app-sidebar-brand .uplix-logo {
    height: 30px;
    width: auto;
    display: block;
}

.app-sidebar-product {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-light);
    letter-spacing: 0.02em;
    padding-bottom: 2px;
}

.side-nav {
    flex: 1;
}

.side-section {
    margin-bottom: 0.85rem;
}

.side-section-title {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #374151;
    padding: 0 0.4rem 0.45rem;
}

summary.side-section-title {
    cursor: pointer;
    list-style: none;
    user-select: none;
}

summary.side-section-title::-webkit-details-marker {
    display: none;
}

summary.side-section-title::after {
    content: '';
    width: 5px;
    height: 5px;
    border-right: 1.5px solid #9CA3AF;
    border-bottom: 1.5px solid #9CA3AF;
    transform: rotate(-45deg);
    margin-left: 0.2rem;
    transition: transform 0.15s ease;
}

details[open] > summary.side-section-title::after {
    transform: rotate(45deg) translate(-1px, -1px);
}

.side-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.42rem 0.75rem;
    margin-bottom: 1px;
    border-radius: 10px;
    color: #374151;
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 400;
    line-height: 1.3;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.side-link > span:first-of-type {
    overflow: hidden;
    text-overflow: ellipsis;
}

.side-link svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
    color: #4B5563;
}

.side-link:hover {
    background: var(--background);
    color: var(--text);
}

.side-link.active {
    background: var(--up-tint);
    color: var(--up-blue-dk);
    font-weight: 500;
}

.side-link.active svg {
    color: var(--up-blue);
}

.side-ext {
    margin-left: auto;
    font-size: 0.75rem;
    color: #9CA3AF;
}

.side-badge {
    margin-left: auto;
    background: var(--up-coral);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 99px;
    padding: 0 0.4rem;
    line-height: 1.5;
}

.side-locked {
    color: #9CA3AF;
    cursor: not-allowed;
}

.side-bottom {
    border-top: 1px solid var(--up-line);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

.side-bottom .side-section {
    margin-bottom: 0;
}

.app-shell {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.75rem;
    background: var(--white);
    border-bottom: 1px solid var(--up-line);
    flex-wrap: wrap;
}

.app-menu-toggle {
    display: none;
    background: none;
    border: 1px solid var(--up-line);
    border-radius: 10px;
    padding: 0.4rem;
    color: var(--text);
    cursor: pointer;
}

.topbar-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 40px;
    padding: 0 0.9rem 0 0.45rem;
    background: var(--white);
    border: 1px solid var(--up-line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    font-family: inherit;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

button.topbar-pill {
    cursor: pointer;
}

button.topbar-pill:hover {
    border-color: #CBD5E1;
}

.topbar-project-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--up-tint);
    color: var(--up-blue);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
}

.topbar-project-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-caret {
    color: var(--text-light);
    transition: transform 0.15s ease;
}

.topbar-dropdown {
    position: relative;
}

.topbar-dropdown:hover .topbar-caret,
.topbar-dropdown.is-open .topbar-caret {
    transform: rotate(180deg);
}

.topbar-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    min-width: 320px;
    max-height: 480px;
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--up-line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0.35rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 250;
}

/* pont invisible pour ne pas perdre le survol entre le bouton et le menu */
.topbar-menu::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: -8px;
    height: 8px;
}

.topbar-dropdown:hover .topbar-menu,
.topbar-dropdown.is-open .topbar-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.topbar-menu-active {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--up-tint);
    border-radius: 8px;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.3rem;
}

.topbar-menu-kicker {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--up-blue);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.topbar-menu-active-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--up-blue-dk);
    text-decoration: none;
}

.topbar-menu-tag {
    font-size: 0.6rem;
    background: #FEF3C7;
    color: #92400E;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    margin-left: 0.3rem;
}

.topbar-menu-open {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--up-blue);
    text-decoration: none;
    white-space: nowrap;
}

.topbar-menu-item {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    font-size: 0.83rem;
    color: var(--text);
    text-decoration: none;
}

.topbar-menu-item:hover {
    background: var(--background);
    color: var(--up-blue);
}

.topbar-menu-item.is-current {
    font-weight: 600;
    color: var(--up-blue-dk);
}

.topbar-menu-meta {
    font-size: 0.65rem;
    color: var(--text-light);
}

.topbar-menu-strong {
    font-weight: 600;
    color: var(--up-blue);
}

.topbar-menu-create {
    border-top: 1px solid var(--up-line);
    border-radius: 0 0 8px 8px;
    margin-top: 0.3rem;
}

.topbar-menu-empty {
    color: var(--text-light);
    font-style: italic;
}

.topbar-menu-more {
    justify-content: center;
    color: var(--up-blue);
    font-size: 0.78rem;
}

.topbar-quota {
    padding: 0 0.8rem;
    gap: 0.45rem;
    cursor: default;
}

.topbar-quota-label {
    font-weight: 500;
    color: var(--text-light);
    font-size: 0.78rem;
}

.topbar-quota-value {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
}

.topbar-quota.is-ok .topbar-quota-value { background: #DCFCE7; color: #15803D; }
.topbar-quota.is-medium .topbar-quota-value { background: #FEF3C7; color: #B45309; }
.topbar-quota.is-low .topbar-quota-value { background: #FEE2E2; color: #B91C1C; }

.topbar-spacer {
    flex: 1;
}

.topbar-user {
    font-size: 0.8rem;
    color: var(--text-light);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--text-light);
    transition: background 0.15s ease, color 0.15s ease;
}

.topbar-logout:hover {
    background: #FEE2E2;
    color: #B91C1C;
}

.app-pagebar {
    padding: 0.85rem 1.75rem;
    background: var(--white);
    border-bottom: 1px solid var(--up-line);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.app-layout .main-content {
    width: 100%;
    max-width: 1320px;
    flex: 1;
    min-height: 0;
}

/* Largeur utile à droite de la sidebar. Les pages qui sortent de leur
   conteneur en 100vw (matrice Source analysis, audit GEO) se calent dessus,
   sinon elles passent sous la sidebar et font défiler la page en largeur. */
.app-layout {
    --shell-w: calc(100vw - var(--sidebar-w));
}

.app-shell {
    overflow-x: clip;
}

.app-layout .sa-matrix-card {
    width: calc(var(--shell-w) - 2rem);
    margin-left: calc(-1 * (var(--shell-w) - 100%) / 2 + 1rem);
}

.app-layout .ga {
    width: var(--shell-w);
    margin-left: calc(-1 * (var(--shell-w) - 100%) / 2);
}

.app-layout .footer {
    background: transparent;
    color: var(--text-light);
    font-size: 0.75rem;
    border-top: 1px solid var(--up-line);
    padding: 1rem 1.75rem;
}

.app-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 42, 94, 0.35);
    z-index: 290;
}

@media (max-width: 1024px) {
    .app-layout {
        --shell-w: 100vw;
    }
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }
    body.sidebar-open .app-sidebar {
        transform: none;
    }
    .app-shell {
        margin-left: 0;
    }
    .app-menu-toggle {
        display: inline-flex;
    }
    .app-topbar,
    .app-pagebar {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .topbar-user {
        display: none;
    }
}

@media (max-width: 640px) {
    .topbar-quota-label {
        display: none;
    }
    .topbar-project-name {
        max-width: 140px;
    }
    .topbar-menu {
        min-width: min(320px, calc(100vw - 2rem));
    }
}

/* En-tête public : logo Uplix dans une pastille blanche (signature charte) */
.logo-uplix {
    gap: 0.7rem;
}

.logo-pill {
    display: inline-flex;
    align-items: center;
    background: #fff;
    border-radius: 99px;
    padding: 9px 18px;
}

.logo-pill .uplix-logo {
    height: 24px;
    width: auto;
    display: block;
}

.logo-product {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: calc(100vh - 140px);
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

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

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-group input::placeholder {
    color: var(--text-light);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--white);
}

.btn-secondary:hover {
    background: var(--secondary-dark);
    transform: translateY(-1px);
}

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

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

.btn-danger {
    background: var(--error);
    color: var(--white);
}

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

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-logo {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.login-logo .logo-text {
    color: var(--primary);
}

.login-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-light);
    margin-bottom: 2rem;
}

.login-form .btn {
    margin-top: 0.5rem;
}

/* ============================================
   SERP RESULTS
   ============================================ */

.serp-results {
    margin-top: 2rem;
}

.serp-result {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: slideIn 0.3s ease forwards;
    opacity: 0;
    border: 1px solid var(--border);
}

.serp-result:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

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

.serp-result:nth-child(1) { animation-delay: 0.05s; }
.serp-result:nth-child(2) { animation-delay: 0.1s; }
.serp-result:nth-child(3) { animation-delay: 0.15s; }
.serp-result:nth-child(4) { animation-delay: 0.2s; }
.serp-result:nth-child(5) { animation-delay: 0.25s; }
.serp-result:nth-child(6) { animation-delay: 0.3s; }
.serp-result:nth-child(7) { animation-delay: 0.35s; }
.serp-result:nth-child(8) { animation-delay: 0.4s; }
.serp-result:nth-child(9) { animation-delay: 0.45s; }
.serp-result:nth-child(10) { animation-delay: 0.5s; }

.serp-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.serp-position {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.serp-position.top-3 {
    background: var(--secondary);
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.4);
}

.serp-favicon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 4px;
}

.serp-title-wrap {
    flex: 1;
    min-width: 0;
}

.serp-title {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    line-height: 1.4;
    display: block;
    margin-bottom: 0.25rem;
    transition: color 0.2s ease;
}

.serp-title:hover {
    text-decoration: underline;
    color: var(--primary-dark);
}

.serp-link {
    color: #15803D;
    font-size: 0.8rem;
    margin-bottom: 0;
    display: block;
    opacity: 0.8;
}

.serp-snippet {
    color: var(--text);
    font-size: 1.05rem;
    line-height: 1.7;
    background: linear-gradient(135deg, #F8FAFC 0%, #F1F5F9 100%);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    margin: 0.75rem 0;
    font-weight: 400;
}

.serp-highlighted {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}

.serp-highlighted::before {
    content: "Mots-clés :";
    font-size: 0.75rem;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    margin-bottom: 0.25rem;
}

.serp-keyword {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    color: #92400E;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid #F59E0B;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.serp-keyword:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

/* ============================================
   ANALYSIS SECTION
   ============================================ */

.analysis-form {
    background: linear-gradient(135deg, #EBF5FF 0%, #F0F7FF 100%);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 2rem;
}

.analysis-form h3 {
    color: var(--primary);
    margin-bottom: 1rem;
}

.analysis-result {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: var(--shadow);
}

.analysis-result h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.analysis-section {
    margin-bottom: 1.5rem;
}

.analysis-section h4 {
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analysis-section ul {
    list-style: none;
    padding-left: 0;
}

.analysis-section li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.analysis-section li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: 0;
}

.analysis-score {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    font-size: 1.25rem;
    font-weight: 700;
}

.score-bar {
    width: 120px;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: var(--white);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ============================================
   TABS
   ============================================ */

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
    overflow-x: auto;
}

.tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--text);
    background: var(--background);
}

.tab.active {
    color: var(--primary);
    background: var(--background);
    border-bottom: 3px solid var(--primary);
    margin-bottom: -2px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   TABLES
   ============================================ */

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

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

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--background);
    font-weight: 600;
    color: var(--text);
}

tr:hover {
    background: var(--background);
}

/* ============================================
   ADMIN PAGE
   ============================================ */

.api-key-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.api-key-value {
    font-family: 'Courier New', monospace;
    background: var(--white);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    flex: 1;
}

.api-key-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.active {
    background: var(--success);
}

.status-dot.inactive {
    background: var(--error);
}

/* ============================================
   LOADING STATE
   ============================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   LOADING OVERLAY WITH STEPS
   ============================================ */

.loading-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999 !important;
}

.loading-overlay.active {
    display: flex !important;
}

.loading-container {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    width: 90%;
    max-width: 380px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: loadingPopIn 0.3s ease;
}

@keyframes loadingPopIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.loading-header {
    text-align: center;
    margin-bottom: 1rem;
}

.loading-header h3 {
    font-size: 1.25rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.loading-header p {
    color: var(--text-light);
    font-size: 0.85rem;
}

.loading-spinner-main {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.loading-step {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: var(--background);
    border-radius: var(--radius);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.5;
}

.loading-step.active {
    background: linear-gradient(135deg, #EBF5FF 0%, #DBEAFE 100%);
    border-color: var(--primary);
    opacity: 1;
}

.loading-step.completed {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    border-color: var(--success);
    opacity: 1;
}

.loading-step-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.loading-step .loading-step-icon {
    background: var(--border);
    color: var(--text-light);
}

.loading-step.active .loading-step-icon {
    background: var(--primary);
    color: var(--white);
    animation: pulse 1.5s ease-in-out infinite;
}

.loading-step.completed .loading-step-icon {
    background: var(--success);
    color: var(--white);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(0, 102, 204, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(0, 102, 204, 0);
    }
}

.loading-step-content {
    flex: 1;
}

.loading-step-title {
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
    margin-bottom: 0.1rem;
}

.loading-step.active .loading-step-title {
    color: var(--primary);
}

.loading-step.completed .loading-step-title {
    color: #065F46;
}

.loading-step-desc {
    font-size: 0.75rem;
    color: var(--text-light);
}

.loading-step.active .loading-step-desc {
    color: var(--primary-dark);
}

.loading-step.completed .loading-step-desc {
    color: #047857;
}

.loading-progress {
    margin-top: 1rem;
    background: var(--border);
    border-radius: 10px;
    height: 6px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 10px;
    width: 0%;
    transition: width 0.5s ease;
}

.loading-time {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
    background: var(--text);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 1.5rem;
    margin-top: auto;
}

/* ============================================
   UTILITIES
   ============================================ */

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-light);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden {
    display: none !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .nav-dropdown-toggle {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .nav-dropdown-menu {
        position: fixed;
        left: 50%;
        transform: translateX(-50%) translateY(-5px);
        min-width: 280px;
    }

    .nav-dropdown:hover .nav-dropdown-menu {
        transform: translateX(-50%) translateY(0);
    }

    .main-content {
        padding: 1rem;
    }

    .card {
        padding: 1rem;
    }

    .serp-header {
        flex-wrap: wrap;
    }

    .analysis-score {
        flex-direction: column;
        text-align: center;
    }

    .tabs {
        flex-wrap: wrap;
    }
}

/* ============================================
   SHARE ANALYSIS BLOCK (réutilisable)
   ============================================ */

.share-analysis-block {
    margin-top: 0.75rem;
    border: 1px solid #E0E7FF;
    border-radius: var(--radius);
    background: #F5F7FF;
    overflow: hidden;
}

.share-analysis-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.share-analysis-toggle:hover {
    background: #EEF2FF;
}

.share-analysis-toggle-left {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #4338CA;
}

.share-analysis-toggle-left svg {
    color: #6366F1;
}

.share-count-badge {
    background: #6366F1;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    min-width: 1.1rem;
    text-align: center;
}

.share-chevron {
    color: #94A3B8;
    transition: transform 0.25s;
}

.share-chevron.open {
    transform: rotate(180deg);
}

.share-analysis-panel {
    padding: 0.75rem;
    border-top: 1px solid #E0E7FF;
    background: white;
}

.share-hint {
    font-size: 0.78rem;
    color: var(--text-light);
    margin: 0 0 0.5rem 0;
}

.share-users-grid {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 200px;
    overflow-y: auto;
}

.share-user-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    background: white;
}

.share-user-item:hover {
    border-color: #818CF8;
    background: #F5F7FF;
}

.share-user-item.share-user-active {
    border-color: #818CF8;
    background: #EEF2FF;
}

.share-user-item input[type="checkbox"] {
    display: none;
}

.share-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.share-user-info {
    flex: 1;
    min-width: 0;
}

.share-user-name {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-user-email {
    display: block;
    font-size: 0.7rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.share-user-check {
    display: none;
    color: #6366F1;
    flex-shrink: 0;
}

.share-user-item.share-user-active .share-user-check,
.share-user-item input[type="checkbox"]:checked ~ .share-user-check {
    display: flex;
}

.share-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.6rem;
}

.share-counter {
    font-size: 0.75rem;
    color: var(--text-light);
}

.share-readonly-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: #6366F1;
    background: #EEF2FF;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    border: 1px solid #C7D2FE;
    margin-top: 0.5rem;
}

.share-readonly-badge svg {
    flex-shrink: 0;
}

/* ============================================================ */
/* BLOCS DIDACTIQUES GLOBAUX                                    */
/* ============================================================ */

.didactic-intro {
    background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 100%);
    border: 2px solid #BAE6FD;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.didactic-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.didactic-header .didactic-icon {
    font-size: 1.75rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.didactic-header strong {
    display: block;
    font-size: 1.05rem;
    color: #0c4a6e;
    margin-bottom: 0.25rem;
}

.didactic-header p {
    margin: 0;
    font-size: 0.88rem;
    color: #0369a1;
    line-height: 1.5;
}

.didactic-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.didactic-step {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    background: white;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    border: 1px solid #E0F2FE;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.didactic-step:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(3, 105, 161, 0.1);
}

.didactic-step-number {
    background: linear-gradient(135deg, var(--primary) 0%, #0052A3 100%);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.didactic-step strong {
    display: block;
    font-size: 0.92rem;
    color: var(--text);
    margin-bottom: 0.2rem;
}

.didactic-step p {
    margin: 0;
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.5;
}

@media (max-width: 768px) {
    .didactic-header {
        flex-direction: column;
        gap: 0.5rem;
    }
    .didactic-step {
        flex-direction: column;
        gap: 0.5rem;
    }
}
