/* Core Premium Design System Tokens */
:root {
    --bg-sidebar: #0b0f19;
    --bg-card: #111827;
    --bg-input: #1f2937;
    --border-dark: #374151;
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-success: #10b981;
    --accent-print: #f59e0b;
    --txt-white: #f9fafb;
    --txt-muted: #9ca3af;
    
    --bg-paper: #ffffff;
    --txt-paper: #111827;
    --border-paper: #cbd5e1;
    
    --font-sans: 'Inter', 'Noto Sans KR', sans-serif;
    --shadow-premium: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font-sans);
    color: var(--txt-paper);
    background-color: #0f172a;
    height: 100vh;
    overflow: hidden;
}

/* Layout Grid */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 340px;
    background-color: var(--bg-sidebar);
    color: var(--txt-white);
    padding: 2rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border-right: 1px solid var(--border-dark);
    box-shadow: var(--shadow-premium);
    z-index: 10;
    overflow-y: auto;
}

.brand {
    border-bottom: 1px solid var(--border-dark);
    padding-bottom: 1.25rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.brand-logo i {
    color: var(--accent-primary);
}

.premium-badge {
    font-size: 0.7rem;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.25rem;
    vertical-align: middle;
    letter-spacing: 0;
}

.brand-tagline {
    font-size: 0.8rem;
    color: var(--txt-muted);
    margin-top: 0.25rem;
}

/* Progress bar styling */
.progress-bar-container {
    width: 100%;
    background-color: #111827;
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    height: 20px;
    position: relative;
    overflow: hidden;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-bar-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-success));
    transition: width 0.3s ease;
}

#local-ai-progress-text {
    position: relative;
    z-index: 2;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
}

/* API Setup Panel */
.api-setup-panel {
    background-color: var(--bg-card);
    border: 1px solid var(--border-dark);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
}

.api-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
    background-color: var(--bg-input);
    color: var(--txt-white);
    font-size: 0.85rem;
    outline: none;
}

.api-help-text {
    font-size: 0.75rem;
    color: var(--txt-muted);
    line-height: 1.4;
}

.api-help-text a {
    color: var(--accent-primary);
    text-decoration: none;
}

/* Configuration Form */
.generator-config {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--txt-muted);
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background-color: var(--bg-input);
    padding: 2px;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--txt-muted);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.segmented-control input[type="radio"]:checked + label {
    background-color: var(--accent-primary);
    color: white;
}

.form-control,
.form-control-textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
    background-color: var(--bg-input);
    color: var(--txt-white);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
}

.form-control-textarea {
    resize: none;
}

/* Checkbox Style */
.checkbox-container {
    display: flex;
    align-items: center;
    position: relative;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0.5rem;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    height: 18px;
    width: 18px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-dark);
    border-radius: 4px;
    margin-right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.checkmark::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    color: white;
    font-size: 10px;
    display: none;
}

.checkbox-container input:checked ~ .checkmark::after {
    display: block;
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--accent-primary);
}

.checkbox-label {
    font-size: 0.85rem;
    color: var(--txt-white);
}

/* Stepper Custom */
.number-stepper {
    display: flex;
    background-color: var(--bg-input);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    overflow: hidden;
}

.step-btn {
    background: none;
    border: none;
    color: var(--txt-white);
    padding: 0.5rem 1rem;
    font-size: 1.1rem;
    cursor: pointer;
}

.step-btn:hover {
    background-color: var(--border-dark);
}

.number-stepper input {
    flex: 1;
    border: none;
    background: none;
    color: white;
    text-align: center;
    font-size: 0.95rem;
    outline: none;
}

/* Buttons */
.btn {
    width: 100%;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #1d4ed8);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-secondary {
    background-color: var(--bg-input);
    color: var(--txt-white);
    border: 1px solid var(--border-dark);
}

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

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

.btn-accent:hover {
    background-color: #d97706;
}

/* Actions toolbar */
.toolbar-section {
    border-top: 1px solid var(--border-dark);
    padding-top: 1.25rem;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--txt-muted);
    margin-bottom: 0.75rem;
    text-transform: uppercase;
}

.actions-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--txt-muted);
    text-align: center;
    border-top: 1px solid var(--border-dark);
    padding-top: 1rem;
}

.service-policy {
    text-decoration: underline;
    cursor: pointer;
    margin-top: 0.25rem;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: #1f2937;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.5);
    z-index: 1000;
    transition: opacity 0.3s;
    border-left: 4px solid var(--accent-primary);
}

/* Preview / Exam Sheets Styles */
.preview-area {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    background-color: #0f172a;
}

.exam-paper {
    background-color: var(--bg-paper);
    width: 210mm;
    min-height: 297mm;
    padding: 15mm 15mm;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    border: 1px solid #cbd5e1;
    display: flex;
    flex-direction: column;
    position: relative;
    box-sizing: border-box;
}

/* Paper Header Styling (Real Textbook Style from Reference image) */
.paper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #000;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.exam-title-box {
    display: flex;
    flex-direction: column;
}

.exam-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #000;
    letter-spacing: -0.02em;
}

.exam-subtitle {
    font-size: 0.8rem;
    color: #475569;
}

.student-info-box {
    display: flex;
    gap: 1rem;
    border: 1.2px solid #000;
    padding: 0.25rem 0.75rem;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.info-field {
    font-size: 0.8rem;
    font-weight: 800;
}

.info-line-text {
    font-size: 0.8rem;
    font-weight: 500;
}

.info-line {
    display: inline-block;
    width: 60px;
    border-bottom: 1px solid #000;
    height: 1rem;
}

/* 2-Column Grid Layout matching the textbook image */
.problems-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 20mm;
    row-gap: 8mm;
    position: relative;
    flex: 1;
}

/* Vertical separating line in the middle */
.problems-grid::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    background-color: #94a3b8;
    transform: translateX(-50%);
}

.problem-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-bottom: 0.5rem;
    break-inside: avoid;
    word-wrap: break-word;
    overflow-wrap: break-word;
    min-width: 0;
}

.problem-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.problem-num {
    font-weight: 800;
    font-size: 1.2rem;
    color: #000;
    line-height: 1;
}

.problem-type-tag {
    font-size: 0.7rem;
    color: #64748b;
    border: 1px solid #e2e8f0;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    margin-top: 0.1rem;
}

.problem-text {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #000;
    word-break: keep-all;
    white-space: normal;
    text-align: justify;
}

/* Diagram Styling */
.problem-diagram {
    margin: 0.25rem 0;
    display: flex;
    justify-content: center;
}

.problem-workspace {
    flex: 1;
    min-height: 40px;
}

/* Multiple choice layout */
.multiple-choice-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    row-gap: 0.25rem;
    column-gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.8rem;
}

.multiple-choice-option {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.option-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: 1px solid #000;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: bold;
}

.solution-box {
    margin-top: auto;
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #0f172a;
}

.solution-box.hidden {
    display: none;
}

/* Placeholder */
.placeholder-msg {
    grid-column: span 2;
    text-align: center;
    padding: 6rem 2rem;
    color: #64748b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.placeholder-art {
    font-size: 4rem;
    color: var(--accent-primary);
    animation: pulse 2s infinite;
}

.sample-key-notice {
    font-size: 0.8rem;
    background-color: #e0f2fe;
    color: #0369a1;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.hidden {
    display: none !important;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.8; }
}

/* Print Layout overrides */
@media print {
    .no-print {
        display: none !important;
    }
    body {
        background-color: white;
        overflow: visible;
        height: auto;
    }
    .app-layout {
        display: block;
        width: 100%;
        height: auto;
    }
    .preview-area {
        padding: 0;
        overflow: visible;
        background: white;
    }
    .exam-paper {
        border: none;
        box-shadow: none;
        width: 100%;
        min-height: 0;
        padding: 0;
    }
    .problems-grid::after {
        background-color: #000;
    }
}
