/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #6b7280;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --border: #e5e7eb;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --border-color: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #3b82f6;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-yellow: #fbbf24;
    --accent-cyan: #06b6d4;
    --transition: all 0.3s ease;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    color: var(--text-primary);
    overflow: hidden;
}

/* ===== MODAL STYLES ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 32px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

.modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.beaker-icon, .failure-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.modal-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-dark);
}

.modal-header p {
    color: var(--text-light);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}

.safety-alert {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.warning-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.safety-alert p {
    margin: 0;
    font-size: 14px;
    color: #78350f;
}

.alert-title {
    font-weight: 700;
    margin-bottom: 4px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-secondary:hover {
    background: #4b5563;
}

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

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9em;
}

.btn-danger-small:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dark);
}

.btn-outline:hover {
    background: var(--bg-light);
}

/* ===== APP LAYOUT ===== */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

.container.hidden {
    display: none;
}

/* ===== HEADER ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(30, 41, 59, 0.8);
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    backdrop-filter: blur(8px);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon {
    font-size: 32px;
}

.app-title {
    font-size: 24px;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.app-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ===== MAIN LAYOUT ===== */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 24px;
    overflow-y: auto;
    flex-shrink: 0;
}

.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.experiment-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.experiment-btn {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.experiment-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

.experiment-btn.active {
    background: rgba(59, 130, 246, 0.25);
    border-color: var(--accent-blue);
    color: white;
}

.name {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
}

.desc {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== WORKSPACE ===== */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-align: center;
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
}

.placeholder-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.placeholder-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.workspace-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.workspace-content.hidden {
    display: none;
}

/* ===== INFO HEADER ===== */
.info-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.header-glow {
    position: absolute;
    top: -32px;
    right: -32px;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    opacity: 0.15;
    pointer-events: none;
    transition: 1s ease;
}

.header-glow.exo {
    background: var(--accent-red);
}

.header-glow.endo {
    background: var(--accent-blue);
}

.reaction-name {
    font-size: 28px;
    font-weight: 700;
    color: white;
    margin-bottom: 8px;
}

.reaction-description {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
}

.equation-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: #aaddff;
    margin-bottom: 16px;
    overflow-x: auto;
}

.header-info {
    display: flex;
    gap: 24px;
    align-items: center;
}

.reaction-type-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reaction-type-badge {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.reaction-type-badge.exo {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.reaction-type-badge.endo {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
}

.enthalpy-display {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===== MAIN GRID ===== */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1400px) {
    .main-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 1000px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}


/* ===== SCENE CONTAINER ===== */
.scene-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

.canvas-3d {
    width: 100%;
    height: 400px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: block;
}

.scene-label {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(15, 23, 42, 0.8);
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
    pointer-events: none;
}

.label-title {
    color: white;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
}

.label-subtitle {
    color: var(--text-secondary);
    font-size: 11px;
}

.progress-container {
    position: relative;
}

.progress-bar-wrapper {
    width: 100%;
    height: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
    transition: width 0.3s ease-out;
    width: 0%;
}

.progress-bar.exo {
    background: linear-gradient(90deg, #f97316 0%, var(--accent-red) 100%);
}

.progress-bar.endo {
    background: linear-gradient(90deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
}

/* ===== CONTROL PANEL ===== */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.parameter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.parameter-label {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--text-secondary);
}

.temp-display {
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    transition: var(--transition);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-blue);
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.6);
}

.slider:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== CATALYST & WARNING ===== */
.catalyst-container {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-green);
}

.checkbox-label {
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.checkbox:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.warning-box {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
    color: #fcd34d;
}

/* ===== CONTROL BUTTONS ===== */
.control-buttons {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.btn-icon {
    font-size: 16px;
}

.complete-message {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-green);
    animation: pulse 2s infinite;
}

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

/* ===== THERMOMETER WIDGET ===== */
.thermometer-widget {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.therm-icon {
    font-size: 32px;
    margin-bottom: 8px;
    transition: 1s ease;
}

.therm-icon.hot {
    font-size: 40px;
    filter: drop-shadow(0 0 8px #ef4444);
}

.therm-icon.cold {
    font-size: 40px;
    filter: drop-shadow(0 0 8px #3b82f6);
}

.widget-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.temp-value {
    font-size: 48px;
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: white;
    line-height: 1;
}

.unit {
    font-size: 20px;
    color: var(--text-secondary);
    margin-left: 4px;
}

.temp-trend {
    margin-top: 12px;
    font-size: 14px;
    font-weight: 700;
}

.temp-trend.heating {
    color: #fca5a5;
}

.temp-trend.cooling {
    color: #93c5fd;
}

/* ===== ENERGY PROFILE ===== */
.energy-profile {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.diagram-title {
    font-size: 16px;
    font-weight: 700;
    color: white;
    margin-bottom: 16px;
    text-align: center;
}

.canvas-energy {
    width: 100%;
    height: 300px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
}

.diagram-description {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.info-header {
    animation: fadeIn 0.3s ease-out;
}

.main-grid > * {
    animation: slideIn 0.4s ease-out;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 16px;
    }
    
    .workspace {
        padding: 16px;
    }
    
    .reaction-name {
        font-size: 20px;
    }
    
    .equation-box {
        font-size: 14px;
    }
    
    .main-grid {
        grid-template-columns: 1fr;
    }
}
