/* ============================================================
   SolarCalc.fyi — Styles
   ============================================================ */

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --primary: #e67e22;
    --primary-dark: #d35400;
    --primary-light: #f39c12;
    --text: #2c3e50;
    --text-light: #6c757d;
    --border: #dee2e6;
    --success: #27ae60;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.12);
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }

/* HEADER */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}
.logo-icon { font-size: 1.5rem; }
.accent { color: var(--primary); }
.main-nav a {
    text-decoration: none;
    color: var(--text-light);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}
.main-nav a:hover { background: var(--bg); color: var(--text); }
.main-nav a.active { color: var(--primary); background: #fef3e7; }

/* BUTTONS */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-lg { padding: 14px 32px; font-size: 1.1rem; }
.btn-sm { padding: 6px 14px; font-size: 0.9rem; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* HERO */
.hero {
    text-align: center;
    padding: 80px 0 60px;
    background: linear-gradient(135deg, #fef3e7 0%, #f8f9fa 100%);
}
.hero h1 { font-size: 2.8rem; margin-bottom: 16px; color: var(--text); }
.hero-subtitle { font-size: 1.2rem; color: var(--text-light); max-width: 640px; margin: 0 auto 32px; }
.hero-note { margin-top: 16px; font-size: 0.9rem; color: var(--text-light); }

/* FEATURES */
.features { padding: 60px 0; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature-card {
    background: var(--surface);
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    transition: transform 0.2s;
}
.feature-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.feature-icon { font-size: 2.5rem; margin-bottom: 16px; }
.feature-card h3 { margin-bottom: 8px; }
.feature-card p { color: var(--text-light); font-size: 0.95rem; }

/* HOW IT WORKS */
.how-it-works { padding: 60px 0; background: var(--surface); text-align: center; }
.how-it-works h2 { margin-bottom: 40px; }
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; text-align: left; }
.step { padding: 20px; }
.step-number {
    width: 40px; height: 40px;
    background: var(--primary); color: white;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; margin-bottom: 12px;
}
.step h4 { margin-bottom: 8px; }
.step p { color: var(--text-light); font-size: 0.9rem; }

/* FAQ PREVIEW */
.faq-preview {
    padding: 60px 0;
    text-align: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #fef3e7 100%);
}
.faq-preview h2 { margin-bottom: 16px; }
.faq-preview p { max-width: 640px; margin: 0 auto 24px; color: var(--text-light); }

/* === CALCULATOR PAGE === */
.calc-page { padding: 40px 0; }
.calc-page h1 { text-align: center; margin-bottom: 8px; }
.calc-intro { text-align: center; color: var(--text-light); margin-bottom: 32px; }

/* STEP INDICATOR */
.step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
}
.step-dot {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
    transition: all 0.3s;
    cursor: pointer;
}
.step-dot.active { background: var(--primary); color: white; }
.step-dot.completed { background: var(--success); color: white; }
.step-line {
    width: 80px; height: 3px;
    background: var(--border);
    margin: 0 8px;
}

/* CALC CARD */
.calc-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
}
.calc-step { display: none; }
.calc-step.active { display: block; }
.step-desc { color: var(--text-light); margin-bottom: 24px; }

/* APPLIANCES */
.appliance-selector { margin-bottom: 20px; }
.appliance-search input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}
.preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
}
.preset-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    gap: 6px;
    align-items: center;
}
.preset-btn:hover { border-color: var(--primary); background: #fef3e7; }
.preset-name { font-weight: 500; }
.preset-watts { color: var(--text-light); font-size: 0.8rem; }
.preset-icon { font-size: 1.3rem; line-height: 1; }

.custom-appliance {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.custom-appliance input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}
.custom-appliance input[type="number"] { flex: 0 0 100px; }

.appliance-table-wrap { overflow-x: auto; margin-bottom: 16px; }
.appliance-table { width: 100%; border-collapse: collapse; }
.appliance-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-light);
}
.appliance-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.appliance-table .input-sm {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-align: center;
}
.empty-state { text-align: center; color: var(--text-light); padding: 24px !important; }
.btn-remove {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.btn-remove:hover { background: #fde8e8; }

.step-total {
    text-align: right;
    font-size: 1.1rem;
    padding: 16px 0;
    border-top: 2px solid var(--border);
}
.step-total span { color: var(--primary); font-size: 1.3rem; }

.step-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* LOCATION */
.location-input { position: relative; margin-bottom: 16px; }
.location-input input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
}
.city-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: var(--shadow);
}
.city-hint {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
}
.city-result-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.city-result-item:hover { background: #fef3e7; }
.city-result-item:last-child { border-bottom: none; }
.no-result { color: var(--text-light); }

.location-info {
    background: #eef2ff;
    padding: 16px;
    border-radius: 8px;
    margin-top: 12px;
}

/* CONFIG */
.config-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}
.config-item label { display: block; font-weight: 600; margin-bottom: 8px; }
.radio-group { display: flex; gap: 8px; }
.radio-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}
.radio-btn:has(input:checked) {
    border-color: var(--primary);
    background: #fef3e7;
}
.radio-btn input { display: none; }
.config-item select, .config-item input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
}
.config-hint { display: block; font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }

.config-summary {
    background: #fef3e7;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--primary-dark);
    font-weight: 500;
    text-align: center;
}

/* RESULTS */
.loading { text-align: center; padding: 60px 0; }
.spinner {
    width: 48px; height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.results-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 24px 0;
}
.result-metric {
    background: var(--bg);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}
.metric-label { display: block; color: var(--text-light); font-size: 0.85rem; margin-bottom: 4px; }
.metric-value { font-size: 1.2rem; font-weight: 700; }

.system-design {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 24px 0;
}
.design-card {
    background: var(--bg);
    padding: 24px;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid var(--border);
}
.card-icon { font-size: 2rem; margin-bottom: 8px; }
.design-card h3 { font-size: 0.95rem; color: var(--text-light); margin-bottom: 8px; }
.card-value { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.card-detail { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }

.battery-card { border-left: 4px solid #27ae60; }
.panel-card { border-left: 4px solid var(--primary); }
.inverter-card { border-left: 4px solid #2c3e50; }
.controller-card { border-left: 4px solid #3498db; }

.cost-estimate {
    text-align: center;
    padding: 24px;
    background: linear-gradient(135deg, #fef3e7, #f8f9fa);
    border-radius: var(--radius);
    margin: 24px 0;
}
.cost-estimate h3 { margin-bottom: 12px; }
.cost-range { font-size: 1.8rem; font-weight: 700; }
.cost-value { color: var(--text); }
.cost-sep { color: var(--text-light); }
.cost-note { color: var(--text-light); font-size: 0.85rem; margin-top: 8px; }

.result-actions { display: flex; gap: 12px; justify-content: center; margin: 24px 0; }

.error-state {
    text-align: center;
    padding: 60px 20px;
}
.error-state h2 { margin-bottom: 12px; }
.error-state p { color: var(--text-light); margin-bottom: 24px; }

/* FOOTER */
.site-footer {
    background: var(--text);
    color: #adb5bd;
    text-align: center;
    padding: 32px 0;
    font-size: 0.85rem;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .feature-grid { grid-template-columns: 1fr; }
    .steps { grid-template-columns: 1fr; }
    .calc-card { padding: 20px; }
    .config-grid { grid-template-columns: 1fr; }
    .system-design { grid-template-columns: 1fr; }
    .results-summary { grid-template-columns: 1fr; }
}

/* ============================================================
   APPLIANCE PHOTO / NAMEPLATE UPLOAD
   ============================================================ */
.appliance-thumb {
    width: 36px; height: 36px;
    object-fit: cover;
    border-radius: 6px;
    vertical-align: middle;
    margin-right: 6px;
    border: 1px solid var(--border);
}
.appliance-table td:first-child {
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-appliance-divider {
    text-align: center;
    margin: 16px 0;
    position: relative;
    color: var(--text-light);
    font-size: 0.85rem;
}
.custom-appliance-divider::before,
.custom-appliance-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border);
}
.custom-appliance-divider::before { left: 0; }
.custom-appliance-divider::after { right: 0; }

.upload-hint {
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 10px;
    text-align: center;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--bg);
}
.upload-area:hover {
    border-color: var(--primary);
    background: #fef3e7;
}
.upload-icon { font-size: 2rem; }
.upload-text { color: var(--text-light); font-size: 0.9rem; }

.nameplate-preview {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    background: var(--bg);
    border: 1px solid var(--success);
    border-radius: 12px;
    padding: 16px;
}
.nameplate-preview img {
    width: 120px;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border);
}
.nameplate-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nameplate-info p {
    font-size: 0.85rem;
    color: var(--text);
    margin: 0;
}
.nameplate-info input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}
.nameplate-info .btn { align-self: flex-start; }

.nameplate-upload {
    margin-top: 12px;
}

@media (max-width: 768px) {
    .nameplate-preview { flex-direction: column; align-items: stretch; }
    .nameplate-preview img { width: 100%; max-height: 200px; }
    .upload-area { padding: 16px; }
    .appliance-table td:first-child { flex-wrap: wrap; }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 32px;
    max-width: 500px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.modal h2 { margin-bottom: 8px; }
.modal p { color: var(--text-light); margin-bottom: 20px; font-size: 0.95rem; }
.modal-close {
    position: absolute;
    top: 16px; right: 16px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}
.modal-close:hover { background: var(--bg); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 0.9rem; }
.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.form-group input:focus { outline: none; border-color: var(--primary); }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 20px; }
.share-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    overflow-y: auto;
}
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; }

/* ============================================================
   RESPONSIVE — Tablet & Phone
   ============================================================ */
@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .hero { padding: 50px 0 40px; }
    .hero-subtitle { font-size: 1.05rem; }
    .feature-grid { grid-template-columns: 1fr; }
    .steps { grid-template-columns: 1fr; text-align: center; }
    .step-number { margin: 0 auto 12px; }
    .calc-card { padding: 20px; }
    .calc-page { padding: 24px 0; }
    .config-grid { grid-template-columns: 1fr; }
    .system-design { grid-template-columns: 1fr; }
    .results-summary { grid-template-columns: 1fr; }
    .step-indicator { gap: 4px; }
    .step-dot { width: 32px; height: 32px; font-size: 0.8rem; }
    .step-line { width: 40px; }
    .custom-appliance { flex-direction: column; }
    .custom-appliance input[type="number"] { flex: 1; }
    .step-actions { flex-direction: column; }
    .step-actions .btn { width: 100%; text-align: center; }
    .result-actions { flex-direction: column; }
    .result-actions .btn { width: 100%; text-align: center; }
    .site-header .container { flex-direction: column; height: auto; padding: 12px 20px; gap: 8px; }
    .main-nav a { padding: 6px 12px; font-size: 0.9rem; }
    .design-card { padding: 16px; }
    .card-value { font-size: 1.3rem; }
    .cost-range { font-size: 1.4rem; }
    .preset-list { max-height: 160px; }
    .preset-btn { font-size: 0.8rem; padding: 5px 10px; }
    .modal { padding: 24px; margin: 10px; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; text-align: center; }
}

@media (max-width: 480px) {
    .container { padding: 0 12px; }
    .hero h1 { font-size: 1.6rem; }
    .hero-subtitle { font-size: 0.95rem; }
    .calc-card { padding: 16px; border-radius: 8px; }
    .step-dot { width: 28px; height: 28px; font-size: 0.7rem; }
    .step-line { width: 24px; }
    .appliance-table { font-size: 0.85rem; }
    .appliance-table .input-sm { width: 50px; font-size: 0.8rem; }
    .btn { font-size: 0.9rem; padding: 10px 16px; }
    .btn-lg { padding: 12px 20px; font-size: 1rem; }
    .results-summary { gap: 8px; }
    .result-metric { padding: 12px; }
    .design-card { padding: 12px; }
    .config-item select, .config-item input[type="number"] { padding: 8px 10px; }
    .site-footer { padding: 24px 12px; font-size: 0.8rem; }
}