:root {
    --primary-blue: #1a73e8;
    --dark-grey: #455a64;
    --light-grey: #f8f9fa;
    --border-color: #dadce0;
    --text-main: #3c4043;
    --white: #ffffff;
    --status-green: #34a853;
    --route-grey: #78909c;
}

/* --- GRUNDLAYOUT --- */
body, html {
    margin: 0;
    padding: 0;
    height: 100dvh; 
    width: 100%;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--text-main);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* --- FAST TOPPRUBRIK --- */
.top-header {
    width: 100%;
    height: 70px;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    z-index: 1001;
    flex-shrink: 0; 
}

.header-text-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.app-title {
    margin: 0;
    font-size: 20px;
    color: var(--primary-blue);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    line-height: 1.2;
}

.app-subtitle {
    font-size: 11px;
    color: var(--dark-grey);
    font-weight: 500;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.info-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color);
    background: transparent;
    color: var(--dark-grey);
    font-family: serif;
    font-style: italic;
    font-weight: bold;
    cursor: pointer;
    margin-right: 15px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.info-button:hover {
    background: var(--light-grey);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

/* --- MODAL (POPUP) --- */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--white);
    margin: 15% auto; 
    padding: 25px;
    border-radius: 15px;
    width: 85%; 
    max-width: 400px;
    text-align: left; /* Ändrad till vänsterställning */
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: modalSlideDown 0.3s ease-out;
}

.modal-content h2 {
    text-align: center; /* Rubriken förblir centrerad */
    margin-top: 10px;
    margin-bottom: 20px;
}

.modal-content ul {
    padding-left: 20px; /* Indrag för att punkterna ska synas bra */
    margin-bottom: 20px;
}

.modal-content p {
    line-height: 1.5;
    margin-bottom: 15px;
}

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

.close-modal {
    position: absolute;
    right: 15px;
    top: 10px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

/* --- KARTAN --- */
#map {
    flex-grow: 1;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* --- BOTTPANEL (SIDEBAR) --- */
#sidebar {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    background: var(--white);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 25px rgba(0,0,0,0.15);
    border-radius: 20px 20px 0 0;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 85vh;
}

#sidebar.collapsed {
    max-height: 75px;
}

.panel-header {
    padding: 12px 20px 18px 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--white);
    border-radius: 20px 20px 0 0;
}

.drag-handle {
    width: 40px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    margin-bottom: 12px;
}

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

#menuToggle {
    background: var(--light-grey);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    color: var(--primary-blue);
    border: 1px solid var(--border-color);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 30px 20px;
    -webkit-overflow-scrolling: touch;
}

/* --- SEKTIONER --- */
.section {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.section-header {
    background: var(--light-grey);
    padding: 14px 18px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.section-body {
    padding: 18px;
    display: none;
}

.section.expanded .section-body {
    display: block;
}

/* --- INPUTS & SLIDER --- */
.input-group {
    position: relative;
    margin-bottom: 12px;
}

input[type="text"] {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-sizing: border-box;
    font-size: 15px;
    outline: none;
}

/* Slider-container med luft och full bredd */
.buffer-control {
    margin-top: 10px;
    margin-bottom: 25px; /* Marginal mot knappen under */
}

.buffer-control label {
    display: block;
    margin-bottom: 15px;
    font-size: 15px;
}

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

.buffer-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-blue);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.autocomplete-items {
    position: absolute;
    top: 100%; 
    left: 0;
    right: 0;
    background: white;
    z-index: 2000;
    border: 1px solid var(--border-color);
    border-radius: 0 0 10px 10px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--light-grey);
}

/* --- KNAPPAR --- */
.btn-primary { 
    background: var(--primary-blue); 
    color: white; 
    width: 100%; 
    padding: 15px; 
    border: none; 
    border-radius: 10px; 
    font-weight: 700; 
    cursor: pointer;
}

.btn-search { 
    background: var(--dark-grey); 
    color: white; 
    width: 100%; 
    padding: 15px; 
    border: none; 
    border-radius: 12px; /* Mjukare hörn enligt bild */
    cursor: pointer;
    font-weight: 700;
    font-size: 15px;
}

/* --- STATUS-PRICK & LEAFLET --- */
#routeStatusDot {
    width: 10px;
    height: 10px;
    background: #dadce0;
    border-radius: 50%;
    transition: all 0.3s ease;
}

#routeStatusDot.active {
    background: var(--status-green);
    box-shadow: 0 0 10px rgba(52, 168, 83, 0.6);
}

.leaflet-top { margin-top: 15px !important; }
.leaflet-bottom { bottom: 85px !important; }

/* --- MOBILANPASSNING --- */
@media (max-width: 480px) {
    #sidebar { max-width: 100%; border-radius: 20px 20px 0 0; }
    .app-title { font-size: 18px; }
    .app-subtitle { font-size: 10px; }
}
