/* ==========================================================================
   Thermodynamic Calculator Design System & Theme Stylesheet
   ========================================================================== */

/* Design Tokens & Theme Variables */
:root {
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Dark Theme Variables (Default) */
    --bg-main: #0f172a;
    --bg-panel: #1e293b;
    --bg-input: #0f172a;
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-start: #38bdf8;
    --accent-end: #2563eb;
    --accent-glow: rgba(56, 189, 248, 0.15);
    
    --card-bg: #1e293b;
    --card-border: rgba(255, 255, 255, 0.05);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    
    --btn-primary-bg: linear-gradient(135deg, #38bdf8 0%, #2563eb 100%);
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: #334155;
    --btn-secondary-text: #cbd5e1;
    
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    
    --sidebar-width: 380px;
    --header-height: 70px;
    --border-radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables (High Contrast, Pure White BG) */
body.light-theme {
    --bg-main: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-input: #ffffff;
    --border-color: #cbd5e1;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --accent-start: #0284c7;
    --accent-end: #1d4ed8;
    --accent-glow: rgba(29, 78, 216, 0.12);
    
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.08);
    
    --btn-primary-bg: linear-gradient(135deg, #0284c7 0%, #1d4ed8 100%);
    --btn-primary-text: #ffffff;
    --btn-secondary-bg: #e2e8f0;
    --btn-secondary-text: #0f172a;
}

/* Base resets */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
    min-height: 100vh;
}

h1, h2, h3, h4, .card-symbol, .card-value {
    font-family: var(--font-heading);
    font-weight: 600;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Header */
.main-header {
    height: var(--header-height);
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--accent-start) 0%, var(--accent-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.main-header h1 {
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.accent-text {
    background: linear-gradient(135deg, var(--accent-start) 0%, var(--accent-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Layout */
.main-layout {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    width: 100%;
}

.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.panel-title {
    font-size: 1.15rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.icon-title {
    color: var(--accent-start);
}

/* Sidebar */
.control-panel {
    width: var(--sidebar-width);
    flex-shrink: 0;
    border-radius: 0;
    border-top: none;
    border-bottom: none;
    border-left: none;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.workspace {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    overflow-y: auto;
    max-width: 100%;
}

/* Form Controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.flex-2 { flex: 2; }
.flex-3 { flex: 3; }

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

label i {
    margin-right: 0.25rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    height: 44px;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent-start);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

body.light-theme select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 1.5rem 0;
}

.section-subtitle {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    height: 44px;
    padding: 0 1.5rem;
    border-radius: 8px;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    filter: brightness(1.15);
    box-shadow: 0 4px 12px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--btn-secondary-bg);
    color: var(--btn-secondary-text);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-icon:hover {
    background-color: var(--border-color);
}

/* Theme Toggle Button Icons */
#theme-toggle .icon-sun {
    display: none;
    color: var(--warning);
}
#theme-toggle .icon-moon {
    display: inline-block;
    color: #a855f7;
}
body.light-theme #theme-toggle .icon-sun {
    display: inline-block;
}
body.light-theme #theme-toggle .icon-moon {
    display: none;
}

/* Results Panel Placeholder */
.results-panel {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.results-placeholder {
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.placeholder-icon {
    font-size: 3rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.6;
}

.results-placeholder h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.results-placeholder p {
    font-size: 0.9rem;
    max-width: 400px;
    margin: 0 auto;
}

/* Results Content */
.results-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.fluid-badge, .phase-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
}

.fluid-badge {
    background-color: var(--accent-glow);
    color: var(--accent-start);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.phase-badge {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Fluid categories custom accent colors */
.category-pura {
    --accent-start: #38bdf8;
    --accent-end: #0ea5e9;
    --accent-glow: rgba(56, 189, 248, 0.15);
}

.category-refrigerante {
    --accent-start: #60a5fa;
    --accent-end: #2563eb;
    --accent-glow: rgba(96, 165, 251, 0.15);
}

.category-gas {
    --accent-start: #34d399;
    --accent-end: #059669;
    --accent-glow: rgba(52, 211, 153, 0.15);
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 1rem;
}

.result-card {
    background-color: var(--bg-main);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
}

.result-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-start);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.card-symbol {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 700;
    opacity: 0.4;
}

.card-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    text-align: center;
}

.card-value {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

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

.export-actions {
    display: flex;
    justify-content: flex-end;
}

/* Charts Panel */
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.chart-panel {
    display: flex;
    flex-direction: column;
    min-height: 380px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0;
}

.btn-axis-toggle {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.25rem 0.65rem;
    border-radius: 4px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: var(--transition);
}

.btn-axis-toggle:hover {
    border-color: var(--accent-start);
    color: var(--text-primary);
}

.axis-controls {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
}

.axis-control-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.axis-control-row span {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    width: 85px;
}

.axis-control-row input {
    flex: 1;
    max-width: 90px;
    height: 28px;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    outline: none;
    transition: var(--transition);
}

.axis-control-row input:focus {
    border-color: var(--accent-start);
}

.axis-control-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.btn-xs {
    height: 28px;
    padding: 0 0.75rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

.chart-wrapper {
    flex-grow: 1;
    position: relative;
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

/* Error banner style */
.error-banner {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
}

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

/* Mixture Saturation Table Styles */
.mixture-table-container {
    margin-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
    padding-top: 1.5rem;
    animation: slideIn 0.3s ease;
}

.mixture-table-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mixture-table-title i {
    color: var(--accent-start);
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.mixture-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
    background-color: var(--bg-panel);
}

.mixture-table th {
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    background-color: var(--bg-input);
}

.mixture-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

.mixture-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

body.light-theme .mixture-table tr:hover td {
    background-color: rgba(0, 0, 0, 0.015);
}

.prop-col {
    font-weight: 500;
    color: var(--text-secondary);
}

.val-col {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
}

.unit-col {
    color: var(--text-muted);
}

/* Responsive Breakpoints */

/* Mobile layouts (max 768px) */
@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .control-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1.5rem;
        overflow-y: visible;
    }
    
    .workspace {
        padding: 1.5rem;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-panel {
        min-height: 300px;
    }
    
    .main-header {
        padding: 0 1rem;
    }
    
    .main-header h1 {
        font-size: 1.1rem;
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablet layouts (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .control-panel {
        width: 320px;
        padding: 1.5rem;
    }
    
    .workspace {
        padding: 1.5rem;
    }
    
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
