
/* Reset default browser styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    min-height: 100vh;
    background-color: #f5f5f7;
    padding: 10px;
    color: #1d1d1f;
}

.wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.simulator-container {
    background-color: #fbfbfd;
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
    width: 100%;
    max-width: 1300px;
}

.hf-shell {
    background: #fbfbfd;
    border: 1px solid #e5e5ea;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

.hf-panel {
    background: #f8f8fa !important;
    border: 1px solid #e5e5ea !important;
}

h1 {
    text-align: center;
    color: #1c2e4a;
    margin-top: 5px;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.8em;
}

.wide-block {
    width: 100%;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 12px;
}

.wide-block h2, .wide-block h3 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 10px;
    color: #0056b3;
    font-weight: 500;
}

.type-selector-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.type-option {
    flex: 1;
    min-width: 120px;
    max-width: 150px;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 5px;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.type-option:hover {
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.15);
}

.type-option.selected {
    border-color: #007bff;
    background-color: #e7f3ff;
}

.type-option input[type="radio"] {
    display: none;
}

.type-label-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
}

.type-label-group img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #eee;
}

.type-label-group label {
    font-weight: 500;
    font-size: 0.85em;
    color: #333;
}

.main-layout {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.column {
    flex: 1;
    min-width: 320px;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.hot-side {
    border-left: 4px solid #d9534f;
    background-color: #fff7f7;
}

.cold-side {
    border-left: 4px solid #5bc0de;
    background-color: #f4faff;
}

.column h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 12px;
    font-weight: 500;
}

.hot-side h2 {
    color: #d9534f;
}

.cold-side h2 {
    color: #5bc0de;
}

.control-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.control-row .control-group {
    flex: 1;
    margin-bottom: 0;
}

.control-group {
    margin-bottom: 8px;
}

.control-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: #555;
    font-size: 0.9em;
}

.control-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    background: #e9ecef;
    outline: none;
    border-radius: 5px;
    padding: 0;
    cursor: pointer;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 20px;
    background: #007bff;
    cursor: pointer;
    border-radius: 3px;
    margin-top: -8px;
    transition: background-color 0.2s;
}

.hot-side input[type="range"]::-webkit-slider-thumb {
    background: #d9534f;
}

.cold-side input[type="range"]::-webkit-slider-thumb {
    background: #5bc0de;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
    filter: brightness(90%);
}

.control-group input[type="number"],
.control-group select {
    width: 100%;
    padding: 6px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95em;
}

.control-group input[type="number"]:focus,
.control-group select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* Remove number input spinner arrows */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.auto-updated {
    font-style: italic;
    font-weight: 700;
}

.status-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    line-height: 1.3;
}

.status-manual { background: #e5f2ff; color: #1d4ed8; }
.status-auto { background: #ecfdf3; color: #047857; }
.status-locked { background: #fee2e2; color: #b91c1c; }

#modelSizingTableBody tr {
    cursor: pointer;
    transition: background-color 0.15s ease;
}
#modelSizingTableBody tr:hover {
    background-color: #f8fafc;
}
#modelSizingTableBody tr.selected-model {
    background-color: #e8f0ff;
}

input[type="range"] + input[type="number"] {
    margin-top: 5px;
}

.selector-with-info {
    display: flex;
    align-items: center;
    gap: 5px;
}

.selector-with-info select {
    flex-grow: 1;
}

.info-btn {
    padding: 6px 9px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
}

.info-btn:hover {
    background-color: #5a6268;
}

.top-controls-block {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.material-selectors-container {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    margin-top: 8px;
}

.material-selectors-container .control-group {
    flex: 1;
    margin-bottom: 0;
}

.capacity-display {
    width: 30%;
    min-width: 320px;
    margin-bottom: 0;
    background-color: #fff;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 12px;
}

.capacity-display h3,
.capacity-display p {
    margin: 0;
    padding: 0;
}

.results-block .results-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.results-block .calculated-params,
.results-block .material-recommendation {
    flex: 1;
    min-width: 300px;
    background-color: #fff;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.material-recommendation p {
    font-size: 0.85em;
    font-weight: 500;
    margin: 6px 0;
    padding: 5px;
    border-radius: 4px;
    background-color: #f8f9fa;
    text-align: left;
}

.results-block h3 {
    margin-top: 0;
    color: #0056b3;
    font-weight: 500;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.capacity-display h3 {
    font-size: 1.8em;
    color: #0056b3;
    font-weight: 500;
}

#capacityOutput {
    font-size: 1.8em;
    font-weight: 600;
    color: #28a745;
}

.calculated-params p {
    font-size: 0.95em;
    color: #343a40;
    line-height: 1.5;
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
    text-align: left;
}

.calculated-params span:first-child {
    color: #555;
    padding-right: 10px;
}

.calculated-params span:last-child {
    font-weight: 600;
    color: #000;
}

.temperature-profile-block #temperatureGraph {
    height: 300px;
    max-width: 100%;
}

.animation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.flow-switch-btn {
    padding: 5px 10px;
    font-size: 0.85em;
    font-weight: 500;
    color: #fff;
    background-color: #007bff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.flow-switch-btn:hover {
    background-color: #0056b3;
}

.flow-switch-btn:active {
    transform: scale(0.98);
}

.animation-canvas-wrapper {
    position: relative;
    margin-top: 8px;
}

.animation-block #fluidAnimationCanvas {
    background-color: #1a2533;
    width: 100%;
    border-radius: 4px;
    display: block;
}

.sim-data-overlay {
    position: absolute;
    color: white;
    font-size: 0.85em;
    font-weight: 500;
    padding: 3px 6px;
    background-color: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    pointer-events: none;
    text-align: center;
}

#hot-inlet-temp { top: 25%; left: 10px; transform: translateY(-50%); }
#hot-outlet-temp { top: 25%; right: 10px; transform: translateY(-50%); }
#cold-inlet-temp { top: 75%; left: 10px; transform: translateY(-50%); }
#cold-outlet-temp { top: 75%; right: 10px; transform: translateY(-50%); }
#hot-flow-rate { top: 25%; left: 50%; transform: translate(-50%, -50%); }
#cold-flow-rate { top: 75%; left: 50%; transform: translate(-50%, -50%); }

@media (max-width: 1100px) {
    .main-layout,
    .material-selectors-container {
        flex-direction: column;
        gap: 10px;
    }
    .column {
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .results-block .results-container,
    .animation-header {
        flex-direction: column;
    }

    .control-row {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .control-row .control-group {
        flex: 0 0 48%;
        width: 48%;
    }

    .control-row .control-group:nth-child(odd):last-child {
        flex: 0 0 100%;
        width: 100%;
    }

    .animation-header {
        gap: 8px;
        margin-bottom: 8px;
    }

    .capacity-display {
        width: 90%;
    }
}

/* ===== v1.10 NEW STYLES ===== */

/* Result badges (Task 6.3) */
.result-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    margin-left: 4px;
}
.badge-green  { background: #16a34a; }
.badge-amber  { background: #d97706; }
.badge-red    { background: #dc2626; }
.badge-blue   { background: #1d4ed8; }

/* Auto Balance toggle pill (Task 10.3) */
.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-pill {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    background: #9ca3af;
    border-radius: 10px;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-pill::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: left 0.2s;
}
.toggle-label input:checked + .toggle-pill { background: #16a34a; }
.toggle-label input:checked + .toggle-pill::after { left: 18px; }

/* Balance indicator (Task 11.2) */
.balance-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    min-height: 2rem;
    padding: 0.35rem 0.8rem;
    border-radius: 9999px;
    border: 1px solid #d1d5db;
    background: #f3f4f6;
    color: #374151;
}
.balance-indicator.balanced {
    color: #065f46;
    border-color: #86efac;
    background: #ecfdf3;
}
.balance-indicator.near-balanced {
    color: #92400e;
    border-color: #fcd34d;
    background: #fffbeb;
}
.balance-indicator.imbalanced {
    color: #991b1b;
    border-color: #fca5a5;
    background: #fef2f2;
}

/* Secondary button style for manual Balance btn (Task 10.5) */
.btn-secondary {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #d1d5db;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}
.btn-secondary:hover { border-color: #9ca3af; background: #f9fafb; }

/* Top control strip */
.hf-top-line {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}
.hf-inline-capacity {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    flex: 0 1 auto;
}
.hf-capacity-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
}
.hf-unit {
    color: #6b7280;
    font-weight: 600;
    white-space: nowrap;
}
.hf-inline-select {
    min-width: 7.25rem;
    flex: 1 1 8.5rem;
}
.hf-inline-select select {
    height: 42px;
}
.hf-inline-margin {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 9rem;
    flex: 0 1 auto;
}
.hf-inline-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
    white-space: nowrap;
}
.hf-margin-input {
    width: 5rem;
}
.hf-model-type-wrap select {
    border: 1.5px solid #38bdf8;
    background: #eff6ff;
    color: #0f172a;
    font-weight: 700;
}
.hf-second-line {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.2rem;
}
.hf-design-btn {
    background: #dc2626;
    color: #fff;
    border: 1px solid #b91c1c;
}
.hf-design-btn:hover {
    background: #b91c1c;
}
#balanceIndicator {
    justify-self: end;
}

/* Custom fluid entry */
.custom-fluid-group {
    grid-column: 1 / -1;
    background: rgba(255, 255, 255, 0.75);
    border: 1px dashed #cbd5e1;
    border-radius: 0.6rem;
    padding: 0.6rem;
}
.custom-fluid-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 0.4rem;
}

.lock-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #111827;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}
.lock-toggle:hover {
    color: #000;
    transform: scale(1.05);
}
.lock-toggle.is-locked {
    background: transparent;
    color: #000;
}

/* Mobile: geometry grid collapses */
@media (max-width: 640px) {
    #plateGeometryPanel .grid { grid-template-columns: 1fr 1fr; }
    .hf-top-line {
        gap: 0.4rem;
    }
    .hf-inline-select {
        min-width: 48%;
        flex: 1 1 48%;
    }
    .hf-inline-capacity,
    .hf-inline-margin {
        width: 100%;
        justify-content: flex-start;
    }
    .hf-second-line {
        grid-template-columns: 1fr;
        justify-items: center;
    }
    #balanceIndicator {
        justify-self: center;
    }
}
