/* Nanum Square Neo Font */
@import url('https://cdn.rawgit.com/moonspam/NanumSquare/master/nanumsquare.css');

/* CSS Variables for Theming */
:root {
    /* Light Theme (Default) */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f7fafc;
    --text-primary: #1a202c;
    --text-secondary: #718096;
    --text-tertiary: #a0aec0;
    --border-color: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-hover: rgba(0, 0, 0, 0.1);
    --gradient-start: #5e72e4;
    --gradient-end: #825ee4;
}

body.dark-theme {
    /* Dark Theme */
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --bg-tertiary: #374151;
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --text-tertiary: #a0aec0;
    --border-color: #4a5568;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.4);
    --gradient-start: #4c5fd5;
    --gradient-end: #6b4fd5;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'NanumSquare', 'Nanum Square', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header - Professional Financial Style */
.header {
    background: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-end) 100%);
    color: white;
    padding: 32px 0;
    box-shadow: 0 2px 8px var(--shadow);
    transition: background 0.3s ease;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.75em;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

.header-meta span {
    display: block;
    margin: 0;
    opacity: 0.95;
}

.period-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Month Dropdown Styles */
.month-dropdown {
    position: relative;
    display: inline-block;
}

.month-dropdown-toggle {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 600;
    font-family: 'NanumSquare', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
    transition: all 0.2s;
}

.month-dropdown-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.month-dropdown-toggle.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.dropdown-arrow {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 0.8em;
}

.month-dropdown-toggle.active .dropdown-arrow {
    transform: rotate(180deg);
}

.month-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 140px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.month-dropdown-menu.show {
    max-height: 300px;
    opacity: 1;
    overflow-y: auto;
}

.month-option {
    padding: 10px 16px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'NanumSquare', sans-serif;
}

.month-option:hover:not(:disabled) {
    background: var(--bg-tertiary);
}

.month-option.active {
    background: var(--bg-tertiary);
    color: var(--gradient-start);
    font-weight: 700;
}

.month-option:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    color: var(--text-tertiary);
}

.month-option:first-child {
    border-radius: 6px 6px 0 0;
}

.month-option:last-child {
    border-radius: 0 0 6px 6px;
}

.update-time {
    font-size: 0.9em;
    opacity: 0.85;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-start);
    color: white;
    border: none;
    box-shadow: 0 4px 12px var(--shadow-hover);
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1000;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px var(--shadow-hover);
}

/* Navigation - Clean Professional */
.nav {
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px var(--shadow);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.3s ease;
}

.nav .container {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 12px 20px;
    flex-wrap: wrap;
}

.nav-link {
    padding: 8px 20px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.95em;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--gradient-start);
}

/* Main */
.main {
    padding: 40px 0;
}

.section {
    margin-bottom: 48px;
}

.section-title {
    font-size: 1.75em;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    transition: color 0.3s ease;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 1.05em;
    transition: color 0.3s ease;
}

/* KPI Cards - Professional Style */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.kpi-card {
    background: var(--bg-secondary);
    padding: 28px;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.3s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.kpi-icon {
    font-size: 2.5em;
    margin-bottom: 12px;
}

.kpi-value {
    font-size: 2.2em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
    font-family: 'NanumSquare', system-ui, sans-serif;
    transition: color 0.3s ease;
}

.kpi-label {
    color: var(--text-secondary);
    font-size: 0.95em;
    font-weight: 500;
    transition: color 0.3s ease;
}

.kpi-danger {
    border-left: 3px solid #f56565;
}

.kpi-success {
    border-left: 3px solid #48bb78;
}

/* Card - Professional Style */
.card {
    background: var(--bg-secondary);
    padding: 28px;
    border-radius: 8px;
    box-shadow: 0 1px 3px var(--shadow);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    transition: all 0.3s;
}

.card-title {
    font-size: 1.35em;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.card-danger {
    border-left: 3px solid #f56565;
}

.card-warning {
    border-left: 3px solid #ed8936;
}

.card-success {
    border-left: 3px solid #48bb78;
}

.alert-card {
    background: var(--bg-tertiary);
    border-left: 3px solid #f56565;
}

/* Grid */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 24px;
}

/* Risk Level Badges - Professional */
.risk-level-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    margin: 24px 0;
    padding: 20px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.risk-level-item {
    text-align: center;
    padding: 16px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 2px solid var(--border-color);
    transition: all 0.2s;
}

.risk-level-item:hover {
    border-color: #5e72e4;
    transform: translateY(-2px);
}

/* Grade Detail Grid */
.grade-detail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.grade-item {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid #48bb78;
    transition: all 0.2s;
}

.grade-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.grade-item-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.grade-item-value {
    font-size: 2em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.grade-item-pct {
    font-size: 0.95em;
    color: var(--text-secondary);
}

.risk-level-label {
    font-size: 0.85em;
    color: #718096;
    margin-bottom: 8px;
    font-weight: 600;
}

.risk-level-count {
    font-size: 1.8em;
    font-weight: 700;
    color: #1a202c;
}

.risk-level-low {
    border-color: #48bb78;
}

.risk-level-medium {
    border-color: #4299e1;
}

.risk-level-high {
    border-color: #ed8936;
}

.risk-level-veryhigh {
    border-color: #f56565;
}

.risk-level-critical {
    border-color: #c53030;
    background: #fff5f5;
}

/* Table - Professional Data Table */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.data-table thead {
    background: var(--bg-tertiary);
    transition: background-color 0.3s ease;
}

.data-table th {
    padding: 14px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.data-table td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.data-table tr:hover {
    background: var(--bg-tertiary);
}

.company-link {
    color: #5e72e4;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.company-link:hover {
    color: #434190;
    text-decoration: underline;
}

/* Risk Level Badges in Table */
.risk-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.85em;
}

.risk-low {
    background: #c6f6d5;
    color: #22543d;
}

.risk-medium {
    background: #bee3f8;
    color: #2c5282;
}

.risk-high {
    background: #feebc8;
    color: #7c2d12;
}

.risk-veryhigh {
    background: #fed7d7;
    color: #742a2a;
}

.risk-critical {
    background: #fc8181;
    color: white;
}

/* Company Change Item (Section 7) */
.company-change-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.company-change-item:hover {
    background: var(--border-color);
}

.company-change-item .company-name {
    color: var(--text-primary);
}

.company-change-item .score-change {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 0.95em;
}

.company-change-item .score {
    color: var(--text-secondary);
}

.company-change-item .arrow {
    color: var(--text-tertiary);
}

.company-change-item .change-up {
    color: #ef4444;
    font-weight: 700;
}

.company-change-item .change-down {
    color: #48bb78;
    font-weight: 700;
}

/* Action Companies (Section 8) */
.action-company-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.action-company-item:last-child {
    border-bottom: none;
}

.action-company-item .company-name {
    color: var(--text-primary);
}

.action-company-item .score-danger {
    color: #ef4444;
    font-weight: 700;
}

.action-company-item .score-warning {
    color: #ed8936;
    font-weight: 700;
    font-weight: 700;
}

/* Issue List - Professional */
.issue-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.issue-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f7fafc;
    border-radius: 6px;
    border-left: 3px solid #5e72e4;
    transition: all 0.2s;
}

.issue-item:hover {
    background: #edf2f7;
    transform: translateX(4px);
}

.issue-name {
    font-weight: 600;
    color: #1a202c;
    font-size: 1.05em;
}

.issue-code {
    font-size: 0.85em;
    color: #718096;
    margin-left: 8px;
}

.issue-count {
    background: #5e72e4;
    color: white;
    padding: 6px 16px;
    border-radius: 16px;
    font-weight: 700;
    font-size: 1.05em;
}

/* Modal for Company News */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--bg-secondary);
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px var(--shadow-hover), 0 10px 10px -5px var(--shadow);
    animation: slideIn 0.3s;
    transition: background-color 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 24px 28px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.modal-title {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.modal-close {
    font-size: 2em;
    font-weight: 300;
    color: #718096;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #edf2f7;
    color: #1a202c;
}

.modal-body {
    padding: 24px 28px;
    max-height: calc(80vh - 100px);
    overflow-y: auto;
}

.news-item {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s;
}

.news-item:last-child {
    border-bottom: none;
}

.news-item:hover {
    background: var(--bg-tertiary);
}

.news-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.news-date {
    font-size: 0.9em;
    color: #718096;
    font-weight: 500;
}

.news-issue {
    padding: 4px 12px;
    background: #edf2f7;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    color: #2d3748;
}

.news-title {
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.news-title a {
    color: inherit;
    text-decoration: none;
}

.news-title a:hover {
    color: #5e72e4;
}

.news-media {
    font-size: 0.9em;
    color: #718096;
}

.severity-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
    margin-left: 8px;
}

.severity-1, .severity-2 {
    background: #c6f6d5;
    color: #22543d;
}

.severity-3 {
    background: #feebc8;
    color: #7c2d12;
}

.severity-4, .severity-5 {
    background: #fed7d7;
    color: #742a2a;
}

/* Footer - Professional */
.footer {
    background: #2d3748;
    color: white;
    padding: 40px 0;
    margin-top: 60px;
}

.footer-content {
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.footer-text {
    color: #a0aec0;
    line-height: 1.8;
    font-size: 0.95em;
}

.footer-info-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.footer-info-links a {
    color: #a0aec0;
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.3s ease;
}

.footer-info-links a:hover {
    color: #ffffff;
    text-decoration: underline;
}

/* Buttons - Professional */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95em;
}

.btn-primary {
    background: #5e72e4;
    color: white;
}

.btn-primary:hover {
    background: #434190;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(94, 114, 228, 0.4);
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover {
    background: #4a5568;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .header-meta {
        text-align: center;
        margin-top: 12px;
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .nav .container {
        gap: 4px;
    }

    .nav-link {
        padding: 6px 14px;
        font-size: 0.9em;
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* Chart Container */
canvas {
    max-height: 380px;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #718096;
}

.loading::after {
    content: "데이터를 불러오는 중...";
    font-size: 1.1em;
}

/* No Data */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
    font-style: italic;
}
