@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;700&display=swap');

:root {
    --main-color: #F58220;
    --secondary-color: #043B72;
    --background-color: #f4f7f9;
    --card-background: #ffffff;
    --text-color: #333;
    --light-text-color: #777;
    --border-color: #e0e0e0;
}

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

html, body {
    height: 100%;
    overflow: hidden; /* Prevent scroll on the body */
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px; /* Add padding to the body */
}

.app-container {
    width: 95vw; /* Almost full width */
    height: 95vh; /* Almost full height */
    max-width: 1800px; /* Max width */
    max-height: 1000px; /* Max height */
    background-color: var(--card-background);
    border-radius: 20px; /* Restore border-radius */
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12); /* Restore box-shadow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* --- Start Screen --- */
.card {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    opacity: 1;
    transition: opacity 0.6s ease-out;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--card-background);
    padding: 20px;
}
.card.hidden {
    opacity: 0;
    pointer-events: none;
}
.card-content {
    text-align: center;
    max-width: 550px;
}
.main-logo {
    max-width: 150px;
    margin: 0 auto 20px auto;
}
.card-content h1 {
    color: var(--secondary-color);
    font-size: 32px;
    margin-bottom: 15px;
}
.card-content > p {
    color: var(--light-text-color);
    font-size: 18px;
    line-height: 1.6;
}
.start-footer {
    padding-top: 30px;
}
#start-button {
    padding: 20px 30px; /* Increased padding */
    width: 100%;
    max-width: 300px;
    font-size: 20px; /* Increased font size */
}

/* --- Main Layout --- */
.main-view {
    display: flex;
    flex-grow: 1;
    height: 100%;
    overflow: hidden; /* Ensure inner containers control scroll */
}
.main-view.hidden { display: none; }

.dashboard-container {
    flex: 2; /* 40% width */
    background-color: #f7f9fc;
    padding: 40px 4vw 25px; /* Increased top padding */
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}
.form-container {
    flex: 3; /* 60% width */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Form container itself should not scroll */
}
.form-wrapper {
    padding: 40px 5vw 20px; /* Increased top padding */
    flex-grow: 1;
    overflow-y: auto; /* The wrapper is what scrolls */
}

/* --- Dashboard --- */
.dashboard-header {
    text-align: center;
    margin-bottom: 20px;
}
.dashboard-header h2 {
    font-size: 24px;
    color: var(--secondary-color);
}
.comment {
    font-size: 15px;
    color: var(--secondary-color);
    background-color: #e6f3ff;
    padding: 15px;
    border-radius: 8px;
    line-height: 1.6;
    margin-bottom: 20px;
}
.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.summary-item {
    background-color: #fff;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-color);
}
.summary-label {
    display: block;
    font-size: 13px;
    color: var(--light-text-color);
    margin-bottom: 4px; /* Reduced spacing */
}
.summary-value {
    display: block;
    font-size: 18px;
    font-weight: bold;
    color: var(--secondary-color);
}
.summary-item.shortfall .summary-value { color: var(--main-color); }
.graph-placeholder {
    height: 300px; /* Fix the height of the chart container */
    margin-bottom: 20px;
    position: relative; /* Ensure canvas positions correctly inside */
}

.graph-placeholder canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
}
.proposals-container {
    display: flex;
    gap: 15px;
    justify-content: space-between;
}
.proposal-card {
    background-color: #fff;
    padding: 15px;
    border-radius: 8px;
    flex: 1;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--main-color);
}
.proposal-card h4 { color: var(--secondary-color); margin-bottom: 8px; font-size: 16px; }
.proposal-card p { font-size: 14px; margin-bottom: 5px; }
.proposal-card strong { color: var(--main-color); }
.proposal-description { font-size: 12px; color: var(--light-text-color); }
.dashboard-placeholder { text-align: center; padding: 40px 10px; color: var(--light-text-color); }
.dashboard-placeholder h3 { color: var(--secondary-color); margin-bottom: 10px; font-size: 22px; }

/* --- Form --- */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px; /* Reduced margin */
    padding: 0 5px;
}
.form-header h2 {
    margin: 0;
    font-size: 24px;
    color: var(--secondary-color);
}
.form-header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}
.evaluation-date {
    font-size: 13px;
    color: var(--light-text-color);
    white-space: nowrap;
}
.form-header-buttons {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.form-grid-3-col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px; /* Reduced gap */
}
.form-column fieldset {
    border: 1px solid var(--border-color);
    padding: 10px; /* Reduced padding */
    border-radius: 8px;
    margin-bottom: 15px; /* Reduced margin */
}
.form-column fieldset:last-child { margin-bottom: 0; }
.form-column legend {
    font-weight: bold;
    color: var(--secondary-color);
    padding: 0 6px; /* Reduced padding */
    margin-left: 5px;
    font-size: 15px; /* Reduced font size */
}
.form-group { margin-bottom: 10px; /* Reduced margin */ }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--secondary-color);
    font-size: 14px;
}
.form-group input[type="date"],
.form-group input[type="number"],
.form-group input[type="text"][data-is-currency="true"] {
    width: 100%;
    padding: 10px 12px; /* Reduced padding */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit; /* Ensure font consistency */
    transition: border-color 0.3s, box-shadow 0.3s;
}

/* --- Sliders --- */
.slider-group label {
    display: block;
    margin-bottom: 8px; /* Reduced margin */
}
.slider-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px; /* Reduced gap */
}
.slider-wrapper output {
    font-weight: bold;
    color: var(--secondary-color);
    min-width: 50px;
    text-align: right;
}
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--border-color);
    border-radius: 5px;
    outline: none;
    opacity: 0.7;
    transition: opacity .2s;
}
input[type="range"]:hover {
    opacity: 1;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--main-color);
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--main-color);
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

.input-wrapper { position: relative; display: flex; align-items: center; }
.input-wrapper input[type="number"] { padding-right: 30px; }
.input-suffix { color: var(--light-text-color); font-size: 14px; }
.toggle-buttons { display: flex; border: 1px solid var(--main-color); border-radius: 8px; overflow: hidden; }
.toggle-buttons button { flex: 1; padding: 10px; /* Reduced padding */ border: none; background-color: white; color: var(--main-color); font-size: 14px; /* Reduced font size */ cursor: pointer; transition: background-color 0.3s, color 0.3s; }
.toggle-buttons button:not(:last-child) { border-right: 1px solid var(--main-color); }
.toggle-buttons button.active { background-color: var(--main-color); color: white; }

/* --- Buttons --- */
#reset-button, #submit-button, #start-button, #generate-report-button {
    width: auto;
    padding: 10px 20px; /* Reduced padding */
    border-radius: 8px;
    font-size: 14px; /* Reduced font size */
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    border: none;
}
#reset-button {
    background-color: transparent;
    color: var(--secondary-color);
    border: 1px solid var(--secondary-color);
}
#submit-button, #start-button { background-color: var(--main-color); color: white; }
#generate-report-button { background-color: var(--secondary-color); color: white; }
.hidden { display: none !important; }

/* --- Loading --- */
.dashboard-container {
    position: relative; /* Needed for absolute positioning of the overlay */
}
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(247, 249, 252, 0.7); /* Use dashboard background color with transparency */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    border-radius: 8px; /* Match container's border radius if any */
}
.loading-overlay.visible {
    opacity: 1;
    visibility: visible;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--main-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* --- Report Modal --- */
.report-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.report-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.report-container {
    background-color: var(--card-background);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background-color: var(--secondary-color);
    color: white;
}

.report-header h1 {
    font-size: 22px;
    margin: 0;
}

.report-header-buttons {
    display: flex;
    gap: 10px;
}

.report-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.report-btn:hover {
    transform: translateY(-1px);
}

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

.report-btn.close-btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.report-btn.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.report-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.report-section {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
}

.report-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.report-section h2 {
    font-size: 18px;
    color: var(--secondary-color);
    margin-bottom: 15px;
    padding-left: 12px;
    border-left: 4px solid var(--main-color);
}

/* Report Info Grid */
.report-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.report-info-item {
    background-color: #f7f9fc;
    padding: 12px 15px;
    border-radius: 8px;
}

.report-info-label {
    font-size: 12px;
    color: var(--light-text-color);
    margin-bottom: 4px;
}

.report-info-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--secondary-color);
}

/* Report Summary Grid */
.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.report-summary-item {
    background-color: #f7f9fc;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.report-summary-item.highlight {
    background-color: #fff3e6;
    border: 1px solid var(--main-color);
}

.report-summary-item.shortfall {
    background-color: #ffebee;
    border: 1px solid #e57373;
}

.report-summary-label {
    font-size: 13px;
    color: var(--light-text-color);
    margin-bottom: 6px;
}

.report-summary-value {
    font-size: 18px;
    font-weight: bold;
    color: var(--secondary-color);
}

.report-summary-item.shortfall .report-summary-value {
    color: #d32f2f;
}

.report-summary-item.highlight .report-summary-value {
    color: var(--main-color);
}

/* Report Graph */
.report-graph-container {
    height: 280px;
    position: relative;
    background-color: #f7f9fc;
    border-radius: 8px;
    padding: 15px;
}

.report-graph-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Expert Analysis Content */
.report-expert-content {
    background-color: #f7f9fc;
    padding: 20px;
    border-radius: 8px;
    line-height: 1.8;
    font-size: 14px;
    color: var(--text-color);
}

/* Markdown content styling */
.report-expert-content p,
.persona-advice p {
    margin: 0 0 10px 0;
}

.report-expert-content p:last-child,
.persona-advice p:last-child {
    margin-bottom: 0;
}

.report-expert-content ul,
.report-expert-content ol,
.persona-advice ul,
.persona-advice ol {
    margin: 8px 0;
    padding-left: 20px;
}

.report-expert-content li,
.persona-advice li {
    margin-bottom: 4px;
}

.report-expert-content strong,
.persona-advice strong {
    color: var(--secondary-color);
}

.report-expert-content h1,
.report-expert-content h2,
.report-expert-content h3 {
    color: var(--secondary-color);
    margin: 12px 0 8px 0;
    font-size: 15px;
}

.report-expert-content .loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 40px;
}

.loading-placeholder p {
    color: var(--light-text-color);
    font-size: 14px;
}

/* Streaming cursor animation */
.streaming-cursor {
    display: inline;
    animation: blink 1s step-end infinite;
    color: var(--main-color);
    font-weight: normal;
}

/* Print Styles */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html, body {
        height: auto !important;
        overflow: visible !important;
        padding: 0;
        margin: 0;
        background-color: white;
    }

    .app-container,
    .card,
    .main-view {
        display: none !important;
    }

    .report-modal {
        position: static !important;
        display: block !important;
        background-color: white !important;
        padding: 0 !important;
        height: auto !important;
        overflow: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .report-modal.hidden {
        display: block !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    .report-container {
        position: static !important;
        width: 100% !important;
        max-width: 100% !important;
        max-height: none !important;
        height: auto !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    .report-header {
        background-color: var(--secondary-color) !important;
    }

    .report-header-buttons {
        display: none !important;
    }

    .report-body {
        overflow: visible !important;
        height: auto !important;
        padding: 20px !important;
    }

    .report-section {
        break-inside: avoid;
        page-break-inside: avoid;
        margin-bottom: 20px;
    }

    .report-graph-container {
        height: 250px !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .report-expert-content {
        break-inside: avoid;
        page-break-inside: avoid;
        overflow: visible !important;
        height: auto !important;
    }

    .streaming-cursor {
        display: none !important;
    }

    .loading-placeholder {
        display: none !important;
    }
}