/* --- ranta.css (Slutgiltig Version) --- */

/* FÄRGTEMAN */
:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --container-bg: #ffffff;
    --text-color: #333;
    --input-bg: #fff;
    --input-border: #ddd;
    --heading-color: #2c3e50;
    --section-bg: #fff;
    --modal-bg: #fff;
    --modal-header-border: #eee;
    --result-bg: #f8f9fa;
    --tab-inactive: #888;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #1e1e2f 0%, #2a2a40 100%);
    --container-bg: #2d2d3a;
    --text-color: #e0e0e0;
    --input-bg: #3b3b4d;
    --input-border: #4f4f6a;
    --heading-color: #ffffff;
    --section-bg: #3b3b4d;
    --modal-bg: #2d2d3a;
    --modal-header-border: #444;
    --result-bg: rgba(0,0,0,0.2);
    --tab-inactive: #aaa;
    --primary-color: #4dabf7;
    --primary-hover: #339af0;
}

/* GRUNDLÄGGANDE */
html { 
    scroll-behavior: smooth; 
    -webkit-text-size-adjust: 100%; 
} 

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    margin: 0; 
    padding: 0;
    min-height: 100vh;
    line-height: 1.6;
}

/* NAVIGATION */
nav {
    position: sticky; top: 0; z-index: 100;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--input-border);
    padding: 12px 0; 
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    width: 100%;
}
[data-theme="dark"] nav { background-color: rgba(45, 45, 58, 0.95); }

.nav-container {
    max-width: 1100px; margin: 0 auto; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
}
.nav-logo { font-weight: 800; font-size: 1.3rem; color: var(--heading-color); text-decoration: none; margin-right: auto; }
.nav-links { display: flex; gap: 20px; align-items: center; }
.nav-links a { text-decoration: none; color: var(--text-color); font-weight: 600; font-size: 0.95rem; transition: color 0.2s; }
.nav-links a:hover { color: var(--primary-color); }
.theme-btn { background:none; border:none; font-size:1.2rem; cursor:pointer; width:auto; padding:0; margin-left:15px; }

/* HUVUDCONTAINER */
.container {
    position: relative;
    background-color: var(--container-bg);
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    width: 90%; max-width: 1100px;
    margin: 0 auto; 
    transition: background-color 0.3s ease;
}
h2 { text-align: center; color: var(--heading-color); margin-bottom: 2rem; font-size: 1.8rem; }

/* LAYOUT DASHBOARD */
.dashboard-layout { display: grid; grid-template-columns: 1fr; gap: 40px; }
@media (min-width: 900px) {
    .dashboard-layout { grid-template-columns: 350px 1fr; align-items: start; }
    .input-section { background: var(--section-bg); padding: 25px; border-radius: 12px; border: 1px solid var(--input-border); }
    .result-box { margin-top: 0; height: 100%; }
}

/* INPUTS */
.input-group { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 1.2rem; width: 100%; }
label { margin-bottom: 0.5rem; font-weight: 600; color: var(--text-color); width: 100%; font-size: 0.95rem; }
input[type="number"], textarea {
    width: 100%; padding: 12px; border-radius: 8px; font-size: 16px; 
    box-sizing: border-box; background-color: var(--input-bg); 
    border: 1px solid var(--input-border); color: var(--text-color);
    transition: border-color 0.2s; appearance: none;
}
input[type="number"]:focus, textarea:focus { border-color: var(--primary-color); outline: none; }

/* KNAPPAR */
button { 
    width: 100%; padding: 14px; background-color: var(--primary-color); 
    color: white; border: none; border-radius: 8px; font-size: 1.05rem; 
    font-weight: 700; cursor: pointer; margin-top: 15px; transition: background-color 0.2s;
}
button:hover { background-color: var(--primary-hover); }
.link-btn { background: none; border: none; color: var(--primary-color); font-size: 0.95rem; text-decoration: none; padding: 10px; width: auto; font-weight:600; }
.link-btn:hover { text-decoration: underline; background:none; }
.action-buttons { display: flex; justify-content: center; gap: 10px; margin-top: 15px; }
.reset-btn { background: var(--input-bg); border: 1px solid var(--input-border); color: var(--text-color); padding: 10px 16px; border-radius: 6px; font-size: 0.9rem; cursor: pointer; width: auto; margin: 0; font-weight:600; }
.reset-btn:hover { background-color: rgba(0,0,0,0.05); }
.delete-btn:hover { background-color: #ffe6e6 !important; border-color: #d32f2f !important; color:#d32f2f; }
.small-btn { background-color: #6c757d; color: white; padding: 8px 14px; font-size: 0.85rem; width: auto; margin-top: 8px; border-radius: 6px; }

/* RESULTAT & TABELL (FIXAD LAYOUT) */
.result-box { 
    padding: 1.5rem; background-color: var(--result-bg); 
    border-radius: 12px; border: 1px solid var(--input-border); 
    display: flex; flex-direction: column;
}
.result-title { font-size: 1.1rem; color: var(--text-color); text-align: center; margin-bottom: 5px; }
.result-value { text-align: center; font-size: 2.2rem; font-weight: 800; color: var(--heading-color); margin-bottom: 1.5rem; line-height: 1.2; }
#emptyState { text-align:center; padding:50px; opacity:0.6; font-style:italic; }

/* NYA STABILA SAMMANFATTNINGEN */
.result-summary { 
    display: flex; flex-direction: column; gap: 20px; margin-bottom: 25px; 
}
.summary-row {
    display: flex; justify-content: center; gap: 25px; flex-wrap: wrap; 
}
.summary-divider { width: 100%; height: 1px; background-color: #ccc; opacity: 0.5; }
.details { min-width: 130px; text-align: center; }
.details span { display: block; }

/* GRAF & TABELL */
.tab-container { display: flex; gap: 5px; margin-bottom: 15px; border-bottom: 2px solid var(--input-border); padding-bottom: 10px; align-items: center; overflow-x: auto; }
.tab-btn { background: none; border: none; font-size: 0.95rem; font-weight: 600; color: var(--tab-inactive); padding: 8px 16px; width: auto; margin:0; white-space: nowrap; }
.tab-btn.active { color: var(--primary-color); background-color: rgba(0,123,255,0.1); border-radius: 6px; }
.export-btn { margin-left: auto; background-color: #28a745; padding: 6px 12px; font-size: 0.85rem; width: auto; color: white; border-radius: 6px; }

/* DEN VIKTIGA GRAF-FIXEN */
.chart-container { position: relative; height: 300px; width: 100%; min-width: 0; }

.table-wrapper { max-height: 400px; overflow-y: auto; overflow-x: auto; border: 1px solid var(--input-border); background: var(--input-bg); border-radius:6px; }
#resultatTabell { width: 100%; border-collapse: collapse; font-size: 0.85rem; color: var(--text-color); min-width: 350px; }
#resultatTabell th { background-color: var(--result-bg); position: sticky; top: 0; padding: 12px; text-align: right; border-bottom: 2px solid var(--input-border); z-index: 10; color: var(--heading-color); }
#resultatTabell td { padding: 10px 12px; border-bottom: 1px solid var(--input-border); text-align: right; }

/* INFO SEKTIONER */
.info-section {
    max-width: 800px; margin: 40px auto; padding: 40px;
    background: var(--section-bg); border-radius: 12px;
    border: 1px solid var(--input-border); box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}
.info-section h3 { margin-top: 0; color: var(--heading-color); font-size: 1.6rem; margin-bottom: 20px; }
.info-section h4 { color: var(--heading-color); margin-top: 25px; margin-bottom: 10px; font-size: 1.1rem; }
.info-section p, .info-section li { line-height: 1.6; color: var(--text-color); margin-bottom: 15px; }
.disclaimer { font-size: 0.9rem; color: #666; background: rgba(0,0,0,0.03); padding: 10px; border-radius: 4px; border-left: 3px solid #ccc; margin-bottom: 20px; }
.contact-text { margin-top:20px; font-style:italic; font-size:0.9rem; }

/* MODAL */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background-color: rgba(0,0,0,0.5); z-index: 1000; 
    display: flex; justify-content: center; align-items: center; 
    backdrop-filter: blur(3px); padding: 10px; box-sizing: border-box;
}
.modal-content { 
    background-color: var(--modal-bg); color: var(--text-color); 
    width: 100%; max-width: 550px; max-height: 90vh; 
    border-radius: 12px; display: flex; flex-direction: column; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.3); animation: fadeIn 0.2s ease-out;
}
@media (max-width: 600px) {
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-content { height: 100%; max-height: 100%; border-radius: 0; }
}
.modal-header { padding: 15px 20px; border-bottom: 1px solid var(--modal-header-border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; overflow-y: auto; background-color: var(--modal-bg); -webkit-overflow-scrolling: touch; }
.modal-footer { padding: 15px 20px; border-top: 1px solid var(--modal-header-border); text-align: right; background-color: var(--result-bg); }
.close-btn { font-size: 2rem; cursor: pointer; color: #aaa; padding: 0 10px; line-height: 1; }

/* MODAL DETALJER */
.section-box { margin-bottom: 20px; border: 1px solid var(--input-border); padding: 15px; border-radius: 8px; background-color: var(--section-bg); }
.section-title { font-weight: bold; margin-bottom: 12px; color: var(--heading-color); font-size: 0.95rem; border-bottom: 1px solid var(--input-border); padding-bottom: 8px; display:flex; align-items:center; }
.spar-rad, .engangs-rad { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; background: var(--input-bg); padding: 8px; border: 1px solid var(--input-border); border-left: 3px solid var(--primary-color); border-radius: 6px; }
.spar-rad span { font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.mini-input { width: 60px !important; padding: 8px !important; text-align: center; }
.spar-belopp { flex-grow: 1; padding: 8px !important; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; margin-left: auto; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .3s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 22px; width: 22px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(22px); }
.dold { display: none !important; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* TOOLTIPS */
.help-icon { display: inline-flex; justify-content: center; align-items: center; width: 20px; height: 20px; background-color: #e0e0e0; color: #555; border-radius: 50%; font-size: 12px; font-weight: bold; margin-left: 8px; cursor: help; position: relative; }
.help-icon .tooltip-text { visibility: hidden; width: 220px; background-color: #333; color: #fff; text-align: center; border-radius: 6px; padding: 10px; font-size: 0.8rem; font-weight: normal; line-height: 1.4; position: absolute; z-index: 1001; bottom: 135%; left: 50%; margin-left: -110px; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.help-icon .tooltip-text::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px; border-width: 5px; border-style: solid; border-color: #333 transparent transparent transparent; }
.help-icon:hover .tooltip-text { visibility: visible; opacity: 1; }