/* Optotoolkit - Components & Applet Styles */

/* Navigation Bar Container */
.nav-container {
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-mobile-header {
    display: none;
    background: var(--bg-surface);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 1002;
    position: relative;
}

.navbar-mobile-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-toggle-btn {
    background: var(--accent-blue);
    color: #ffffff;
    border: none;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 700;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    white-space: nowrap;
}

.navbar {
    display: flex;
    gap: 6px;
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

/* Navigation Group Block (Accordion & Dropdown) */
.nav-group-block {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.nav-group-header-btn {
    background: linear-gradient(135deg, var(--bg-surface-alt), var(--bg-surface));
    color: var(--accent-blue);
    border: 1px solid var(--border-strong);
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 800;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    width: 100%;
    text-align: left;
    transition: all 0.2s ease;
    user-select: none;
}

.nav-group-header-btn:hover {
    background: var(--accent-blue);
    color: #ffffff;
    border-color: var(--accent-blue-hover);
}

.nav-group-arrow {
    font-size: 12px;
    transition: transform 0.25s ease;
}

.nav-group-block.open .nav-group-arrow {
    transform: rotate(180deg);
}

.nav-group-children {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    padding-top: 8px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, padding 0.25s ease;
}

.nav-group-block.open .nav-group-children {
    max-height: 800px;
    opacity: 1;
    overflow: visible;
}

@media (max-width: 820px) {
    .nav-group-children {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding-left: 10px;
        border-left: 2px dashed var(--accent-blue);
        margin-left: 6px;
        margin-top: 4px;
    }
}

@media (max-width: 820px) {
    .navbar-mobile-header {
        display: flex;
    }

    .navbar {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-surface);
        border-bottom: 2px solid var(--border-strong);
        box-shadow: 0 20px 40px rgba(0,0,0,0.4);
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        padding: 0 16px;
        pointer-events: none;
        transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, padding 0.35s ease;
        z-index: 1001;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .navbar.mobile-open {
        max-height: 80vh;
        opacity: 1;
        overflow-y: auto;
        padding: 14px 16px;
        pointer-events: auto;
    }

    .navbar .tab-btn {
        width: 100%;
        justify-content: flex-start;
        padding: 12px 16px;
        font-size: 14px;
    }
}

.tab-btn {
    background: var(--bg-surface-alt);
    color: var(--text-muted);
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    background: var(--border-color);
    color: var(--text-main);
    transform: translateY(-1px);
}

.tab-btn.active {
    background: var(--accent-blue);
    color: #ffffff;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    border-color: var(--accent-blue-hover);
}

/* Global Action Bar */
.action-toolbar {
    padding: 14px 24px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--bg-base);
}

/* Buttons */
button {
    cursor: pointer;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.main-btn {
    background: linear-gradient(135deg, var(--accent-red), var(--accent-red-hover));
    color: #ffffff;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(225, 29, 72, 0.25);
}

.main-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(225, 29, 72, 0.35);
}

.secondary-btn {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-blue-hover));
    color: #ffffff;
    padding: 10px 18px;
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.secondary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.small-btn {
    background: var(--bg-surface-alt);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
}

.small-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

/* Accordions Collapsible Fieldsets */
fieldset.opto-accordion {
    padding: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

fieldset.opto-accordion legend {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-left: 0;
    padding: 12px 18px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    transition: background-color 0.2s ease, color 0.2s ease;
}

fieldset.opto-accordion legend:hover {
    background: var(--bg-surface-alt);
    color: var(--accent-red-hover);
}

fieldset.opto-accordion.open legend {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    background: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-color);
}

.accordion-chevron {
    font-size: 11px;
    transition: transform 0.3s ease;
    margin-left: 12px;
    color: var(--text-muted);
}

fieldset.opto-accordion.collapsed .accordion-chevron {
    transform: rotate(-90deg);
}

fieldset.opto-accordion.open .accordion-chevron {
    transform: rotate(0deg);
}

.accordion-body {
    padding: 18px;
    transition: opacity 0.25s ease, max-height 0.35s ease;
}

fieldset.opto-accordion.collapsed .accordion-body {
    display: none;
}

fieldset.opto-accordion.open .accordion-body {
    display: block;
    animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Eye Board Canvas */
.eye-board {
    position: relative;
    width: 100%;
    max-width: 260px;
    aspect-ratio: 1/1;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.eye-board svg {
    width: 100%;
    height: 100%;
    display: block;
}

.eye-board canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
}

/* Photo-mesure + diagnostic IA Studio */
.file-picker-box {
    border: 1px solid var(--border-color);
    background: var(--bg-surface-alt);
    padding: 14px;
    border-radius: var(--radius-md);
    margin: 10px 0 16px;
}

.file-picker-box input[type="file"] {
    display: block;
    width: 100%;
    margin: 6px 0 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.photo-measure-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .photo-measure-grid {
        grid-template-columns: 1fr;
    }
}

.measure-canvas-wrap {
    position: relative;
    width: 100%;
    min-height: 280px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: #090d16;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#eyeMeasureCanvas_od, #eyeMeasureCanvas_og {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    touch-action: none;
}

.measure-help {
    background: var(--bg-surface-alt);
    border-left: 4px solid var(--accent-red);
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-main);
}

.measure-status {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: rgba(217, 119, 6, 0.1);
    border: 1px solid rgba(217, 119, 6, 0.3);
    color: var(--accent-amber);
    font-size: 13px;
    font-weight: 600;
}

.measure-chip {
    display: inline-block;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 4px 10px;
    margin: 3px;
    font-size: 12px;
    font-weight: 600;
}

.ai-config-box {
    margin: 12px 0 16px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-surface-alt);
}

.ai-diagnostic-box textarea {
    min-height: 160px;
    font-family: var(--font-family);
    font-size: 13px;
    line-height: 1.5;
    border-radius: var(--radius-md);
}

.ai-warn {
    margin-top: 8px;
    color: var(--accent-amber);
    font-size: 12px;
    font-weight: 600;
}

/* Efron Visual Badges */
.efron-badge {
    display: inline-block;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    letter-spacing: 0.02em;
}

.efron-grade-0 { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.efron-grade-1 { background: #fef9c3; color: #854d0e; border: 1px solid #fef08a; }
.efron-grade-2 { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.efron-grade-3 { background: #ffedd5; color: #9a3412; border: 1px solid #fed7aa; }
.efron-grade-4 { background: #ffe4e6; color: #9f1239; border: 1px solid #fecdd3; }

/* Dedicated OSDI Tab Radio Choice Pills */
.osdi-card-question {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.osdi-card-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 8px;
}

.osdi-choice-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.osdi-choice-label {
    flex: 1;
    min-width: 120px;
    padding: 10px 12px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.osdi-choice-label:hover {
    border-color: var(--accent-blue);
    background: var(--bg-surface);
    transform: translateY(-1px);
}

.osdi-choice-label input[type="radio"] {
    display: none;
}

.osdi-choice-label:has(input[type="radio"]:checked) {
    background: var(--accent-blue);
    color: #ffffff;
    border-color: var(--accent-blue-hover);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Auto-anamnèse patient — Mode Applet Plein Écran */
.patient-anam-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    z-index: 9999;
    padding: 16px;
    box-sizing: border-box;
    overflow-y: auto;
}

.patient-anam-modal.active { display: flex !important; }

.patient-anam-card {
    width: 100%;
    max-width: 780px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    border-radius: 18px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    margin: auto;
}

.patient-anam-topbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.patient-anam-title { font-size: 20px; font-weight: 800; color: var(--accent-red); }
.patient-anam-progress { font-size: 13px; font-weight: 600; color: var(--text-muted); text-align: right; }
.patient-progress-track { height: 8px; background: var(--bg-surface-alt); border-radius: var(--radius-full); overflow: hidden; margin-bottom: 24px; }
.patient-progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-red), #be123c); border-radius: var(--radius-full); transition: width 0.3s ease; }

.patient-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    text-align: center;
}

.patient-screen-kicker { font-size: 13px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.patient-screen-question { font-size: 28px; line-height: 1.25; font-weight: 800; color: var(--text-main); margin: 0 auto; max-width: 680px; }
.patient-screen-help { font-size: 15px; color: var(--text-muted); line-height: 1.45; max-width: 560px; margin: 0 auto; }
.patient-answer-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }

.patient-big-choice {
    min-width: 160px;
    min-height: 64px;
    padding: 16px 24px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 20px;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.patient-big-choice:hover, .patient-big-choice.active {
    background: var(--accent-red);
    color: #ffffff;
    border-color: var(--accent-red);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(225, 29, 72, 0.3);
}

.patient-rating-row { display: none; justify-content: center; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.patient-rating-row.active { display: flex; }

.patient-star-choice {
    min-width: 80px;
    min-height: 60px;
    padding: 10px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-strong);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 22px;
    font-weight: 700;
}

.patient-star-choice:hover, .patient-star-choice.active {
    background: var(--accent-red);
    color: #ffffff;
    border-color: var(--accent-red);
    transform: translateY(-2px);
}

.patient-anam-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; justify-content: space-between; align-items: center; }
.patient-anam-actions-left, .patient-anam-actions-right { display: flex; gap: 10px; flex-wrap: wrap; }

.patient-summary-box { display: none; text-align: left; background: var(--bg-surface-alt); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 18px; max-height: 45vh; overflow: auto; font-size: 14px; line-height: 1.5; }
.patient-summary-box.active { display: block; }

/* Print Container Light Theme Enforcement for PDF Export */
#printContainer, #printContainer * {
    color: #0f172a !important;
    background-color: #ffffff !important;
}

#printContainer fieldset {
    border: 1px solid #94a3b8 !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
}

#printContainer legend {
    color: #1e40af !important;
    background-color: #ffffff !important;
}

#printContainer table {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

#printContainer th {
    background-color: #f1f5f9 !important;
    color: #1e3a8a !important;
    border: 1px solid #cbd5e1 !important;
}

#printContainer td {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
}

#printContainer tr:nth-child(even) td {
    background-color: #ffffff !important;
}

#printContainer td:first-child {
    background-color: #f8fafc !important;
}
