/* ==========================================================================
   1. VARIABLE & GLOBAL DESIGN
   ========================================================================== */
:root {
    --broken-white: #F7F4EF;
    --buttercream: #F6E4C1;
    --race-green: #094027;   /* Hijau Utama Resmi */
    --race-orange: #FF6600;  /* Oranye Utama Resmi */
    --dark-slate: #2C3E50;
}

body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--broken-white);
    overflow: hidden;
}

#app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ==========================================================================
   2. SIDEBAR PANEL (DESKTOP DEFAULT)
   ========================================================================== */
#sidebar {
    width: 460px;
    min-width: 460px;
    height: 100%;
    background-color: white;
    box-shadow: 4px 0 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    box-sizing: border-box;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#sidebar.sidebar-minimized {
    width: 0px;
    min-width: 0px;
    padding: 0px;
    margin: 0px;
    border: none;
}

#header-brand {
    padding: 15px 20px; 
    background-color: var(--race-green);
    color: var(--broken-white); 
    display: flex;
    align-items: center; 
    justify-content: space-between;
    margin: -20px -20px 0 -20px; /* Reset padding sidebar khusus header */
}

.logo-container { display: flex; align-items: center; gap: 10px; }
.logo-img { width: 42px; height: 42px; object-fit: cover; }
.logo-text { font-size: 20px; font-weight: bold; color: white; letter-spacing: 0.5px; }
.logo-text span { color: var(--race-orange); }

/* FORM & INTERFACE INSIDE SIDEBAR */
.sidebar-section {
    width: 100%;
    box-sizing: border-box;
}

.panel-title { 
    font-size: 16px; 
    font-weight: bold; 
    color: var(--dark-slate); 
    margin-bottom: 12px; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.form-group { margin-bottom: 12px; text-align: left; }
.form-group label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 4px; color: #7f8c8d; }

#sidebar input[type="email"],
#sidebar input[type="text"],
#sidebar input[type="file"],
.form-control { 
    width: 100% !important; 
    padding: 10px; 
    border: 1px solid #ccc; 
    border-radius: 6px; 
    box-sizing: border-box; 
    display: block;
}

#sidebar button.btn-login,
.btn-primary { 
    background-color: var(--race-orange); 
    color: white; 
    border: none; 
    padding: 12px 15px; 
    border-radius: 6px; 
    font-weight: bold; 
    cursor: pointer; 
    width: 100% !important; 
    display: block;
    box-sizing: border-box;
    transition: background 0.2s;
}

#sidebar button.btn-login:hover,
.btn-primary:hover {
    background-color: #e05500;
}

/* ==========================================================================
   3. LIVE LEADERBOARD TABLE
   ========================================================================== */
.leaderboard-table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 13px; 
    table-layout: fixed; /* Memaksa kolom patuh pada lebar pembagian */
    margin-top: 10px;
}

.leaderboard-table th { 
    background-color: #f8f9fa; 
    padding: 8px; 
    text-align: left; 
    color: #7f8c8d; 
}

.leaderboard-table td { 
    padding: 10px 8px; 
    border-bottom: 1px solid #eef2f3; 
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-badge { background: #f1f1f1; padding: 2px 6px; border-radius: 4px; font-weight: bold; }
.rank-1 { background: gold; color: black; }
.gap-text { font-size: 11px; color: #e74c3c; font-weight: bold; display: block; }

/* ==========================================================================
   4. MAIN DISPLAY (MAP & CONTROLS)
   ========================================================================== */
#main-display {
    flex: 1; height: 100%;
    display: flex; flex-direction: column;
}

#map { flex: 1; position: relative; }

#elevation-panel {
    height: 180px;
    background: white;
    border-top: 2px solid #eee;
    padding: 10px 20px;
    box-sizing: border-box;
}

#live-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* BUTTON FLOATING TOGGLE SIDEBAR */
#btn-toggle-floating {
    position: absolute;
    left: 470px; /* Posisi default mengikuti lebar sidebar terbuka (460px + 10px) */
    top: 20px;
    z-index: 9999;
    background-color: var(--race-green);
    color: #ffffff;
    border: 2px solid #ffffff;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-toggle-floating:hover {
    background-color: var(--race-orange);
    transform: scale(1.05);
}

/* LEAFLET CONTROLS TUNING */
.leaflet-left .leaflet-control {
    margin-left: 65px !important; /* Geser tombol zoom agar tidak tertabrak tombol toggle */
}

.leaflet-top.leaflet-right .leaflet-custom-control {
    margin-top: 10px !important; /* Jarak aman tombol lokasi saya */
}

.leaflet-custom-control {
    background: #ffffff;
    border: 2px solid rgba(0,0,0,0.2) !important;
    border-radius: 4px;
    box-sizing: border-box;
}

.leaflet-custom-control button:hover {
    background-color: #f4f4f4 !important;
}

.leaflet-control-layers {
    border: 2px solid rgba(0,0,0,0.2) !important;
    border-radius: 8px !important;
    font-family: inherit;
    font-weight: bold;
    color: #1e272c;
}

/* ==========================================================================
   5. RESPONSIVE MEDIA QUERY (MOBILE SCREEN MODE)
   ========================================================================== */
@media screen and (max-width: 767px) {
    #sidebar {
        width: 85vw;
        min-width: 85vw;
        position: absolute;
        left: 0;
        top: 0;
        z-index: 10000; /* Pastikan berdiri di atas Leaflet map */
    }

    #sidebar.sidebar-minimized {
        width: 0px;
        min-width: 0px;
        left: -85vw;
    }
/* Posisi Tombol saat Sidebar Terbuka di HP */
    #btn-toggle-floating {
        left: calc(85vw + 10px) !important;
        top: 15px;
        padding: 10px 12px;
    }

    /* Posisi Tombol saat Sidebar Sembunyi di HP */
    #sidebar.sidebar-minimized + #btn-toggle-floating {
        left: 15px !important;
    }

    .leaflet-top.leaflet-left {
        top: 70px !important; /* Turunkan tombol zoom di HP agar tidak tertindih */
    }
    
    .leaflet-left .leaflet-control {
        margin-left: 15px !important;
    }
    
    .leaderboard-table th, 
    .leaderboard-table td {
        padding: 8px 4px;
        font-size: 12px;
    }
}

/* Gaya Tombol Registrasi EO Baru (Halaman Index) */
.link-register-host {
    display: block;
    text-align: center;
    margin-top: 12px;
    padding: 10px;
    border: 2px solid var(--race-green);
    color: var(--race-green) !important;
    text-decoration: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 13px;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.link-register-host:hover {
    background-color: var(--race-green);
    color: white !important;
}