/* ===== Simulator-specific styles ===== */
/* Scoped to simulator pages only */

:root,
[data-theme="dark"] {
    --modal-overlay: rgba(0, 0, 0, 0.75);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b99b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    --chart-grid: rgba(42, 53, 72, 0.5);
}

[data-theme="light"] {
    --modal-overlay: rgba(0, 0, 0, 0.4);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234a5568' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    --chart-grid: rgba(0, 0, 0, 0.08);
}

.hidden {
    display: none !important;
}

/* ===== Lang button ===== */
.lang-btn {
    width: auto;
    padding: 0 10px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

/* ===== Simulator Modal ===== */
.sim-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.sim-modal.active {
    display: flex;
}

.sim-modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 28px 24px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    border: 1px solid var(--border-color);
    max-height: 85vh;
    overflow-y: auto;
}

.sim-modal-content h2 {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.sim-modal-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.sim-modal-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    color: var(--accent-yellow);
}

.sim-modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.sim-modal-actions .btn {
    flex: 1;
}

/* ===== Simulator Header ===== */
.sim-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    max-width: 600px;
    margin: 0 auto;
}

.sim-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sim-header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sim-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.running {
    background: var(--accent-green);
    animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.paused {
    background: var(--accent-yellow);
}

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

/* ===== Simulator Screens ===== */
.sim-screen {
    display: none;
    padding: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.sim-screen.active {
    display: block;
}

/* ===== Simulator Cards ===== */
.sim-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.sim-card:hover {
    transform: none;
}

.sim-card h2 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.sim-card h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ===== Forms ===== */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    flex: 1;
}

.form-group.full-width {
    flex: none;
    width: 100%;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

input[type="number"],
select {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

select {
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input:focus,
select:focus {
    border-color: var(--accent-blue);
}

.calculated-value {
    padding: 12px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

/* ===== Simulator Warnings ===== */
.sim-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.8rem;
    color: var(--accent-yellow);
    margin-top: 12px;
    line-height: 1.4;
}

/* ===== Simulator Buttons ===== */
.btn-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-accent {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.btn-info {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

/* ===== Metrics Grid ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}

.metric-card.primary {
    border-color: rgba(59, 130, 246, 0.4);
}

.metric-card.accent {
    border-color: rgba(6, 182, 212, 0.4);
}

.metric-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.metric-card.primary .metric-value {
    color: var(--accent-blue);
}

.metric-card.accent .metric-value {
    color: var(--accent-cyan);
}

.metric-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ===== Progress Section ===== */
.progress-section {
    margin-bottom: 12px;
}

.progress-bar {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-cyan));
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.elapsed-time {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    margin-top: 6px;
}

/* ===== Control Bar ===== */
.control-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 16px;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 12px;
}

.tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab.active {
    background: var(--bg-card);
    color: var(--text-primary);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ===== Chart ===== */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    height: 280px;
    position: relative;
}

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

/* ===== Data Table ===== */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: auto;
    max-height: 400px;
    -webkit-overflow-scrolling: touch;
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

#data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

#data-table th {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    padding: 10px 8px;
    text-align: right;
    white-space: nowrap;
}

#data-table th:first-child {
    text-align: left;
}

#data-table td {
    padding: 8px;
    border-top: 1px solid var(--border-color);
    text-align: right;
    color: var(--text-secondary);
}

#data-table td:first-child {
    text-align: left;
    color: var(--text-primary);
}

#data-table tbody tr:last-child {
    background: rgba(59, 130, 246, 0.05);
}

#data-table tbody tr.bolus-row {
    background: rgba(139, 92, 246, 0.1);
}

#data-table tbody tr.bolus-row td {
    color: var(--accent-purple);
    font-weight: 600;
}

#data-table tbody tr.target-row {
    background: rgba(245, 158, 11, 0.1);
}

#data-table tbody tr.target-row td {
    color: var(--accent-yellow);
    font-weight: 600;
}

/* ===== Event Log ===== */
.event-log {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.8rem;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 60px;
}

.log-message {
    color: var(--text-secondary);
}

.log-entry.start .log-message { color: var(--accent-green); }
.log-entry.stop .log-message { color: var(--accent-red); }
.log-entry.pause .log-message { color: var(--accent-yellow); }
.log-entry.target .log-message { color: var(--accent-cyan); }
.log-entry.bolus .log-message { color: var(--accent-purple); }
.log-entry.alarm .log-message { color: var(--accent-red); font-weight: 600; }

/* ===== Wake-up Card ===== */
.wake-up-card {
    margin-top: 12px;
}

.wake-up-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wake-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.wake-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--accent-green);
    margin-left: 8px;
}

/* ===== Induction preview ===== */
.induction-preview {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 0.75rem;
    margin-bottom: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.induction-preview .preview-item {
    text-align: center;
}

.induction-preview .preview-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent-blue);
}

.induction-preview .preview-label {
    font-size: 0.7rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* Download buttons row */
.download-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

/* Session Info */
.session-info-body {
    text-align: left;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
}

.info-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-row span:first-child {
    color: var(--text-muted);
}

.info-row span:last-child {
    font-weight: 500;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .sim-card {
        padding: 16px;
    }
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    .induction-preview {
        flex-direction: column;
        gap: 0.5rem;
    }
    .metric-label {
        font-size: 0.68rem;
    }
    .metric-value {
        font-size: 1.4rem;
    }
}

@media (max-width: 380px) {
    .metrics-grid {
        gap: 6px;
    }
    .metric-value {
        font-size: 1.3rem;
    }
    .control-bar {
        gap: 6px;
    }
}

@media (min-width: 768px) {
    .sim-screen {
        max-width: 700px;
    }
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .control-bar {
        grid-template-columns: repeat(4, 1fr);
    }
    .chart-container {
        height: 350px;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}
