/* === Theme: Dark (default) === */
:root,
[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #8e8e93;
    --text-tertiary: #636366;
    --accent-blue: #0a84ff;
    --accent-green: #30d158;
    --accent-purple: #bf5af2;
    --separator: rgba(84, 84, 88, 0.35);
    --header-bg: rgba(0, 0, 0, 0.72);
    --phase-bg: rgba(0, 0, 0, 0.85);
    --overlay-shadow: rgba(0, 0, 0, 0.5);
}

/* === Theme: Light === */
[data-theme="light"] {
    --bg-primary: #f2f2f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e5ea;
    --text-primary: #000000;
    --text-secondary: #6c6c70;
    --text-tertiary: #8e8e93;
    --accent-blue: #007aff;
    --accent-green: #28cd41;
    --accent-purple: #af52de;
    --separator: rgba(60, 60, 67, 0.18);
    --header-bg: rgba(242, 242, 247, 0.72);
    --phase-bg: rgba(242, 242, 247, 0.85);
    --overlay-shadow: rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth transition between themes */
body,
.header,
.phase-header,
.phase-subtitle,
.contact-card,
.detail-back,
.contact-detail-overlay,
.search-input,
.action-btn,
.detail-section {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Light mode: avatar placeholder text stays white */
[data-theme="light"] .method-step-number {
    color: white;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* === Lucide SVG sizing === */
.search-icon svg,
.phase-chevron svg,
.contact-chevron svg,
.detail-back-icon svg { width: 18px; height: 18px; }

.action-btn-icon svg { width: 22px; height: 22px; }
.download-file-icon svg { width: 20px; height: 20px; }
.download-file-arrow svg { width: 16px; height: 16px; }

/* === Header === */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 16px 10px;
    border-bottom: 0.5px solid var(--separator);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.header-title {
    font-size: 34px;
    font-weight: 700;
    letter-spacing: 0.37px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-link {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease;
    text-decoration: none;
}
.header-link:active { background: var(--bg-secondary); }
.header-link svg { width: 20px; height: 20px; }

/* === Snapshot button === */
.snapshot-btn {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 18px;
    height: 36px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s ease, opacity 0.2s ease;
}
.snapshot-btn:hover { opacity: 0.85; }
.snapshot-btn:active { opacity: 0.7; }
.snapshot-btn svg { width: 16px; height: 16px; }

/* === Snapshot toast === */
.snapshot-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--accent-green);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.snapshot-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* === Language selector === */
.lang-selector {
    position: relative;
}

.lang-btn {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease;
    gap: 0;
    overflow: hidden;
}
.lang-btn:active { background: var(--bg-secondary); }
.lang-btn svg { width: 20px; height: 20px; }
.lang-code { display: none; }

.lang-dropdown {
    display: none;
    position: absolute;
    top: 42px;
    right: 0;
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--overlay-shadow);
    border: 0.5px solid var(--separator);
    overflow: hidden;
    z-index: 300;
    min-width: 140px;
}

.lang-dropdown.open { display: block; }

.lang-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.lang-option:hover,
.lang-option:focus { background: var(--bg-tertiary); }
.lang-option.active { color: var(--accent-blue); font-weight: 600; }
.lang-option + .lang-option { border-top: 0.5px solid var(--separator); }

/* === Theme toggle === */
.theme-toggle {
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}
.theme-toggle:active {
    background: var(--bg-secondary);
}
.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.search-container { position: relative; }

.search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 17px;
    font-family: inherit;
    outline: none;
}

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

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    display: flex;
}

/* === Phase sections === */
.phase-section {
    margin-bottom: 8px;
    animation: fadeUp 0.4s ease forwards;
}

.phase-header {
    display: flex;
    align-items: center;
    padding: 20px 16px 8px;
    position: sticky;
    top: 105px;
    z-index: 50;
    background: var(--phase-bg);
    backdrop-filter: blur(15px);
}

.phase-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    margin-right: 10px;
    flex-shrink: 0;
}

.phase-label {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.35px;
    flex: 1;
}


.phase-title-sep {
    color: var(--text-tertiary);
    font-weight: 400;
}

.contacts-list {
    overflow: hidden;
    transition: max-height 0.4s ease;
    max-height: none;
}


/* === Contact card === */
.contact-card {
    display: flex;
    align-items: center;
    padding: 12px 16px 12px 0;
    background: var(--bg-primary);
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 0.5px solid var(--separator);
    margin-left: 82px;
    position: relative;
}

.contact-card::before {
    content: '';
    position: absolute;
    left: -82px;
    top: 0;
    bottom: 0;
    width: 82px;
    cursor: pointer;
}

.contact-card:active { background: var(--bg-tertiary); }
.contact-card:last-child { border-bottom: none; }

.contact-avatar-wrapper {
    position: absolute;
    left: -70px;
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.contact-avatar-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

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

.contact-name {
    font-size: 17px;
    font-weight: 400;
    letter-spacing: -0.41px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-name .last-name { font-weight: 600; }

.contact-role {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.contact-chevron {
    color: var(--text-tertiary);
    margin-left: 8px;
    flex-shrink: 0;
    display: flex;
}

/* === Detail overlay === */
.contact-detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--bg-primary);
    overflow-y: auto;
    animation: slideIn 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.contact-detail-overlay.active { display: block; }

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

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

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

.detail-back {
    position: sticky;
    top: 0;
    z-index: 210;
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;
}

.detail-back-icon {
    color: var(--accent-blue);
    margin-right: 6px;
    display: flex;
}

.detail-back-text {
    font-size: 17px;
    color: var(--accent-blue);
}

/* === Detail hero === */
.detail-hero {
    text-align: center;
    padding: 30px 16px 24px;
}

.detail-avatar {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 14px;
    background: var(--bg-tertiary);
}

.detail-avatar-placeholder {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    font-weight: 600;
    color: white;
    margin: 0 auto 14px;
}

.detail-name {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.36px;
    margin-bottom: 4px;
}

.detail-agent-name {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-document {
    font-size: 13px;
    color: var(--text-tertiary);
}

.detail-phase-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 10px;
}

/* === Action buttons === */
.detail-actions {
    display: flex;
    justify-content: center;
    gap: 18px;
    padding: 6px 20px 20px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 14px;
    padding: 10px 12px 8px;
    cursor: pointer;
    min-width: 74px;
    transition: background 0.15s ease;
    text-decoration: none;
}

.action-btn:active { background: var(--bg-tertiary); }

.action-btn-icon { line-height: 1; display: flex; justify-content: center; }
.action-btn-label { font-size: 10px; font-weight: 500; }

.action-btn.call .action-btn-icon,
.action-btn.call .action-btn-label { color: var(--accent-green); }


/* === Detail sections === */
.detail-section {
    margin: 0 16px 10px;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.detail-section-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 20px 16px 8px;
}

.detail-description {
    padding: 14px 16px;
    font-size: 15px;
    line-height: 1.55;
}

/* === Accordion === */
.detail-accordion {
    margin: 0 16px 10px;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.detail-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    color: var(--text-primary);
}

.detail-accordion-header::-webkit-details-marker { display: none; }

.detail-accordion-icon {
    color: var(--text-tertiary);
    display: flex;
    transition: transform 0.25s ease;
}

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

.detail-accordion[open] .detail-accordion-icon {
    transform: rotate(180deg);
}

.detail-accordion-body {
    border-top: 0.5px solid var(--separator);
}

@media (min-width: 768px) {
    .detail-accordion {
        margin: 0 24px 10px;
    }
}

@media (min-width: 1024px) {
    .detail-accordion {
        margin: 0 28px 12px;
    }
}

/* === Methodology steps === */
.method-step {
    display: flex;
    padding: 10px 16px;
    border-bottom: 0.5px solid var(--separator);
    align-items: flex-start;
}

.method-step:last-child { border-bottom: none; }

.method-step-number {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-right: 12px;
    margin-top: 1px;
}

.method-step-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.method-step-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === Download files === */
.download-file-row {
    display: flex;
    align-items: center;
    padding: 11px 16px;
    border-bottom: 0.5px solid var(--separator);
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: inherit;
}

.download-file-row:last-child { border-bottom: none; }
.download-file-row:active { background: var(--bg-tertiary); }

.download-file-icon {
    margin-right: 12px;
    width: 28px;
    display: flex;
    justify-content: center;
    color: var(--accent-blue);
}

.download-file-info { flex: 1; }
.download-file-name { font-size: 15px; }

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

.download-file-arrow {
    color: var(--text-tertiary);
    display: flex;
}

/* === No results === */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 17px;
    display: none;
}

/* === Responsive === */

/* Viewport meta is set in HTML, so base styles are mobile-first */

/* Small phones (max-width: 374px) */
@media (max-width: 374px) {
    .header-title {
        font-size: 28px;
    }
    .search-input {
        font-size: 15px;
    }
    .phase-label {
        font-size: 18px;
    }
    .detail-name {
        font-size: 22px;
    }
    .detail-avatar,
    .detail-avatar-placeholder {
        width: 90px;
        height: 90px;
        border-radius: 50%;
        font-size: 36px;
    }
    .detail-actions {
        gap: 12px;
        padding: 6px 12px 16px;
    }
    .action-btn {
        min-width: 64px;
        padding: 8px 10px 6px;
    }
}

/* Tablets (min-width: 768px) */
@media (min-width: 768px) {
    body {
        max-width: 700px;
        margin: 0 auto;
    }
    .header {
        padding: 16px 24px 12px;
    }
    .header-title {
        font-size: 36px;
    }
    .phase-header {
        padding: 20px 24px 8px;
    }
    .contact-card {
        padding: 14px 24px 14px 0;
    }
    .contact-avatar,
    .contact-avatar-placeholder {
        width: 48px;
        height: 48px;
    }
    .detail-section {
        margin: 0 24px 10px;
    }
    .detail-section-header {
        padding: 20px 24px 8px;
    }
    .detail-hero {
        padding: 36px 24px 28px;
    }
    .detail-actions {
        gap: 24px;
    }
    .action-btn {
        min-width: 90px;
        padding: 12px 16px 10px;
        border-radius: 16px;
    }
    .action-btn-label {
        font-size: 11px;
    }
    .action-btn-icon svg {
        width: 24px;
        height: 24px;
    }
    .detail-description {
        font-size: 16px;
        line-height: 1.6;
    }
}

/* Desktop (min-width: 1024px) */
@media (min-width: 1024px) {
    body {
        max-width: 900px;
        margin: 0 auto;
    }
    .header {
        padding: 20px 32px 14px;
        border-radius: 0 0 16px 16px;
    }
    .header-title {
        font-size: 38px;
    }
    .search-input {
        max-width: 400px;
    }
    .phase-header {
        padding: 24px 32px 10px;
    }

    .contact-avatar,
    .contact-avatar-placeholder {
        width: 50px;
        height: 50px;
    }

    /* Overlay en panneau latéral sur desktop */
    .contact-detail-overlay {
        left: auto;
        right: 0;
        width: 520px;
        box-shadow: -10px 0 40px var(--overlay-shadow);
        border-left: 0.5px solid var(--separator);
    }
    .detail-section {
        margin: 0 28px 12px;
    }
    .detail-section-header {
        padding: 20px 28px 8px;
    }
    .detail-hero {
        padding: 40px 28px 30px;
    }
    .detail-avatar,
    .detail-avatar-placeholder {
        width: 120px;
        height: 120px;
        border-radius: 50%;
        font-size: 48px;
    }
    .detail-name {
        font-size: 28px;
    }
    .detail-description {
        font-size: 16px;
        line-height: 1.65;
    }
}

/* Large desktop (min-width: 1440px) */
@media (min-width: 1440px) {
    body {
        max-width: 1100px;
    }
    .contact-detail-overlay {
        width: 600px;
    }
}

/* === Accessibility === */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.theme-toggle:focus-visible,
.search-input:focus-visible,
.action-btn:focus-visible,
.contact-card:focus-visible,
.detail-back:focus-visible,
.download-file-row:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* === Missing layout classes === */
.method-step-content {
    flex: 1;
    min-width: 0;
}

.download-files {
    display: flex;
    flex-direction: column;
}

/* === Detail back button reset === */
.detail-back {
    appearance: none;
    background: var(--header-bg);
    border: none;
    font: inherit;
    color: inherit;
    width: 100%;
}

::-webkit-scrollbar { width: 0; }
