/* FidesIA — Theme & Layout */

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
button, a, [role="button"] { touch-action: manipulation; }

:root {
    --bg-primary: #faf8f5;
    --bg-secondary: #f0ebe4;
    --bg-tertiary: #e8e0d6;
    --text-primary: #2c1810;
    --text-secondary: #5a4a3e;
    --text-muted: #8a7a6e;
    --accent: #8b1a2b;
    --accent-hover: #a62038;
    --gold: #c5961a;
    --gold-light: #d4a830;
    --border: #e0d5c8;
    --border-light: #ede7df;
    --shadow: rgba(44, 24, 16, 0.08);
    --radius: 10px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
    --max-chat: 1020px;
    --sidebar-width: 280px;
    --header-height: 56px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1510;
        --bg-secondary: #241e17;
        --bg-tertiary: #2e2620;
        --text-primary: #e8ddd0;
        --text-secondary: #b8a898;
        --text-muted: #9a8a7e;
        --accent: #d4475a;
        --accent-hover: #e05a6c;
        --gold: #d4a830;
        --gold-light: #e0b840;
        --border: #3a3025;
        --border-light: #2e2620;
        --shadow: rgba(0, 0, 0, 0.3);
    }
}

html, body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    overscroll-behavior: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* === Focus visible === */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* === App Layout === */
.app-layout {
    display: flex;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-close-btn {
    display: none;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.new-chat-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 8px;
}

.conv-item {
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background var(--transition);
    min-height: 36px;
}

.conv-item:hover { background: var(--bg-tertiary); }
.conv-item.active { background: var(--bg-tertiary); color: var(--text-primary); font-weight: 500; }

.conv-item .conv-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-actions {
    display: flex;
    gap: 2px;
    transition: opacity var(--transition);
}

/* Desktop: hide until hover */
@media (hover: hover) {
    .conv-actions { display: none; }
    .conv-item:hover .conv-actions { display: flex; }
}

/* Touch devices: always visible */
@media (hover: none) {
    .conv-actions { opacity: 0.6; }
}

.btn-mini-danger:hover {
    color: var(--accent);
    background: rgba(139, 26, 43, 0.1);
}

/* Sidebar compact widgets (saint, lectures, heures) */
.saint-du-jour,
.lectures-du-jour,
.heures-du-jour {
    flex-shrink: 0;
}

.saint-du-jour {
    border-top: 1px solid var(--border);
}

.sidebar-compact-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    transition: background var(--transition);
    overflow: hidden;
}

.sidebar-compact-widget:hover {
    background: var(--bg-tertiary);
}

.sidebar-compact-widget svg {
    flex-shrink: 0;
    stroke: var(--text-muted);
}

.sidebar-compact-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sidebar-compact-detail {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-left: auto;
}

/* === Sidebar navigation === */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.sidebar-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--transition);
    min-height: 40px;
}

.sidebar-nav-btn:hover {
    background: var(--bg-tertiary);
}

.sidebar-nav-btn.active {
    color: var(--accent);
    font-weight: 600;
}

.sidebar-nav-btn svg:first-child {
    flex-shrink: 0;
    stroke: currentColor;
}

.sidebar-nav-chevron {
    margin-left: auto;
    transition: transform 0.2s ease;
}

.sidebar-nav-btn.active .sidebar-nav-chevron {
    transform: rotate(90deg);
}

.sidebar-nav-donate {
    color: var(--accent);
}

/* Sidebar widgets & donate banner — remplacés par sidebar-nav */
.saint-du-jour,
.lectures-du-jour,
.heures-du-jour,
.sidebar-donate {
    display: none;
}

.donate-link {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    transition: all var(--transition);
}

.donate-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.donate-heart {
    color: var(--accent);
    font-size: 14px;
    flex-shrink: 0;
    line-height: 1.5;
}

.donate-text {
    flex: 1;
}

/* Sidebar footer (compte) */
.sidebar-footer {
    margin-top: auto;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    overflow: hidden;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 1px;
}

.sidebar-user-info span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-profile {
    font-size: 11px;
    font-weight: 400;
    color: var(--text-muted);
}

.sidebar-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: all var(--transition);
    min-width: 44px;
    min-height: 44px;
}

.sidebar-logout:hover {
    background: var(--accent);
    color: white;
}

.sidebar-legal {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 12px 8px;
    flex-shrink: 0;
}
.sidebar-legal a {
    color: var(--text-muted);
    text-decoration: none;
}
.sidebar-legal a:hover {
    color: var(--accent);
}

/* === Main === */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* === Header === */
.header {
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    gap: 8px;
    flex-shrink: 0;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 18px;
    flex: 1;
}

.brand-cross {
    color: var(--accent);
    display: flex;
    align-items: center;
}

.brand-cross svg {
    width: 20px;
    height: 20px;
}

.brand-name {
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 4px;
}

.header-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    min-width: 44px;
    min-height: 44px;
}

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

/* === Chat Area === */
.chat-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
}

/* === Welcome === */
.welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.welcome-icon {
    color: var(--accent);
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.welcome-icon svg {
    width: 56px;
    height: 56px;
}

.welcome h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.welcome p {
    color: var(--text-secondary);
    font-size: 16px;
    max-width: 600px;
}

.welcome-sub {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.welcome-disclaimer {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 16px;
    line-height: 1.5;
}

.welcome-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 32px;
    justify-content: center;
}

.example-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 10px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
}

.example-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent);
    color: var(--text-primary);
}

/* === Input Area === */
.input-area {
    padding: 12px 16px 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-light);
    background: var(--bg-primary);
    flex-shrink: 0;
}

.chat-form {
    max-width: var(--max-chat);
    margin: 0 auto;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-secondary);
    max-height: 150px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    line-height: 1.5;
    transition: border-color var(--transition);
}

#chat-input:focus,
#chat-input:focus-visible {
    border-color: var(--accent);
    outline: none;
}

#chat-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    flex-shrink: 0;
    align-self: stretch;
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background: var(--accent);
    color: white;
}

.send-btn:hover svg {
    stroke: white;
}

.send-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--accent);
}

.guest-banner {
    max-width: var(--max-chat);
    margin: 8px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

/* === Legal footer === */
.legal-footer {
    max-width: var(--max-chat);
    margin: 4px auto 0;
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    padding: 2px 16px 4px;
}
.legal-footer a {
    color: var(--text-muted);
    text-decoration: none;
}
.legal-footer a:hover {
    color: var(--accent);
}

/* === AI notice === */
.ai-notice {
    max-width: var(--max-chat);
    margin: 8px auto;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
}
.ai-notice p { flex: 1; margin: 0; line-height: 1.4; }
.ai-notice-btn {
    padding: 6px 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    background: transparent;
    color: var(--accent);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}
.ai-notice-btn:hover {
    background: var(--accent);
    color: white;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    gap: 6px;
}

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

.btn-primary:hover, .btn-accent:hover { background: var(--accent-hover); }
.btn-primary:disabled, .btn-accent:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-small {
    padding: 6px 12px;
    font-size: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

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

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 32px;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    max-height: 85svh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: 0 20px 60px var(--shadow);
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover { color: var(--text-primary); }

/* === Auth Modal === */
.auth-tabs {
    display: flex;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.auth-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.auth-form { display: flex; flex-direction: column; gap: 16px; }

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

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

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

.form-group input:focus,
.form-group input:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.form-error {
    color: var(--accent);
    font-size: 13px;
    padding: 8px 12px;
    background: rgba(139, 26, 43, 0.08);
    border-radius: var(--radius);
}

/* === Forgot Password === */
.forgot-link {
    display: block;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    margin-top: 4px;
    transition: color var(--transition);
}

.forgot-link:hover {
    color: var(--accent);
}

.forgot-intro {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.5;
}

.forgot-success {
    font-size: 13px;
    padding: 12px;
    background: rgba(34, 139, 34, 0.08);
    color: #2d7a2d;
    border-radius: var(--radius);
    line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
    .forgot-success {
        background: rgba(34, 139, 34, 0.15);
        color: #5cb85c;
    }
}

/* Reset password page */
.reset-container {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.reset-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 4px 24px var(--shadow);
    text-align: center;
}

.reset-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.reset-card .reset-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.reset-card .form-group {
    text-align: left;
}

.reset-card .btn {
    width: 100%;
    margin-top: 8px;
}

/* === Profile Modal === */
.profile-modal-content { max-width: 600px; }
.profile-modal-content h2 { margin-bottom: 20px; }

.profile-section {
    margin-bottom: 20px;
}

.profile-section h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.profile-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.profile-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition);
}

.profile-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.profile-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.profile-register-options {
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.profile-reassurance {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.4;
    margin-bottom: 8px;
}

.form-optional {
    font-weight: 400;
    font-size: 11px;
    color: var(--text-muted);
}

.profile-hint {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 12px;
}

.profile-danger-zone {
    margin-top: 24px;
    text-align: center;
}

.btn-danger-outline {
    background: transparent;
    color: #c0392b;
    border: 1px solid #c0392b;
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-danger-outline:hover {
    background: #c0392b;
    color: #fff;
}

/* === Delete Account Modal === */
.delete-modal-content {
    max-width: 420px;
}

.delete-modal-title {
    color: #c0392b;
    margin-bottom: 8px;
}

.delete-modal-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.delete-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.delete-modal-actions .btn,
.delete-modal-actions .btn-danger-outline {
    flex: 1;
}

/* === Corpus Modal === */
.corpus-modal-content {
    max-width: 860px;
    max-height: 80vh;
    max-height: 80svh;
}

.corpus-modal-content h2 { margin-bottom: 16px; }

.corpus-search {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    margin-bottom: 16px;
    transition: border-color var(--transition);
}

.corpus-search:focus,
.corpus-search:focus-visible {
    border-color: var(--accent);
    outline: none;
}

.corpus-list {
    max-height: 55vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.corpus-group {
    margin-bottom: 16px;
}

.corpus-group-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

.corpus-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition);
}

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

.corpus-item .corpus-year {
    color: var(--text-muted);
    font-size: 12px;
    min-width: 40px;
}

.corpus-item .corpus-link {
    margin-left: auto;
    color: var(--gold);
    font-size: 12px;
    text-decoration: none;
}

.corpus-item .corpus-link:hover { text-decoration: underline; }

/* === Saint Detail Modal === */
.saint-modal-content {
    max-width: 680px;
    max-height: 85vh;
    max-height: 85svh;
    overflow-y: auto;
}

.saint-header {
    text-align: center;
    margin-bottom: 24px;
}

.saint-header h2 {
    font-size: 22px;
    margin-bottom: 4px;
}

.saint-latin {
    font-style: italic;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 6px;
}

.saint-titres {
    color: var(--gold);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
}

.saint-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.saint-fete {
    font-weight: 600;
    color: var(--accent);
}

.saint-celebration {
    font-size: 11px;
    font-style: italic;
    color: var(--text-muted);
}

/* Liturgical rank badges */
.saint-rank {
    display: inline-block;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 8px;
    vertical-align: middle;
    margin-left: 4px;
    text-transform: uppercase;
}

.saint-rank-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
}

.saint-rank-solennite {
    background: var(--gold);
    color: #fff;
}

.saint-rank-fete {
    background: var(--accent);
    color: #fff;
}

.saint-rank-memoire-obligatoire {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.saint-rank-memoire-facultative {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.saint-section {
    margin-bottom: 20px;
}

.saint-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

.saint-bio {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    text-align: justify;
}

.saint-quote {
    margin: 0 0 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-left: 3px solid var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.saint-quote p {
    font-size: 14px;
    font-style: italic;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.saint-quote cite {
    font-size: 12px;
    color: var(--text-muted);
    font-style: normal;
}

.saint-ecrits {
    list-style: none;
    padding: 0;
}

.saint-ecrits li {
    padding: 8px 0;
    font-size: 13px;
    line-height: 1.5;
}

.saint-annee {
    color: var(--text-muted);
    font-size: 12px;
}

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

.saint-themes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.saint-theme {
    padding: 4px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.saint-theme-btn {
    cursor: pointer;
    font-family: inherit;
    transition: all var(--transition);
}

.saint-theme-btn:hover {
    background: var(--gold);
    color: #fff;
    border-color: var(--gold);
}

.saint-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.saint-links a {
    font-size: 12px;
    color: var(--gold);
    text-decoration: none;
}

.saint-links a:hover {
    text-decoration: underline;
}

.saint-ask {
    margin-top: 24px;
    text-align: center;
}

.saint-ask .btn {
    width: 100%;
}

/* === Donation Popup === */
.donate-modal-content {
    max-width: 420px;
    text-align: center;
}

.donate-icon {
    color: var(--accent);
    margin-bottom: 12px;
}

.donate-icon svg {
    width: 48px;
    height: 48px;
}

.donate-modal-content h2 {
    margin-bottom: 12px;
    font-size: 20px;
}

.donate-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.donate-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.donate-btn-primary {
    text-decoration: none;
    width: 100%;
}

/* Sidebar toggle — visible sur toutes les tailles (contrôlé par hidden attr) */
#sidebar-toggle:not([hidden]) {
    display: flex;
}

/* Desktop : collapse le sidebar */
@media (min-width: 769px) {
    .sidebar.collapsed {
        display: none;
    }
}

/* === Responsive: Tablet (768-1023px) === */
@media (max-width: 1023px) and (min-width: 769px) {
    .sidebar { width: 240px; }
    .welcome h1 { font-size: 28px; }
    .welcome-icon svg { width: 48px; height: 48px; }
}

/* === Responsive: Mobile (<= 768px) === */
@media (max-width: 768px) {
    #sidebar-toggle:not([hidden]) {
        display: flex;
    }

    .sidebar-close-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        z-index: 100;
        left: -100%;
        top: 0;
        bottom: 0;
        max-width: 300px;
        width: 85%;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .welcome h1 { font-size: 24px; }
    .welcome-icon svg { width: 40px; height: 40px; }
    .welcome-icon { margin-bottom: 12px; }
    .welcome-sub { font-size: 13px; }

    .welcome-examples {
        flex-direction: column;
    }

    .welcome-examples .example-btn:nth-child(n+4) {
        display: none;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
        max-height: 90vh;
        max-height: 90svh;
    }

    .corpus-modal-content,
    .saint-modal-content,
    .metrics-modal-content {
        max-width: 100%;
    }

    .metrics-row { grid-template-columns: 1fr; }
    .metrics-modal-content { padding: 16px; }

    .donate-icon svg { width: 36px; height: 36px; }

    /* Masquer icônes header sauf auth sur mobile */
    .header-actions .header-btn:not(#auth-btn) { display: none; }
}

/* === Responsive: Small mobile (<= 374px, iPhone SE) === */
@media (max-width: 374px) {
    html, body { font-size: 14px; }

    .header { padding: 0 10px; gap: 4px; }

    .input-area { padding: 8px 10px 10px; }
    .chat-form { gap: 6px; }

    .modal-content { padding: 16px; }

    .guest-banner {
        flex-direction: column;
        gap: 4px;
        font-size: 12px;
    }

    .sidebar-compact-label { font-size: 11px; }
}

/* === Responsive: Landscape on small screens === */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        height: 44px;
        padding: 0 12px;
    }

    .input-area { padding: 8px 12px; }

    .modal-content {
        max-height: 92vh;
        padding: 16px;
    }

    .welcome { padding: 16px; }
    .welcome-icon svg { width: 32px; height: 32px; }
    .welcome-icon { margin-bottom: 8px; }
    .welcome h1 { font-size: 22px; }

    .metrics-row { grid-template-columns: 1fr; }
    .metrics-modal-content { padding: 16px; }
    .metrics-kpis { grid-template-columns: repeat(3, 1fr); }
}

/* ===================== */
/* Admin Metrics Dashboard */
/* ===================== */

.metrics-modal-content {
    max-width: 960px;
    max-height: 85vh;
    max-height: 85svh;
}

.metrics-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.metrics-header h2 { margin: 0; }

.metrics-period {
    display: flex;
    gap: 4px;
}

.metrics-period-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
}

.metrics-period-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.metrics-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

.metrics-kpis-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    margin: 0 0 12px 0;
}

.metrics-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.metrics-kpi {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
}

.metrics-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.1;
}

.metrics-kpi-suffix {
    font-size: 14px;
    font-weight: 400;
    color: var(--text-muted);
}

.metrics-kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metrics-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.metrics-card {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
    overflow-x: auto;
}

.metrics-card h3 {
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.metrics-table th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    white-space: nowrap;
}

.metrics-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border-light);
}

.metrics-table code {
    font-size: 11px;
    background: var(--bg-tertiary);
    padding: 1px 4px;
    border-radius: 3px;
}

.metrics-empty {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

/* === Lectures du jour Modal === */
.lectures-modal-content {
    max-width: 680px;
    max-height: 85vh;
    max-height: 85svh;
    overflow-y: auto;
}

.lectures-header {
    text-align: center;
    margin-bottom: 24px;
}

.lectures-header h2 {
    font-size: 22px;
    margin: 0 0 4px 0;
    color: var(--text);
}

.lectures-couleur {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-bottom: 8px;
}

.lectures-fete {
    color: var(--gold);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.lectures-temps {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.lectures-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.lecture-item {
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border-left: 4px solid var(--border);
}

.lecture-psaume {
    border-left-color: var(--gold);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(200, 155, 60, 0.05) 100%);
}

.lecture-evangile {
    border-left-color: var(--accent);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(74, 125, 255, 0.05) 100%);
}

.lecture-type {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.lecture-ref {
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 4px;
}

.lecture-titre {
    font-size: 14px;
    font-style: italic;
    color: var(--gold);
    margin-bottom: 8px;
}

.lecture-refrain {
    font-size: 14px;
    color: var(--text);
    background: rgba(200, 155, 60, 0.1);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-style: italic;
}

.lecture-refrain strong {
    color: var(--gold);
}

.lecture-contenu {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.lecture-contenu-collapsed {
    max-height: 200px;
    overflow: hidden;
    position: relative;
}

.lecture-contenu-collapsed::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--bg-secondary));
}

.lecture-expand-btn {
    display: block;
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
    color: var(--accent);
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.lecture-expand-btn:hover {
    background: var(--accent);
    color: #fff;
}

.lectures-actions {
    margin-top: 24px;
    text-align: center;
}

.homelie-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
}

.homelie-btn svg {
    flex-shrink: 0;
}

.lectures-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 40px 20px;
}

/* === Heures modal === */

.heures-modal-content {
    max-width: 680px;
    max-height: 85vh;
    max-height: 85svh;
    overflow-y: auto;
}

.heures-header {
    text-align: center;
    margin-bottom: 20px;
}

.heures-header h2 {
    font-size: 22px;
    margin: 0 0 4px 0;
}

.heures-jour {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.heures-temps {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: capitalize;
    margin-bottom: 12px;
}

.heures-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

.heures-tab {
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.heures-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.heures-tab-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.heures-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.heures-element {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border-left: 3px solid var(--border);
}

.heures-element-titre {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.heures-antienne {
    font-size: 13px;
    font-style: italic;
    color: var(--gold);
    margin-bottom: 6px;
}

.heures-reference {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    margin-bottom: 4px;
}

.heures-texte {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

.heures-refrain {
    font-size: 13px;
    color: var(--text);
    background: rgba(200, 155, 60, 0.1);
    padding: 6px 10px;
    border-radius: 6px;
    margin-top: 8px;
    font-style: italic;
}

.heures-refrain strong {
    color: var(--gold);
}

.heures-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 40px 20px;
}
