/* Version 5 */
/* --- CSS VARIABLER --- */
:root {
    --primary-color: #2c3e50;
    --accent-color: #27ae60;
    --accent-hover: #219150;
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --border-light: #e2e8f0;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    --radius-std: 12px;
}

/* --- GRUNDSTIL --- */
html {
    scroll-padding-top: 150px; 
    scroll-behavior: smooth;
}

* { box-sizing: border-box; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; 
    background: var(--bg-body); 
    color: var(--text-main); 
    margin: 0; 
    padding-top: 70px; 
    overflow-x: hidden; 
    width: 100%;
    line-height: 1.6;
}

/* NAVBAR */
.navbar { 
    background: var(--primary-color); 
    position: fixed; 
    top: 0; 
    width: 100%; 
    z-index: 1000; 
    height: 70px; 
    display: flex; 
    align-items: center; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-content { 
    max-width: 900px; 
    margin: 0 auto; 
    display: flex; 
    justify-content: space-between; 
    width: 100%; 
    padding: 0 20px; 
    align-items: center; 
}

.nav-brand { color: #fff; font-weight: 700; font-size: 1.3rem; letter-spacing: -0.5px; }

.nav-links { 
    list-style: none; display: flex; gap: 15px; align-items: center; padding: 0; margin: 0;
}

.nav-links a { 
    color: rgba(255,255,255,0.9); text-decoration: none; font-size: 0.9rem; font-weight: 500; transition: color 0.2s;
}
.nav-links a:hover { color: #fff; }

/* IKON-KNAPPAR I MENYN */
.nav-icon-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}
.nav-icon-btn:hover { background: rgba(255,255,255,0.1); border-color: #fff; }
.nav-icon-btn.delete-btn:hover { background: #e74c3c; border-color: #e74c3c; }

/* CONTAINER */
.container { width: 95%; max-width: 900px; margin: 40px auto; }

header { text-align: center; margin-bottom: 50px; }
.logo { max-width: 220px; height: auto; margin-bottom: 15px; }

/* --- PROCESS STEPPER (Standard) --- */
.stepper-container {
    display: flex; align-items: center; justify-content: space-between; 
    margin-bottom: 60px; padding: 0 30px;
    transition: all 0.3s ease;
    background: transparent;
}

/* Placeholder för att förhindra layout-hopp vid sticky */
.stepper-placeholder {
    display: none;
    width: 100%;
}

.step { display: flex; flex-direction: column; align-items: center; position: relative; z-index: 2; transition: all 0.3s ease; }

.step-circle {
    width: 50px; height: 50px; background: #fff; border: 3px solid var(--border-light); 
    color: var(--text-muted); border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    font-weight: 700; font-size: 1.2rem; margin-bottom: 10px; transition: all 0.4s ease;
}

.step-label { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); transition: color 0.4s ease; }

/* Aktivt/Ifyllt steg (Grönt) */
.step.completed .step-circle {
    border-color: var(--accent-color); background: var(--accent-color); color: #fff; transform: scale(1.1);
}
.step.completed .step-label { color: var(--accent-color); }

.step-line { flex-grow: 1; height: 3px; background: var(--border-light); margin: 0 15px; transform: translateY(-15px); z-index: 1; }

/* --- STICKY STEPPER (När man scrollar) --- */
body.sticky-mode .stepper-container {
    position: fixed !important;
    top: 70px !important; /* Precis under navbaren */
    left: 0;
    width: 100%;
    z-index: 900;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    margin: 0 !important;
    padding: 10px 20px !important;
    border-bottom: 1px solid var(--border-light);
    
    /* Ingen transition på 'top' eller 'position' för det skapar lagg */
    transition: background 0.3s, padding 0.3s, box-shadow 0.3s;
}

/* Kompakt design vid sticky */
body.sticky-mode .step-circle {
    width: 35px; height: 35px; font-size: 1rem; margin-bottom: 0; border-width: 2px;
}
body.sticky-mode .step { flex-direction: row; gap: 10px; }
body.sticky-mode .step-label { font-size: 0.85rem; margin-top: 0; }
body.sticky-mode .step-line { margin: 0 10px; transform: translateY(0); }


/* --- SEKTIONS-KORT --- */
.tool-card {
    background: var(--bg-card);
    padding: 50px 40px;
    border-radius: var(--radius-std);
    box-shadow: var(--shadow-soft);
    margin-bottom: 0; 
    border: 1px solid rgba(0,0,0,0.02);
    scroll-margin-top: 150px; /* Justerat för sticky header */
}

.section-hero { display: none; }

/* PILAR MELLAN SEKTIONER */
.section-divider-arrow {
    text-align: center; font-size: 2rem; color: var(--primary-color); 
    margin: 40px 0; opacity: 0.2;
}

.section-title { 
    color: var(--primary-color); font-size: 1.8rem; font-weight: 700; border-bottom: none; margin-bottom: 15px; letter-spacing: -0.5px;
}
.section-desc { color: var(--text-muted); font-size: 1rem; margin-bottom: 40px; max-width: 700px; line-height: 1.7; }

/* --- LAYOUT: DASHBOARD (Sektion 1 - Desktop) --- */
.kalkyl-wrapper {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 40px;
    align-items: start;
}
.left-column { display: flex; flex-direction: column; gap: 20px; }

/* Sticky resultatbox på desktop */
.right-column { 
    position: sticky; 
    top: 140px; /* 70px nav + ~60px sticky stepper + 10px luft */
    height: fit-content;
}
.right-column .result-section { margin-top: 0; height: 100%; }

/* --- GRID & INPUTS (Sektion 2) --- */
.calculator-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; align-items: start; } 
.input-section { background: #fff; padding: 0; border: none; margin-bottom: 20px; }
.input-section h3 { font-size: 1.1rem; color: var(--primary-color); margin-bottom: 15px; border-bottom: 2px solid #f0f0f0; padding-bottom: 8px; display: inline-block; }
label { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 600; color: #4a5568; }

input[type="number"], input[type="text"] { 
    width: 100%; padding: 12px 15px; margin-bottom: 15px; border: 1px solid var(--border-light); border-radius: 8px; background: #fff; font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus { outline: none; border-color: #3498db; box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1); }

.ad-slot { background-color: #f1f2f6; border: none; color: #a0aec0; text-align: center; padding: 30px 10px; margin: 40px auto; max-width: 728px; border-radius: 8px; font-size: 0.75rem; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }

.budget-meter { background: #fff; border: 1px solid var(--border-light); padding: 20px; border-radius: var(--radius-std); text-align: center; margin-bottom: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.03); }
.budget-meter strong { font-size: 1.5rem; margin-left: 10px; color: var(--text-main); }

/* --- RESULTAT (Uppdaterad) --- */
.result-section { 
    background: #f8fafc; color: var(--text-main); padding: 30px; border-radius: var(--radius-std); margin-top: 10px; border: 1px solid var(--border-light); position: relative; overflow: hidden;
}
.result-section::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--primary-color); }
.result-section.blue-theme { background: #f0f7ff; }
.result-section.blue-theme::before { background: #3498db; }

/* Standardrader */
.result-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 0.95rem; }
.result-row span:first-child { color: #555; }
.result-row span:last-child { font-weight: 600; color: #000; }

/* TOTAL-RADER (Rubrik och belopp på olika rader) */
.result-row.total { 
    display: flex; flex-direction: column; align-items: flex-start; margin-top: 20px; gap: 5px;
}
.result-row.total span:first-child { font-size: 0.9rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }
.result-row.total span:last-child { font-size: 1.8rem; font-weight: 800; color: var(--primary-color); line-height: 1.2; }
.blue-theme .result-row.total span:last-child { color: #2980b9; }

hr { border: 0; border-top: 1px solid rgba(0,0,0,0.1); margin: 25px 0; }

/* Kapitalbehov-box */
.cash-check-box { border: 2px solid #f39c12; background: #fffaf0; padding: 20px; border-radius: var(--radius-std); margin-top: 25px; color: #333; }
.cash-check-box h4 { margin-top: 0; color: #d35400; font-size: 0.9rem; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 15px; }

/* Streckad linje innan totalen i den orangea boxen */
.cash-check-box .result-row.total { margin-top: 15px; padding-top: 15px; border-top: 1px dashed rgba(211, 84, 0, 0.3); }

/* --- TABELL --- */
.table-container { overflow-x: auto; border-radius: var(--radius-std); border: 1px solid var(--border-light); margin-top: 30px; -webkit-overflow-scrolling: touch; }
#bidTable { width: 100%; border-collapse: collapse; min-width: 600px; font-size: 0.9rem; }
#bidTable th, #bidTable td { padding: 16px; text-align: right; border-bottom: 1px solid var(--border-light); }
#bidTable th { background: #f8f9fa; color: var(--primary-color); font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.5px; }
#bidTable th:first-child, #bidTable td:first-child { position: sticky; left: 0; z-index: 10; text-align: left; background: #fff; border-right: 2px solid #f0f0f0; font-weight: 600; }
#bidTable th:first-child { background: #f8f9fa; }
#bidTable td:nth-child(2), #bidTable th:nth-child(2) { background-color: #fafafa !important; }
.max-bid-column { background-color: #fffde7 !important; border-left: 2px solid #fbc02d !important; border-right: 2px solid #fbc02d !important; color: #856404 !important; }
.own-bid-column { background-color: #f0fff4 !important; color: #155724 !important; }

/* --- KONTROLLER --- */
.bid-controls { display: flex; justify-content: space-between; align-items: flex-end; gap: 15px; flex-wrap: wrap; background: #fff; padding: 20px; border-radius: var(--radius-std); border: 1px solid var(--border-light); margin-top: 20px; }
.action-btn { background: var(--accent-color); color: #fff; border: none; padding: 12px 25px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.95rem; transition: background 0.2s; }
.action-btn:hover { background: var(--accent-hover); }
.secondary-btn { background: #cbd5e0; color: #4a5568; border: none; padding: 12px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: background 0.2s; }
.secondary-btn:hover { background: #a0aec0; }
.nav-btn { padding: 8px 18px; font-size: 0.85rem; border-radius: 6px; cursor: pointer; border: none; color: #fff; font-weight: 500; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.info-icon { background: #3498db; color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; font-size: 0.75rem; line-height: 20px; text-align: center; padding: 0; margin-left: 5px; }

/* MODALS */
.modal { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(2px); }
.modal-content { background: #fff; margin: 15% auto; padding: 40px; border-radius: 16px; width: 85%; max-width: 450px; position: relative; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.close-btn { position: absolute; right: 25px; top: 20px; font-size: 28px; cursor: pointer; color: #aaa; }
.close-btn:hover { color: #333; }

/* FOOTER */
footer.tool-card { 
    text-align: center; border: 1px solid var(--border-light); 
    margin-bottom: 40px; 
    margin-top: 100px; /* REJÄLT AVSTÅND UPPÅT */
}

/* PRINT HELPERS */
.print-only { display: none; }
.menu-toggle { display: none; flex-direction: column; justify-content: space-between; width: 30px; height: 22px; background: transparent; border: none; cursor: pointer; padding: 0; z-index: 1001; }
.menu-toggle .bar { display: block; height: 2px; width: 100%; background-color: #fff; border-radius: 2px; transition: all 0.3s ease; }

/* --- UTSKRIFTSANPASSNING --- */
@media print {
    @page { margin: 2cm; size: auto; }
    .no-print, .navbar, .bid-controls, button, .info-icon, .ad-slot, .section-hero, .menu-toggle, input[type=range], .section-desc, .stepper-container, .section-divider-arrow, .left-column
    { display: none !important; }

    .print-only { display: block !important; }
    body { background: white; padding-top: 0; color: #000; font-size: 11pt; }
    .container { width: 100%; max-width: 100%; box-shadow: none; margin: 0; padding: 0; }
    .tool-card { box-shadow: none; border: none; border-bottom: 1px solid #000; margin-bottom: 30px; padding: 0 0 20px 0; page-break-inside: avoid; overflow: visible; }
    .tool-card:last-child { border-bottom: none; }
    .section-title { font-size: 1.4rem; color: #000; border: none; margin-bottom: 15px; }
    .input-section { background: none; border: none; padding: 0; margin-bottom: 10px; }
    .input-section h3 { color: #000; border: none; }
    label { color: #000; font-size: 0.9rem; }
    input { border: none; background: transparent; font-weight: bold; color: #000; padding: 0; margin-bottom: 2px; font-size: 1rem; }
    .result-section, .result-section.blue-theme { background: #fff !important; color: #000 !important; padding: 15px; border: 2px solid #000; border-radius: 0; margin-top: 20px; }
    .result-section::before { display: none; }
    .result-row span, .result-row.total span, .blue-theme .result-row.total span { color: #000 !important; }
    .cash-check-box { border: 2px solid #000; background: none; color: #000; padding: 15px; }
    .cash-check-box h4 { color: #000; }
    .table-container { box-shadow: none; overflow: visible; border: none; }
    #bidTable { border: 1px solid #000; font-size: 10pt; }
    #bidTable th, #bidTable td { border: 1px solid #000; background: #fff !important; color: #000 !important; }
    #bidTable th:first-child, #bidTable td:first-child { position: static; border-right: 1px solid #000; }
    footer.tool-card { border: none; margin-top: 50px; font-size: 0.8rem; }
    footer h2 { display: none; }
    
    .kalkyl-wrapper { display: block; }
    .right-column { width: 100%; }
    .right-column .result-section { border: 2px solid #000; box-shadow: none; }
}

/* --- MOBILANPASSNING (max 900px) --- */
@media (max-width: 900px) {
    .container { width: 100%; max-width: 100%; margin: 0; padding: 20px; }
    
    /* Återställ Dashboard-layout till en kolumn på mobil */
    .kalkyl-wrapper { grid-template-columns: 1fr; }
    .right-column { position: static; }
    
    .calculator-grid { grid-template-columns: 1fr; gap: 30px; }
    
    .stepper-container { padding: 0; margin-bottom: 30px; }
    .step-circle { width: 40px; height: 40px; font-size: 1rem; }
    .step-label { font-size: 0.8rem; }
    .step-line { margin: 0 5px; transform: translateY(-10px); }
    
    .menu-toggle { display: flex; }
    .nav-links { display: none; position: absolute; top: 70px; left: 0; width: 100%; flex-direction: column; background-color: var(--primary-color); padding: 20px 0; box-shadow: 0 4px 10px rgba(0,0,0,0.1); z-index: 1000; }
    .nav-links.active { display: flex; }
    .nav-links li { margin: 15px 0; width: 100%; text-align: center; }
    .nav-icon-btn { width: 50px; height: 50px; font-size: 1.3rem; margin: 0 auto; }
    
    .budget-meter { display: flex; flex-direction: column; align-items: center; gap: 5px; }
    .budget-meter strong { margin-left: 0; font-size: 1.5rem; }
    .result-row { flex-direction: column; align-items: flex-start; margin-bottom: 15px; padding-bottom: 5px; border-bottom: 1px solid rgba(0,0,0,0.05); }
    .result-row:last-child { border-bottom: none; }
    .result-row span:last-child { font-weight: 600; margin-top: 4px; font-size: 1.15rem; }
    .result-row.total span:last-child { font-size: 1.6rem; margin-top: 8px; }
    
    #bidTable { min-width: 100%; }
    #bidTable th, #bidTable td { padding: 12px 8px; text-align: center; font-size: 0.9rem; }
    #bidTable td:first-child, #bidTable th:first-child { text-align: left; position: static; box-shadow: none; border-right: 1px solid #eee; width: auto; white-space: normal; }
    .max-bid-column { background-color: transparent !important; border: none !important; }
    .max-bid-row td { background-color: #fffde7 !important; border-top: 2px solid #fbc02d; border-bottom: 2px solid #fbc02d; color: #856404; }
    .own-bid-row td { background-color: #f0fff4 !important; color: #155724; }
    .bid-controls { flex-direction: column; align-items: stretch; }
    .bid-controls div { width: 100%; margin-bottom: 10px; }
    #nextBidInput { width: 100% !important; padding: 14px; font-size: 1rem; }
    #addBidBtn, #resetBidsBtn { width: 100%; padding: 14px; margin-top: 5px; }

    /* Sticky stepper anpassning för mobil */
    body.sticky-mode .step-label { display: none !important; }
    body.sticky-mode .step-line { display: block !important; margin: 0 5px; }
    body.sticky-mode .stepper-container { padding: 8px 15px !important; }
}