/* ==================== */
/*   전역 스타일        */
/* ==================== */

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

:root {
    --primary-color: #4285f4;
    --primary-hover: #357ae8;
    --danger-color: #ea4335;
    --warning-color: #fbbc04;
    --success-color: #34a853;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: #dfe1e5;
    --background: #ffffff;
    --card-background: #ffffff;
    --input-background: #f1f3f4;
    --shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
    --shadow-hover: 0 2px 8px rgba(32, 33, 36, 0.35);
}

body.dark-mode {
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --border-color: #3c4043;
    --background: #202124;
    --card-background: #292a2d;
    --input-background: #303134;
    --shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.7);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    color: var(--text-primary);
    background: var(--background);
    line-height: 1.6;
    overflow-x: hidden;
}

.hidden {
    display: none !important;
}

/* ==================== */
/*   초기 화면          */
/* ==================== */

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.container.initial {
    justify-content: center;
    padding-top: 15vh;
}

.logo-section {
    text-align: center;
    margin-bottom: 40px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 56px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo-text {
    font-size: 48px;
    font-weight: 300;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ==================== */
/*   검색 섹션          */
/* ==================== */

.search-section {
    width: 100%;
    max-width: 750px;
}

/* Mode Selector */
.mode-selector {
    margin-bottom: 32px;
    animation: fadeInUp 0.5s ease;
}

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

.mode-tabs {
    display: flex;
    gap: 0;
    background: var(--card-background);
    border-radius: 20px;
    padding: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
}

.mode-tabs::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(50% - 6px);
    height: calc(100% - 12px);
    background: linear-gradient(135deg, var(--primary-color) 0%, #5a9aff 100%);
    border-radius: 16px;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 0;
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.mode-tabs.student-active::before {
    transform: translateX(calc(100% + 6px));
}

.mode-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 24px;
    background: transparent;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    font-family: inherit;
    position: relative;
    z-index: 1;
    color: var(--text-secondary);
}

.mode-tab:hover:not(.active) {
    transform: translateY(-2px);
}

.mode-tab.active {
    color: white;
}

.mode-icon {
    font-size: 36px;
    display: block;
    transition: transform 0.3s ease;
}

.mode-tab:hover .mode-icon {
    transform: scale(1.1);
}

.mode-tab.active .mode-icon {
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.mode-label {
    font-size: 16px;
    font-weight: 700;
    display: block;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.mode-tab.active .mode-label {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.mode-desc {
    font-size: 12px;
    opacity: 0.7;
    display: block;
    text-align: center;
    line-height: 1.3;
    transition: opacity 0.3s ease;
    font-weight: 400;
}

.mode-tab.active .mode-desc {
    opacity: 0.95;
}

.mode-tab:not(.active) .mode-desc {
    opacity: 0.6;
}

/* Ripple effect on click */
.mode-tab {
    overflow: hidden;
}

.mode-tab::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.mode-tab:active::after {
    width: 300px;
    height: 300px;
}

/* Glow effect for active tab */
.mode-tab.active {
    position: relative;
}

.mode-tab.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, var(--primary-color), #5a9aff);
    border-radius: 18px;
    opacity: 0;
    z-index: -1;
    filter: blur(8px);
    animation: glow 2s ease-in-out infinite;
}

@keyframes glow {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.6;
    }
}

.search-box {
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 24px;
    transition: box-shadow 0.3s ease;
}

.info-hint {
    margin-top: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #f1f3f4;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.search-box:hover {
    box-shadow: var(--shadow-hover);
}

#query-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    line-height: 1.5;
    color: var(--text-primary);
    min-height: 80px;
    transition: opacity 0.3s ease;
}

#query-input::placeholder {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.search-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

.btn-primary, .btn-secondary {
    padding: 12px 28px;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.btn-secondary {
    background: #f8f9fa;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #f1f3f4;
    border-color: #c4c7c9;
}

.btn-icon {
    font-size: 16px;
}

/* ==================== */
/*   상세 정보 패널      */
/* ==================== */

.advanced-panel {
    margin-top: 24px;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    animation: slideDown 0.3s ease;
}

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

.advanced-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group.full-width {
    grid-column: 1 / -1;
}

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

.input-group input,
.input-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ==================== */
/*   이미지 업로드 패널  */
/* ==================== */

.image-panel {
    margin-top: 24px;
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    animation: slideDown 0.3s ease;
}

.image-upload-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.image-help-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.image-upload-area:hover {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

.image-upload-area.drag-over {
    border-color: var(--primary-color);
    background: #e8f0fe;
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-icon {
    font-size: 48px;
}

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

.image-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.image-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    aspect-ratio: 1;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s;
}

.image-remove-btn:hover {
    background: var(--danger-color);
}

.btn-image-mode {
    margin-top: 16px;
    padding: 12px 28px;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    justify-content: center;
    background: #34a853;
    color: white;
}

.btn-image-mode:hover {
    background: #2d8e47;
    box-shadow: 0 2px 8px rgba(52, 168, 83, 0.3);
}

/* ==================== */
/*   면책 조항          */
/* ==================== */

.disclaimer {
    margin-top: 40px;
    padding: 16px 24px;
    background: #fef7e0;
    border-left: 4px solid var(--warning-color);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 650px;
    text-align: center;
}

/* ==================== */
/*   로딩 화면          */
/* ==================== */

.container.loading {
    justify-content: center;
}

.loading-content {
    text-align: center;
    max-width: 400px;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 24px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-content h2 {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 12px;
}

.loading-stage {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.loading-bar {
    width: 100%;
    height: 4px;
    background: #e8eaed;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 12px;
}

.loading-progress {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    transition: width 0.3s ease;
    animation: progressAnimation 30s ease-out forwards;
}

@keyframes progressAnimation {
    0% { width: 0%; }
    50% { width: 60%; }
    100% { width: 95%; }
}

.loading-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ==================== */
/*   결과 화면          */
/* ==================== */

.container.result {
    padding: 0;
    align-items: stretch;
}

.top-search-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 24px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.logo-icon-small {
    font-size: 28px;
}

.logo-text-small {
    font-size: 20px;
    font-weight: 400;
    color: var(--text-primary);
}

.top-search-box {
    flex: 1;
    max-width: 600px;
}

.top-search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    background: #f8f9fa;
}

.top-search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
}

.btn-new-search {
    padding: 10px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-new-search:hover {
    background: var(--primary-hover);
}

.result-content {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ==================== */
/*   상태 배너          */
/* ==================== */

.status-banner {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.status-banner.high-confidence {
    background: #e6f4ea;
    color: var(--success-color);
    border-left: 4px solid var(--success-color);
}

.status-banner.uncertain {
    background: #fef7e0;
    color: #ea8600;
    border-left: 4px solid var(--warning-color);
}

.status-banner.emergency {
    background: #fce8e6;
    color: var(--danger-color);
    border-left: 4px solid var(--danger-color);
}

.status-icon {
    font-size: 20px;
}

/* ==================== */
/*   안전 경고          */
/* ==================== */

.safety-warnings {
    background: #fce8e6;
    border: 2px solid var(--danger-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.warning-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.warning-icon {
    font-size: 24px;
}

.warning-header h3 {
    font-size: 18px;
    color: var(--danger-color);
    font-weight: 600;
}

#warning-list {
    list-style: none;
    padding-left: 36px;
}

#warning-list li {
    margin-bottom: 8px;
    color: var(--text-primary);
    position: relative;
}

#warning-list li::before {
    content: "•";
    position: absolute;
    left: -16px;
    color: var(--danger-color);
    font-weight: bold;
}

/* ==================== */
/*   진단 결과          */
/* ==================== */

.diagnosis-section h2 {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.diagnosis-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.diagnosis-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: box-shadow 0.2s;
}

.diagnosis-card:hover {
    box-shadow: var(--shadow);
}

.diagnosis-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.diagnosis-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.diagnosis-score {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e8f0fe;
    padding: 6px 12px;
    border-radius: 16px;
}

.score-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
}

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

.diagnosis-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* ==================== */
/*   상세 정보 카드      */
/* ==================== */

.details-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 32px 0;
}

.detail-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.detail-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.risk-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.risk-badge.low {
    background: #e6f4ea;
    color: var(--success-color);
}

.risk-badge.medium {
    background: #fef7e0;
    color: #ea8600;
}

.risk-badge.high {
    background: #fce8e6;
    color: var(--danger-color);
}

.confidence-bar {
    width: 100%;
    height: 8px;
    background: #e8eaed;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    border-radius: 4px;
    transition: width 0.5s ease;
}

#confidence-text {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.duration-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==================== */
/*   AI 모델 분석       */
/* ==================== */

.models-section {
    margin-top: 32px;
}

.models-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.model-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.model-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

/* ==================== */
/*   오류 화면          */
/* ==================== */

.container.error {
    justify-content: center;
}

.error-content {
    text-align: center;
    max-width: 500px;
}

.error-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.error-content h2 {
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 12px;
}

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

.suggestions-container {
    margin-top: 24px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: left;
}

.suggestions-container h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.suggestions-list {
    list-style: none;
    padding-left: 0;
}

.suggestions-list li {
    padding: 10px 16px;
    background: white;
    border-left: 3px solid var(--primary-color);
    margin-bottom: 8px;
    border-radius: 4px;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
}

.error-content .btn-primary,
.error-content .btn-secondary {
    margin: 8px;
}

/* ==================== */
/*   반응형 디자인      */
/* ==================== */

@media (max-width: 768px) {
    .logo-text {
        font-size: 36px;
    }

    .logo-icon {
        font-size: 42px;
    }

    .search-box {
        padding: 20px;
    }

    .search-actions {
        flex-direction: column;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        justify-content: center;
    }

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

    .top-search-bar {
        flex-wrap: wrap;
    }

    .top-search-box {
        order: 3;
        width: 100%;
        max-width: 100%;
        margin-top: 12px;
    }

    .details-section {
        grid-template-columns: 1fr;
    }

    .models-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==================== */
/*   Enhanced Output (v2.1.0) */
/* ==================== */

.section-note {
    font-size: 14px;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
}

.evidence-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.evidence-badge.strong {
    background: #d4edda;
    color: #155724;
}

.evidence-badge.moderate {
    background: #fff3cd;
    color: #856404;
}

.evidence-badge.weak {
    background: #f8d7da;
    color: #721c24;
}

.sources-compact {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
    padding-left: 20px;
}

.sources-compact li {
    margin-bottom: 4px;
}

.type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: #e9ecef;
    color: #495057;
}

.type-badge.guideline {
    background: #d1ecf1;
    color: #0c5460;
}

.type-badge.RCT, .type-badge.rct {
    background: #d4edda;
    color: #155724;
}

.type-badge.meta-analysis, .type-badge.meta_analysis {
    background: #cce5ff;
    color: #004085;
}

.type-badge.systematic_review, .type-badge.systematic-review {
    background: #d1ecf1;
    color: #0c5460;
}

.type-badge.textbook {
    background: #f8d7da;
    color: #721c24;
}

.evidence-table {
    margin-top: 16px;
    overflow-x: auto;
}

.evidence-table table {
    width: 100%;
    font-size: 14px;
}

.evidence-table th {
    font-weight: 600;
    color: var(--text-primary);
}

.evidence-table td {
    color: var(--text-secondary);
}

.evidence-table a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 18px;
}

.evidence-table a:hover {
    text-decoration: underline;
}

.disclaimer-card {
    background: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 20px;
    color: #856404;
}

.disclaimer-card strong {
    display: block;
    font-size: 16px;
    margin-bottom: 8px;
    color: #721c24;
}

.disclaimer-card p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
}

.diagnosis-card ul {
    margin: 8px 0;
    padding-left: 20px;
}

.diagnosis-card ul li {
    margin-bottom: 4px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.diagnosis-description strong {
    color: var(--text-primary);
    display: inline-block;
    margin-top: 8px;
}

.model-status {
    font-size: 16px;
    margin-right: 8px;
}

.model-status.success {
    color: #34a853;
}

.model-status.failed {
    color: #ea4335;
}

.model-status.fallback {
    color: #fbbc04;
}

/* ==================== */
/*   Authentication UI   */
/* ==================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

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

.auth-form h2 {
    margin-bottom: 24px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

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

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 13px;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

.forgot-password-link {
    text-align: right;
    margin-top: -8px;
    margin-bottom: 16px;
}

.forgot-password-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
}

.forgot-password-link a:hover {
    text-decoration: underline;
}

.form-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-status {
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
}

.auth-status-text {
    color: var(--success-color);
    margin-right: 8px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--primary-hover);
}

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

.btn-icon-only {
    padding: 8px 12px;
    min-width: auto;
}

/* ==================== */
/*   History List       */
/* ==================== */

.history-list {
    max-height: 60vh;
    overflow-y: auto;
}

.history-item {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.history-query {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    margin-right: 12px;
}

.history-date {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

.history-details {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.history-diagnosis {
    color: var(--text-secondary);
    font-size: 14px;
}

.history-actions {
    display: flex;
    gap: 8px;
}

.btn-view-history,
.btn-delete-history {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

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

.btn-view-history:hover {
    background: var(--primary-hover);
}

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

.btn-delete-history:hover {
    background: #d93025;
}

.loading-text,
.error-text,
.empty-text {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.error-text {
    color: var(--danger-color);
}

/* ==================== */
/*   애니메이션         */
/* ==================== */

.fade-in {
    animation: fadeIn 0.4s ease;
}

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


/* ==================== */
/*   Navigation Menu    */
/* ==================== */

.menu-toggle-btn {
    position: fixed;
    top: 20px;
    left: 24px;
    z-index: 1002;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: var(--shadow);
    color: var(--text-primary);
    transition: all 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto;
    touch-action: manipulation;
}

.menu-toggle-btn:hover {
    background: var(--input-background);
    transform: scale(1.05);
}

.menu-toggle-btn:active {
    transform: scale(0.95);
}

.menu-toggle-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* 메뉴가 열릴 때 토글 버튼 숨기기 */
body.menu-open .menu-toggle-btn {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.menu-icon-hamburger {
    display: block;
    font-size: 24px;
    line-height: 1;
    font-weight: 400;
    user-select: none;
    -webkit-user-select: none;
}

.side-menu {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: var(--card-background);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    z-index: 999;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    pointer-events: none;
}

.side-menu.open {
    left: 0;
    pointer-events: auto;
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.menu-overlay.open {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.side-menu-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.side-menu-header h2 {
    font-size: 20px;
    color: var(--text-primary);
    font-weight: 500;
}

.menu-close-btn {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-secondary);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
}

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

.menu-close-btn:active {
    transform: scale(0.9);
}

.side-menu-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.2s;
    margin-bottom: 4px;
}

.menu-item:hover {
    background: var(--input-background);
}

.menu-icon {
    font-size: 20px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

/* Dark Mode Toggle Switch */
.dark-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Dark Mode Overrides for specific elements */
body.dark-mode .search-box,
body.dark-mode .diagnosis-card,
body.dark-mode .detail-card,
body.dark-mode .model-card,
body.dark-mode .advanced-panel,
body.dark-mode .image-panel,
body.dark-mode .modal-content,
body.dark-mode .top-search-bar {
    background: var(--card-background);
    border-color: var(--border-color);
}

body.dark-mode .input-group input,
body.dark-mode .input-group select,
body.dark-mode .top-search-box input {
    background: var(--input-background);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.dark-mode #query-input {
    background: transparent;
    color: var(--text-primary);
}

body.dark-mode .info-hint {
    background: #303134;
    color: var(--text-secondary);
}

body.dark-mode .section-note {
    background: #303134;
}

body.dark-mode .btn-secondary {
    background: var(--input-background);
    color: var(--text-primary);
    border-color: var(--border-color);
}

body.dark-mode .btn-secondary:hover {
    background: #3c4043;
}

body.dark-mode .evidence-table th {
    color: var(--text-primary);
}

body.dark-mode .history-item {
    background: var(--input-background);
    border-color: var(--border-color);
}

body.dark-mode .suggestions-container {
    background: var(--input-background);
}

body.dark-mode .image-upload-area {
    background: var(--input-background);
    border-color: var(--border-color);
}

body.dark-mode .mode-tabs {
    background: var(--card-background);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.dark-mode .mode-tabs::before {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5a9aff 100%);
    box-shadow: 0 2px 8px rgba(66, 133, 244, 0.5);
}

body.dark-mode .mode-tab {
    color: var(--text-secondary);
}

body.dark-mode .mode-tab.active {
    color: white;
}

/* Responsive Mode Selector */
@media (max-width: 600px) {
    .mode-tabs {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    
    .mode-tabs::before {
        display: none;
    }
    
    .mode-tab {
        padding: 16px 20px;
        border-radius: 12px;
        background: var(--input-background);
    }
    
    .mode-tab.active {
        background: linear-gradient(135deg, var(--primary-color) 0%, #5a9aff 100%);
        box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
    }
    
    .mode-icon {
        font-size: 28px;
    }
    
    .mode-label {
        font-size: 15px;
    }
    
    .mode-desc {
        font-size: 11px;
    }
}

/* ==================== */
/*   Student Mode       */
/* ==================== */

.student-section {
    position: relative;
}

.student-guidance {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
}

.student-guidance * {
    color: white !important;
}

.student-question {
    background: rgba(255, 255, 255, 0.15);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.guidance-text {
    font-size: 15px;
    line-height: 1.6;
}

.diff-table-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.diff-card {
    border-left: 4px solid var(--primary-color);
}

.likelihood-high {
    background: #4caf50 !important;
    color: white !important;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
}

.likelihood-moderate {
    background: #ff9800 !important;
    color: white !important;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
}

.likelihood-low {
    background: #9e9e9e !important;
    color: white !important;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
}

.feature-list {
    margin: 8px 0;
    padding-left: 24px;
}

.feature-list li {
    margin: 4px 0;
}

.reasoning-steps {
    margin: 8px 0;
    padding-left: 24px;
}

.reasoning-steps li {
    margin: 8px 0;
    line-height: 1.6;
}

.learning-points {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white !important;
}

.learning-points * {
    color: white !important;
}

.highlight-list {
    list-style: none;
    padding: 0;
}

.highlight-list li {
    padding: 12px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 15px;
}

/* MCQ Cards */
.mcq-card {
    position: relative;
    border-left: 4px solid #2196f3;
}

.mcq-difficulty {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.difficulty-easy {
    background: #4caf50;
    color: white;
}

.difficulty-medium {
    background: #ff9800;
    color: white;
}

.difficulty-hard {
    background: #f44336;
    color: white;
}

.mcq-question {
    font-size: 16px;
    margin-bottom: 16px;
    padding-right: 80px;
}

.mcq-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.mcq-option {
    padding: 12px 16px;
    background: var(--input-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
}

.mcq-option:hover {
    background: var(--card-background);
    border-color: var(--primary-color);
}

.mcq-option.selected {
    font-weight: 600;
}

.mcq-option.correct {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
}

.mcq-option.incorrect {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.mcq-explanation {
    padding: 12px;
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 4px;
    margin-top: 12px;
}

.mcq-explanation strong {
    color: #2196f3;
}

.osce-questions {
    padding-left: 24px;
}

.osce-questions li {
    margin: 12px 0;
    line-height: 1.6;
}

.edu-value-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

.edu-value-badge.high {
    background: #4caf50;
    color: white;
}

.edu-value-badge.medium {
    background: #ff9800;
    color: white;
}

.edu-value-badge.low {
    background: #9e9e9e;
    color: white;
}

/* Dark Mode Student Styles */
body.dark-mode .student-guidance {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.dark-mode .learning-points {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

body.dark-mode .mcq-option {
    background: #303134;
    border-color: #3c4043;
}

body.dark-mode .mcq-option:hover {
    background: #3c4043;
    border-color: var(--primary-color);
}

body.dark-mode .mcq-explanation {
    background: #303134;
    border-color: #2196f3;
}
