/* ═══════════════════════════════════════════════════════════════
   SuperAlloy Analyzer - Professional Light Theme
   동아대학교 스타일: 흰색 바탕 + 파란색/검정색
   재료공학 전문가를 위한 클린 디자인
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    /* Core palette — white background + Dong-A blue + black */
    --bg-primary: #f7f8fc;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f4ff;
    --bg-glass: #f3f5fa;
    --bg-glass-hover: #e8ecf7;

    /* Accent: Dong-A Blue system */
    --primary: #1a4b8c;
    --primary-light: #2563b0;
    --primary-lighter: #e8f0fe;
    --primary-dark: #0e2f5a;
    --accent-primary: #1a4b8c;
    --accent-secondary: #2563b0;
    --accent-tertiary: #3b82f6;
    --accent-success: #0d9f6e;
    --accent-warning: #d97706;
    --accent-error: #dc2626;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #1a4b8c 0%, #2563b0 60%, #3b82f6 100%);
    --gradient-card: linear-gradient(135deg, rgba(26, 75, 140, 0.04) 0%, rgba(37, 99, 176, 0.02) 100%);
    --gradient-sidebar: linear-gradient(180deg, #0e2f5a 0%, #1a4b8c 100%);

    /* Text */
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #8896a8;

    /* Borders */
    --border-color: #e2e8f0;
    --border-dark: #cbd5e1;
    --border-hover: rgba(26, 75, 140, 0.35);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);
    --shadow-glow: 0 0 30px rgba(26, 75, 140, 0.08);

    /* Layout */
    --sidebar-width: 256px;
    --topbar-height: 60px;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Sidebar (remains dark for contrast) ── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--gradient-sidebar);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 17px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.logo-subtitle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
    letter-spacing: 0.5px;
}

.nav-group {
    padding: 16px 12px 8px;
}

.nav-group-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.35);
    padding: 0 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: #ffffff;
    border-radius: 2px;
}

.nav-icon {
    font-size: 17px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.dev-info {
    text-align: center;
    margin-bottom: 12px;
}

.dev-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.3);
    margin-bottom: 5px;
}

.dev-orgs {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.6;
}

.dev-dot {
    color: rgba(255, 255, 255, 0.25);
    margin: 0 2px;
}

.alloy-badge {
    text-align: center;
    padding: 6px 16px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ffffff;
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    position: relative;
}

.top-bar {
    height: var(--topbar-height);
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    color: var(--primary-dark);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.llm-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-error);
    transition: background 0.3s;
}

.status-dot.connected {
    background: var(--accent-success);
    box-shadow: 0 0 6px rgba(13, 159, 110, 0.4);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.content-wrapper {
    padding: 28px 32px;
}

/* ── Flash Messages ── */
.flash-messages {
    padding: 16px 32px 0;
}

.flash-msg {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

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

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.flash-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
}

.flash-warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.flash-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.flash-close:hover {
    opacity: 1;
}

/* ── Cards ── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
}

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

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

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ── Stat Cards ── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: all 0.25s ease;
    box-shadow: var(--shadow-sm);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 34px;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 13px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all 0.2s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 75, 140, 0.12);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%234a5568'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(26, 75, 140, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(26, 75, 140, 0.35);
}

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

.btn-secondary:hover {
    background: var(--bg-glass);
    border-color: var(--border-hover);
}

.btn-success {
    background: linear-gradient(135deg, #0d9f6e, #059669);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 13px 34px;
    font-size: 15px;
}

/* ── Upload Zone ── */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 44px 32px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-glass);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-lighter);
}

.upload-zone.dragover {
    transform: scale(1.01);
}

.upload-icon {
    font-size: 44px;
    margin-bottom: 14px;
    display: block;
}

.upload-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

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

.file-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

/* ── Tables ── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: 11px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    background: var(--bg-glass);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.data-table tr:hover td {
    background: var(--primary-lighter);
    color: var(--text-primary);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-gp {
    background: var(--primary-lighter);
    color: var(--primary);
    border: 1px solid rgba(26, 75, 140, 0.2);
}

.badge-gb {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* ── Image Viewer ── */
.image-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.image-box {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
}

.image-box img {
    width: 100%;
    height: auto;
    display: block;
}

.image-box-label {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 12px;
    background: rgba(26, 75, 140, 0.85);
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    color: white;
}

/* ── Result Panels ── */
.result-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

.result-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.metric-item {
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary);
    margin-bottom: 2px;
}

.metric-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── LLM Interpretation ── */
.llm-panel {
    background: var(--primary-lighter);
    border: 1px solid rgba(26, 75, 140, 0.15);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 20px;
}

.llm-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.llm-panel-content {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

/* ── Plot Container ── */
.plot-container {
    text-align: center;
    margin: 20px 0;
}

.plot-container img {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.plot-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ── Section Headers ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Loading ── */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 24px auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(247, 248, 252, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

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

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination a {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.pagination a:hover {
    background: var(--primary-lighter);
    border-color: var(--border-hover);
    color: var(--primary);
}

.pagination .current {
    background: var(--primary);
    color: white;
    border: none;
}

/* ── Tabs ── */
.tabs {
    display: flex;
    gap: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    margin-bottom: 0;
}

.tab {
    flex: 1;
    padding: 11px 20px;
    background: transparent;
    border: none;
    border-right: 1px solid var(--border-color);
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab:last-child {
    border-right: none;
}

.tab:hover {
    color: var(--primary);
    background: var(--primary-lighter);
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 14px;
    opacity: 0.4;
}

.empty-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-text {
    font-size: 14px;
    max-width: 420px;
    margin: 0 auto 18px;
    line-height: 1.6;
}

/* ── Progress Bar ── */
.progress-bar {
    width: 100%;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

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

    .image-compare {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content-wrapper {
        padding: 16px;
    }

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

    .form-row {
        grid-template-columns: 1fr;
    }

    .result-metrics {
        grid-template-columns: 1fr;
    }
}