/* ============================
   DESIGN SYSTEM
   ============================ */
:root {
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-card-hover: #1e2642;
    --bg-input: #0f172a;
    --bg-input-focus: #131c33;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #60a5fa;

    --accent-blue: #3b82f6;
    --accent-blue-light: #60a5fa;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f97316;
    --accent-amber: #f59e0b;

    --gradient-blue: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-cyan: linear-gradient(135deg, #06b6d4, #3b82f6);
    --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-warning: linear-gradient(135deg, #f59e0b, #f97316);
    --gradient-danger: linear-gradient(135deg, #ef4444, #f97316);

    --border-color: rgba(148, 163, 184, 0.1);
    --border-focus: rgba(59, 130, 246, 0.5);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow-blue: 0 0 20px rgba(59,130,246,0.15);
    --shadow-glow-green: 0 0 20px rgba(16,185,129,0.15);
    --shadow-glow-red: 0 0 20px rgba(239,68,68,0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 20% 20%, rgba(59,130,246,0.06) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 80%, rgba(139,92,246,0.05) 0%, transparent 60%),
        radial-gradient(ellipse 50% 50% at 50% 0%, rgba(6,182,212,0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.app-container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* ============================
   HEADER
   ============================ */
.app-header {
    margin-bottom: 32px;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 28px 32px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.header-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-blue);
}

.header-icon svg {
    width: 52px;
    height: 52px;
    animation: spin-slow 20s linear infinite;
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.header-text h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--gradient-blue);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
    margin-top: 4px;
}

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

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

/* ============================
   PANELS
   ============================ */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.01);
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-icon {
    font-size: 1.2rem;
}

.panel-body {
    padding: 24px;
}

/* Input Panel */
.input-panel {
    position: sticky;
    top: 24px;
}

@media (max-width: 1024px) {
    .input-panel {
        position: static;
    }
}

/* ============================
   PARAMETER GROUPS
   ============================ */
.param-group {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.param-group:last-of-type {
    border-bottom: none;
    margin-bottom: 16px;
}

.param-group-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-blue { background: var(--accent-blue); }
.dot-purple { background: var(--accent-purple); }
.dot-cyan { background: var(--accent-cyan); }

/* ============================
   INPUTS
   ============================ */
.input-row {
    margin-bottom: 14px;
}

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

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 10px 14px;
    padding-right: 50px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    outline: none;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    border-color: var(--border-focus);
    background: var(--bg-input-focus);
    box-shadow: var(--shadow-glow-blue);
}

.input-wrapper .unit {
    position: absolute;
    right: 14px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
    font-family: 'JetBrains Mono', monospace;
}

.select-wrapper select {
    padding-right: 14px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    appearance: auto;
}

.help-text {
    display: block;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

.material-info, .contact-info {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(59,130,246,0.06);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.contact-info {
    background: rgba(245,158,11,0.08);
}

.info-icon {
    flex-shrink: 0;
    font-size: 0.9rem;
}

/* ============================
   CALCULATE BUTTON
   ============================ */
.calc-button {
    width: 100%;
    padding: 14px 24px;
    background: var(--gradient-blue);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(59,130,246,0.3);
    margin-top: 8px;
    position: relative;
    overflow: hidden;
}

.calc-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: var(--transition);
}

.calc-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(59,130,246,0.4);
}

.calc-button:hover::before {
    opacity: 1;
}

.calc-button:active {
    transform: translateY(0);
}

.calc-icon {
    font-size: 1.2rem;
}

/* ============================
   STATUS BANNER
   ============================ */
.status-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    transition: var(--transition);
}

.status-banner.success {
    background: rgba(16,185,129,0.08);
    border-color: rgba(16,185,129,0.2);
    box-shadow: var(--shadow-glow-green);
}

.status-banner.warning {
    background: rgba(245,158,11,0.08);
    border-color: rgba(245,158,11,0.2);
}

.status-banner.danger {
    background: rgba(239,68,68,0.08);
    border-color: rgba(239,68,68,0.2);
    box-shadow: var(--shadow-glow-red);
}

.status-banner.marginal {
    background: rgba(249,115,22,0.08);
    border-color: rgba(249,115,22,0.2);
}

.status-icon {
    font-size: 2rem;
    flex-shrink: 0;
    animation: pulse-icon 2s ease-in-out infinite;
}

@keyframes pulse-icon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.status-text strong {
    font-size: 1rem;
    font-weight: 700;
}

.status-text span {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* ============================
   METRICS GRID
   ============================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 28px;
}

.metric-card {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition);
}

.metric-card:hover {
    border-color: rgba(59,130,246,0.2);
    transform: translateY(-1px);
}

.metric-card.highlight-card {
    background: rgba(59,130,246,0.06);
    border-color: rgba(59,130,246,0.15);
}

.metric-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    line-height: 1.2;
}

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

/* ============================
   CHART SECTION
   ============================ */
.section-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-section, .detail-section, .visual-section, .thermo-section, .recommendations-section, .timing-section {
    margin-bottom: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.chart-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    height: 320px;
    position: relative;
}

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

/* ============================
   DETAIL TABLE
   ============================ */
.detail-table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.detail-table thead th {
    background: rgba(59,130,246,0.08);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.detail-table tbody td {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(148,163,184,0.05);
    color: var(--text-primary);
}

.detail-table tbody tr:hover {
    background: rgba(59,130,246,0.03);
}

.detail-table tbody tr:last-child td {
    border-bottom: none;
}

.detail-table .row-highlight td {
    background: rgba(59,130,246,0.06);
    font-weight: 600;
}

.detail-table .row-warn td {
    background: rgba(245,158,11,0.06);
}

.detail-table .row-danger td {
    background: rgba(239,68,68,0.06);
}

.detail-table .row-success td {
    background: rgba(16,185,129,0.06);
}

/* ============================
   VISUAL CANVAS
   ============================ */
.visual-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    justify-content: center;
}

.visual-container canvas {
    max-width: 100%;
}

.visual-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 12px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    display: inline-block;
}

/* ============================
   THERMOMETER
   ============================ */
.thermometer-container {
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.thermometer {
    position: relative;
    height: 80px;
}

.thermo-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 16px;
    background: linear-gradient(90deg, #1e40af, #3b82f6, #60a5fa, #93c5fd, #fbbf24, #f97316);
    border-radius: 8px;
    overflow: hidden;
}

.thermo-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(16,185,129,0.4);
    border-radius: 8px;
    transition: all 0.6s ease;
}

.thermo-zone-ok {
    position: absolute;
    top: -2px;
    bottom: -2px;
    border: 2px solid var(--accent-green);
    border-radius: 10px;
    background: rgba(16,185,129,0.1);
    transition: all 0.6s ease;
}

.thermo-scale {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 24px;
}

.thermo-marker {
    position: absolute;
    bottom: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    z-index: 2;
}

.thermo-marker::after {
    content: '';
    width: 2px;
    height: 12px;
    background: var(--text-secondary);
    border-radius: 1px;
}

.thermo-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.thermo-temp {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.thermo-marker.thermo-needed .thermo-temp { color: var(--accent-amber); }
.thermo-marker.thermo-needed::after { background: var(--accent-amber); }

.thermo-marker.thermo-achieved .thermo-temp { color: var(--accent-cyan); }
.thermo-marker.thermo-achieved::after { background: var(--accent-cyan); }

.thermo-marker.thermo-source .thermo-temp { color: var(--accent-blue); }
.thermo-marker.thermo-source::after { background: var(--accent-blue); }

.thermo-labels {
    position: absolute;
    bottom: -24px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

/* ============================
   RECOMMENDATIONS
   ============================ */
.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rec-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    transition: var(--transition);
}

.rec-item:hover {
    background: var(--bg-card-hover);
}

.rec-item.rec-success {
    border-left: 3px solid var(--accent-green);
}

.rec-item.rec-warning {
    border-left: 3px solid var(--accent-amber);
}

.rec-item.rec-danger {
    border-left: 3px solid var(--accent-red);
}

.rec-item.rec-info {
    border-left: 3px solid var(--accent-blue);
}

.rec-icon {
    flex-shrink: 0;
    font-size: 1.1rem;
}

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

.rec-text strong {
    color: var(--text-primary);
}

/* ============================
   TIMING CARD
   ============================ */
.timing-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.timing-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.timing-value {
    font-size: 1.5rem;
    font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-blue-light);
}

.timing-note {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============================
   FOOTER
   ============================ */
.app-footer {
    margin-top: 32px;
    padding: 20px 24px;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.app-footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

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

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

::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.15);
    border-radius: 3px;
}

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

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

.animate-in {
    animation: fadeInUp 0.4s ease-out;
}

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }

    .header-content {
        padding: 20px;
    }

    .header-text h1 {
        font-size: 1.3rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .visual-legend {
        flex-direction: column;
        align-items: center;
    }

    .thermometer-container {
        padding: 16px 10px;
    }
}
