/* Simulation Page Styles */
:root {
    --sim-bg: #808080;
    /* Neutral Gray Background for Simulation Area */
    /* --sim-bg: #f1f5f9;  */
    --sim-card-bg: #ffffff;
    --sim-border: #e2e8f0;
    --sim-primary: #6366f1;
    --sim-text: #1e293b;
    --sim-text-muted: #64748b;
}

@import 'simulation-table.css';

body {
    background-color: var(--bg-secondary, #f8fafc);
    margin: 0;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Layout Overrides for Simulation Page Structure */
/* Layout Overrides for Simulation Page Structure */
/* Note: body is flex column */

/* Sidebar specific correction for Sim page -> Not used but keeping for safety if sidebar added */
.sidebar {
    width: 240px;
    height: 100%;
    border-right: 1px solid var(--border-color);
    background: #fff;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 10;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    height: auto;
}

/* Redefine main-container for simulation page specifically if used directly */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    /* Webkit bug fix for nested scrolling */
}

/* Header adjustment */
.app-container .header {
    position: relative;
    /* Not sticky here */
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.sim-container {
    display: flex;
    gap: 24px;
    padding: 24px;
    flex: 1;
    overflow: hidden;
    height: 100%;
    /* Fill available space */
    min-height: 0;
    /* Enable nested scrolling */
}

/* Left Panel: Configuration */
.sim-config-panel {
    width: 400px;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-right: 8px;
    /* Scrollbar space */
}

/* Right Panel: Dashboard */
.sim-dashboard {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Card Styles */
.sim-card {
    background: var(--sim-card-bg);
    border: 1px solid var(--sim-border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sim-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.sim-card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--sim-text);
    margin: 0;
}

/* Form Elements */
.sim-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    position: relative;
}

.sim-form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sim-text-muted);
}

.sim-form-group input,
.sim-form-group select {
    padding: 10px 12px;
    padding-right: 30px;
    /* Space for unit */
    border: 1px solid var(--sim-border);
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
    width: 100%;
    /* Ensure full width */
    box-sizing: border-box;
}

.sim-form-group input:focus,
.sim-form-group select:focus {
    outline: none;
    border-color: var(--sim-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.sim-form-group .unit {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    /* Center vertically */
    margin-top: 12px;
    /* Offset for label */
    font-size: 0.85rem;
    color: var(--sim-text-muted);
    pointer-events: none;
}

.sim-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Tooltips */
.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    margin-left: 4px;
    cursor: help;
    transition: background 0.2s;
}

.tooltip-icon:hover {
    background: var(--primary);
}

.custom-tooltip {
    position: fixed;
    background: #1e293b;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 250px;
    line-height: 1.4;
    display: none;
}

/* Stats Grid */
.sim-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.sim-stat-card {
    background: var(--sim-card-bg);
    border: 1px solid var(--sim-border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.sim-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--sim-primary);
    opacity: 0.5;
}

.sim-stat-card .label {
    font-size: 0.8rem;
    color: var(--sim-text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.sim-stat-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--sim-text);
}

.sim-stat-card .sub {
    font-size: 0.8rem;
    color: #10b981;
    /* Green */
    margin-top: 4px;
}

/* Charts */
.sim-chart-card {
    background: var(--sim-card-bg);
    border: 1px solid var(--sim-border);
    border-radius: 12px;
    padding: 20px;
    flex: 1;
    /* Expand to fill space */
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

.sim-chart-card h3 {
    font-size: 0.95rem;
    margin: 0 0 16px 0;
    color: var(--sim-text);
}

.chart-container {
    flex: 1;
    position: relative;
    width: 100%;
}

/* Rounds List */
.sim-round-item {
    background: var(--bg-secondary, #f8fafc);
    border: 1px solid var(--sim-border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    position: relative;
    animation: slideDown 0.3s ease;
}

.sim-round-item h4 {
    font-size: 0.85rem;
    margin: 0 0 8px 0;
    color: var(--sim-text);
    display: flex;
    justify-content: space-between;
}

.sim-round-remove {
    cursor: pointer;
    color: #ef4444;
    font-size: 0.8rem;
    background: none;
    border: none;
}

.sim-btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #c7d2fe;
    cursor: pointer;
}

.sim-btn-sm:hover {
    background: #e0e7ff;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* === 반응형: 중간 폭에서 세로 배치 === */
@media (max-width: 992px) {
    .sim-container {
        flex-direction: column;
        padding: 20px;
        gap: 20px;
        overflow-y: auto;
    }

    .sim-config-panel {
        width: 100%;
        min-width: 0;
        max-height: none;
    }

    .sim-dashboard {
        width: 100%;
        min-height: 280px;
    }
}

@media (max-width: 768px) {
    .sim-container {
        padding: 16px;
        gap: 16px;
    }

    .sim-card {
        padding: 16px;
    }

    .sim-card-header h3 {
        font-size: 0.95rem;
    }

    body .header {
        padding: 0 16px;
        height: auto;
        min-height: 56px;
    }
}

@media (max-width: 480px) {
    .sim-container {
        padding: 12px;
        gap: 12px;
    }

    .sim-card {
        padding: 12px 14px;
    }

    .sim-card-header {
        margin-bottom: 12px;
    }

    .sim-card-header h3 {
        font-size: 0.9rem;
    }

    .sim-row {
        grid-template-columns: 1fr;
    }

    .sim-form-group input,
    .sim-form-group select {
        padding: 10px 12px;
        font-size: 0.875rem;
    }

    body .header {
        padding: 0 12px;
    }
}

/* Dark Mode Overrides */
body.dark-mode {
    --sim-card-bg: #1e293b;
    --sim-border: #334155;
    --sim-text: #f8fafc;
    --sim-text-muted: #94a3b8;
    background-color: #0f172a;
}