/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sage-green: #00853e;
    --sage-green-dark: #006b32;
    --sage-green-light: #e8f5ee;
    --sage-green-bg: #f0faf4;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
    --radius-full: 9999px;
    --radius-xl: 24px;
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --transition: 0.2s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.6;
}

/* ===== Écran d'accueil ===== */
.landing {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 40px 20px;
}

.landing.hidden { display: none; }

.landing-content {
    text-align: center;
    width: 100%;
    max-width: 720px;
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 14px;
}

.logo-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--sage-green), #2ecc71);
    color: white;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: 0 6px 20px rgba(0, 133, 62, 0.25);
}

.logo-icon.small {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 1rem;
}

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

.tagline {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 36px;
    line-height: 1.6;
}

/* ===== Search box ===== */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    padding: 5px 5px 5px 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow-sm);
}

.search-input-wrapper:focus-within {
    border-color: var(--sage-green);
    box-shadow: 0 0 0 4px rgba(0, 133, 62, 0.08), var(--shadow-md);
}

.search-input-wrapper.compact {
    padding: 3px 3px 3px 16px;
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 14px;
    font-size: 1rem;
    color: var(--text-primary);
    background: transparent;
}

.compact input {
    padding: 8px 12px;
    font-size: 0.92rem;
}

.search-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.search-input-wrapper button {
    width: 46px;
    height: 46px;
    background: var(--sage-green);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}

.compact button {
    width: 38px;
    height: 38px;
}

.search-input-wrapper button svg {
    width: 20px;
    height: 20px;
}

.compact button svg {
    width: 16px;
    height: 16px;
}

.search-input-wrapper button:hover {
    background: var(--sage-green-dark);
    transform: scale(1.06);
}

.search-input-wrapper button:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* ===== Questions fréquentes ===== */
.questions-section {
    margin-top: 40px;
    text-align: left;
}

.questions-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 16px;
    text-align: center;
}

.questions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.question-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text-secondary);
}

.question-card:hover {
    border-color: var(--sage-green);
    background: var(--sage-green-bg);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.question-card:hover .question-icon {
    background: var(--sage-green);
    color: white;
}

.question-card strong {
    color: var(--text-primary);
    font-weight: 600;
}

.question-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: var(--sage-green-light);
    color: var(--sage-green);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.question-icon svg {
    width: 20px;
    height: 20px;
}

/* ===== Doc info ===== */
.doc-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 36px;
    font-size: 0.82rem;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 8px 18px;
    border-radius: var(--radius-full);
}

/* ===== Header fixe ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.header.hidden { display: none; }

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.header-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.header-search {
    flex: 1;
    max-width: 560px;
}

/* ===== Zone de résultats ===== */
.results-area {
    padding: 96px 20px 60px;
    min-height: 100vh;
}

.results-area.hidden { display: none; }

.results-container {
    max-width: 800px;
    margin: 0 auto;
}

.results-header {
    margin-bottom: 24px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.results-header:empty {
    display: none;
}

.results-header strong {
    color: var(--text-primary);
}

/* ===== Loading ===== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 80px 0;
    color: var(--text-muted);
}

.loading.hidden { display: none; }

.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 12px;
    height: 12px;
    background: var(--sage-green);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.loading-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ===== Résultats ===== */
.results {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.result-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--border);
    transition: box-shadow var(--transition), border-color var(--transition);
    animation: fadeInUp 0.35s ease forwards;
    opacity: 0;
    overflow: hidden;
}

.result-card:nth-child(1) { animation-delay: 0.04s; }
.result-card:nth-child(2) { animation-delay: 0.08s; }
.result-card:nth-child(3) { animation-delay: 0.12s; }
.result-card:nth-child(4) { animation-delay: 0.16s; }
.result-card:nth-child(5) { animation-delay: 0.20s; }

.result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.result-card.expanded {
    border-color: var(--sage-green);
    box-shadow: 0 0 0 3px rgba(0, 133, 62, 0.06), var(--shadow-md);
}

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

/* --- Résumé cliquable --- */
.result-summary {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px 22px;
    cursor: pointer;
    user-select: none;
}

.rank-badge {
    width: 34px;
    height: 34px;
    background: var(--sage-green-light);
    color: var(--sage-green);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 2px;
}

.result-card:first-child .rank-badge {
    background: var(--sage-green);
    color: white;
}

.result-summary-body {
    flex: 1;
    min-width: 0;
}

.result-summary-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.result-source {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sage-green);
}

.result-source svg {
    width: 14px;
    height: 14px;
}

.result-page-badge {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.result-score-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

.result-score-pill.high {
    background: var(--sage-green-light);
    color: var(--sage-green);
}

.result-score-pill.medium {
    background: #fef3c7;
    color: #b45309;
}

.result-score-pill.low {
    background: var(--border-light);
    color: var(--text-muted);
}

.result-preview {
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-preview mark {
    background: #fef9c3;
    color: var(--text-primary);
    padding: 1px 3px;
    border-radius: 4px;
}

/* Chevron */
.result-chevron {
    width: 22px;
    height: 22px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-top: 6px;
    transition: transform 0.25s ease, color var(--transition);
}

.result-card:hover .result-chevron {
    color: var(--text-secondary);
}

.result-card.expanded .result-chevron {
    transform: rotate(180deg);
    color: var(--sage-green);
}

/* --- Partie dépliable --- */
.result-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.result-card.expanded .result-detail {
    max-height: 2000px;
}

.result-detail-inner {
    margin: 0 22px 22px 66px;
    border-top: 1px solid var(--border);
    padding-top: 18px;
}

.result-text-wrapper {
    position: relative;
}

.result-full-text {
    font-size: 0.9rem;
    line-height: 1.85;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--border-light);
    padding: 20px;
    padding-right: 90px;
    border-radius: var(--radius-md);
}

.result-full-text mark {
    background: #fef9c3;
    color: inherit;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 600;
}

/* Bouton copier */
.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition);
    z-index: 2;
}

.copy-btn svg {
    width: 14px;
    height: 14px;
}

.copy-btn .hidden { display: none; }

.copy-btn:hover {
    color: var(--sage-green);
    border-color: var(--sage-green);
    background: var(--sage-green-light);
}

.copy-btn.copied {
    color: var(--sage-green);
    border-color: var(--sage-green);
    background: var(--sage-green-light);
}

/* Footer du résultat */
.result-detail-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.detail-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-page);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

.detail-tag svg {
    width: 13px;
    height: 13px;
}

/* ===== État vide ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px;
    height: 56px;
    color: var(--border);
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 1rem;
    line-height: 1.6;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
    .landing {
        padding: 30px 16px;
        align-items: flex-start;
        padding-top: 50px;
    }

    .logo h1 { font-size: 1.6rem; }

    .tagline {
        font-size: 0.95rem;
        margin-bottom: 28px;
    }

    .questions-grid {
        grid-template-columns: 1fr;
    }

    .question-card {
        padding: 14px 16px;
        font-size: 0.88rem;
    }

    .question-icon {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .question-icon svg {
        width: 18px;
        height: 18px;
    }

    .header-title { display: none; }
    .header-inner { gap: 10px; }

    .result-summary {
        padding: 16px;
        gap: 12px;
    }

    .rank-badge {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }

    .result-detail-inner {
        margin-left: 16px;
        margin-right: 16px;
    }

    .result-full-text {
        padding: 16px;
        padding-right: 16px;
        font-size: 0.88rem;
    }

    .copy-btn {
        position: static;
        margin-top: 10px;
    }

    .result-score-pill { margin-left: 0; }

    .result-summary-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .results-header {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}
