/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --accent-orange: #FF8C00;
    --accent-orange-light: #FFA740;
    --accent-orange-dark: #cc7000;
    --bg-main: #F0F2F5; /* สำหรับ Neumorphism Base */
    --text-main: #1F2937;
    --text-muted: #6B7280;
    
    --shadow-light: #ffffff;
    --shadow-dark: #d1d5db;
    
    /* ควบคุมความสูงบนมือถือ (รองรับ Notch) */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    
    --header-height: 60px;
    --bottom-nav-height: 55px;
}

body {
    font-family: 'Prompt', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 16px; 
    overflow: hidden; /* Default: Map page doesn't scroll */
}

/* Class for pages that SHOULD scroll (Data, Report, Admin) */
.scroll-page {
    overflow-y: auto !important;
    height: auto !important;
}
.scroll-page body {
    overflow-y: auto !important;
    height: auto !important;
}

/* ---------------------------
   Glass & Neumorphism Utility
--------------------------- */
.glass-effect, .glass-header, .glass-sheet {
    background: #FFFFFF !important;
    border-bottom: 1px solid #E5E7EB;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.neumorphic {
    background-color: var(--bg-main);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.neumorphic-inset {
    background-color: var(--bg-main);
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.neumorphic-btn {
    border: none;
    background-color: var(--accent-orange);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
}
.neumorphic-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ---------------------------
   Header (App Top Bar)
--------------------------- */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--header-height) + var(--safe-top));
    padding-top: var(--safe-top);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-left: 15px;
    padding-right: 15px;
    z-index: 1000;
    pointer-events: none; /* Let clicks pass through empty space */
}

.header-left, .header-right {
    pointer-events: auto; /* Buttons inside header should be clickable */
}

.header-center {
    text-align: center;
    flex: 1;
}

.title-main {
    color: var(--text-main);
    font-size: 18px; /* อักษรใหญ่ตามแบบ Mobile First */
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0;
}
.title-sub {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    margin: 0;
}

.profile-btn {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 5px var(--shadow-dark), -2px -2px 5px var(--shadow-light);
    background: var(--bg-main);
}

/* ---------------------------
   Main Map Area
--------------------------- */
.map-wrapper {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: var(--bottom-nav-height);
    background: #e5e3df; /* แบ็คกราวระหวางโหลดแมพ */
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ปุ่ม Zoom ขวาล่าง */
.leaflet-control-zoom {
    margin-bottom: 20px !important;
    margin-right: 15px !important;
    border: none !important;
}
.leaflet-control-zoom a {
    background: var(--bg-main) !important;
    color: var(--text-main) !important;
    width: 44px !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 24px !important;
    border-radius: 8px !important;
    margin-bottom: 8px;
    box-shadow: 4px 4px 10px var(--shadow-dark), -4px -4px 10px var(--shadow-light) !important;
    border: none !important;
}

/* ---------------------------
   Floating Search
--------------------------- */
.floating-search {
    position: absolute;
    top: calc(var(--header-height) + var(--safe-top) + 15px);
    left: 15px; right: 15px;
    height: 50px;
    z-index: 900;
    display: flex;
    align-items: center;
    padding: 0 15px;
    /* removed search box shadow because header is now transparent, maybe the search box needs to pop */
    box-shadow: 0 4px 12px rgba(0,0,0,0.15); /* Slightly darker shadow so it floats distinctly */
    background: white; /* Ensure search box has a solid background */
}
.search-icon {
    width: 20px; height: 20px;
    margin-right: 10px;
}
.input-transparent {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-main);
    outline: none;
}

/* ---------------------------
   Bottom Navigation
--------------------------- */
.bottom-nav {
    position: fixed;
    bottom: 25px; /* ลอยขึ้นจากขอบล่าง */
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 40px);
    max-width: 420px;
    height: 70px; /* สูงขึ้นเพื่อให้กดง่าย */
    background-color: #FFFFFF !important;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1100;
    border-radius: 40px; /* ทรงแคปซูล */
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); /* เงาเข้มขึ้นให้ดูมีมิติ */
    border: 1px solid #E5E7EB;
    padding: 0 12px;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #9CA3AF;
    gap: 4px;
    flex: 1;
    height: 100%;
    border-radius: 30px;
    transition: all 0.2s;
}
.nav-item:active {
    background: #F9FAFB;
}
.nav-item.active {
    color: var(--accent-orange);
}
.nav-item span {
    font-size: 12px;
    font-weight: 600;
}
.nav-icon {
    width: 24px; height: 24px;
}

/* Styling for middle prominent button - REMOVED for Single Plane Layout */
.nav-item-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}
.btn-orange-circle {
    width: 24px;   /* Match normal nav-icon */
    height: 24px;
    background-color: transparent !important;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    box-shadow: none !important;
    margin-bottom: 4px;
}
.btn-orange-circle svg {
    width: 24px;
    height: 24px;
}
.center-label {
    font-size: 12px;
    font-weight: 600;
    color: inherit;
}


/* ---------------------------
   Bottom Sheet (Card ปั๊มน้ำมัน)
--------------------------- */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0; right: 0;
    background: var(--bg-main);
    border-radius: 24px 24px 0 0;
    padding: 0 20px 20px 20px;
    z-index: 1500; /* Higher than Bottom Nav (1100) */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.25);
    box-shadow: 0 -8px 32px rgba(0,0,0,0.15); /* Soft deep shadow on top */
}
.bottom-sheet.closed {
    transform: translateY(100%); /* ซ่อนหายไปเลยเวลาปิด */
}

/* เปลี่ยนจาก Glassmorphic เป็นสีทึบ */
.glass-sheet {
    background: var(--bg-main);
}

.sheet-handle {
    width: 40px;
    height: 5px;
    background-color: #cbd5e1;
    border-radius: 3px;
    margin: 12px auto 15px auto;
}

/* ข้อมูลภายใน Card */
.station-header {
    margin-bottom: 20px;
}
.station-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 8px;
}
.station-meta {
    display: flex;
    gap: 10px;
}
.meta-tag {
    font-size: 12px;
    padding: 6px 12px;
    color: var(--text-muted);
}

/* การจัดวางกรอบน้ำมัน */
.fuel-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}
.fuel-card {
    padding: 15px;
    text-align: center;
}
.fuel-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.fuel-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
}
.badge-green { background-color: rgba(16, 185, 129, 0.15); color: #059669; }
.badge-yellow { background-color: rgba(245, 158, 11, 0.15); color: #D97706; }
.badge-red { background-color: rgba(239, 68, 68, 0.15); color: #DC2626; }
.badge-gray { background-color: rgba(156, 163, 175, 0.15); color: #4B5563; }

/* ปุ่มรายงานสีส้ม Neumorphic */
.btn-primary-orange {
    width: 100%;
    min-height: 56px;
    background-color: var(--accent-orange);
    color: white;
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    /* แสงเงาสำหรับปุ่มสีส้ม */
    box-shadow: 4px 4px 10px rgba(255, 140, 0, 0.3), -4px -4px 10px rgba(255, 255, 255, 0.8);
}
.btn-primary-orange:active {
    box-shadow: inset 4px 4px 8px rgba(204, 112, 0, 0.5), inset -4px -4px 8px rgba(255, 167, 64, 0.8);
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.5); /* This is just an overlay, it's fine. But wait, I'll keep it */
}
.modal-content {
    background-color: var(--bg-main);
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1); /* flat shadow instead of neumorphic */
}
.close-modal {
    position: absolute;
    top: 15px; right: 20px;
    font-size: 30px;
    color: var(--text-muted);
    cursor: pointer;
}

.hidden { display: none !important; }

/* ---------------------------
   Report Buttons specific
--------------------------- */
.btn-report {
    width: 100%;
    min-height: 50px;
    border-radius: 8px;
    border: none;
    font-size: 16px;
    font-weight: bold;
    color: white;
    margin-bottom: 15px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.btn-green { background-color: #10B981; }
.btn-yellow { background-color: #F59E0B; color: #fff; }
.btn-red { background-color: #EF4444; }

/* ---------------------------
   Report Bottom Sheet & Grouping UX
--------------------------- */
.report-bottom-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    max-height: 85vh;
    background: var(--bg-main);
    border-radius: 12px 12px 0 0;
    padding: 0 20px 20px 20px;
    z-index: 2500;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1);
    overflow-y: auto;
}
.report-bottom-sheet.open {
    transform: translateY(0);
}

.report-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2400;
    display: none;
}
.report-overlay.open {
    display: block;
}

.fuel-report-group {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.fuel-report-header {
    font-size: 15px;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 12px;
}

/* ขยับปุ่ม Zoom และ Locate Me ขึ้นจากขอบล่าง */
.leaflet-bottom.leaflet-right {
    margin-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 20px) !important;
}
.report-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.btn-status-select {
    flex: 1;
    min-width: 70px;
    padding: 8px 4px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.btn-status-select.selected {
    border-width: 2px;
    color: #fff;
    transform: scale(1.02);
}
.btn-status-select.selected[data-status="Available"] { background: #10B981; border-color: #059669; }
.btn-status-select.selected[data-status="Limited"] { background: #F59E0B; border-color: #D97706; }
.btn-status-select.selected[data-status="Out of stock"] { background: #EF4444; border-color: #DC2626; }
.btn-status-select.selected[data-status="Unknown"] { background: #9CA3AF; border-color: #4B5563; }

.btn-confirm-report {
    width: 100%;
    padding: 15px;
    background-color: var(--accent-orange);
    color: white;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    margin-top: 15px;
    box-shadow: 0 4px 12px rgba(255,140,0,0.3);
    cursor: pointer;
}
.btn-confirm-report:active {
    transform: translateY(2px);
    box-shadow: 0 2px 6px rgba(255,140,0,0.3);
}

/* =========================================
   Data Tab (ข้อมูล) Custom Styles
   ========================================= */

.data-container {
    padding: 20px 15px;
    padding-bottom: 120px; /* เผื่อ Bottom Nav 80px + margin */
    padding-top: calc(var(--header-height) + var(--safe-top) + 20px);
    max-width: 600px;
    margin: 0 auto;
}

/* 1. Profile Section */
.data-profile-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    position: relative;
}
.data-profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #FFF3E0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 2px solid var(--accent-orange);
    overflow: hidden;
}
.data-profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.data-profile-info {
    flex: 1;
    min-width: 0; /* ช่วยให้การเว้นบรรทัดหรือจุดไข่ปลาทำงานได้ใน flex */
}
.data-profile-name {
    font-size: 18px; /* ลดลงนิดนึงเผื่อชื่อยาว */
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-profile-stats {
    color: var(--accent-orange);
    font-size: 13px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-btn-logout {
    background: #F3F4F6;
    color: #4B5563;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0; /* ไม่ให้ปุ่มถูกบีบ */
}

/* 2. Crisis Dashboard */
.data-section-mt { margin-top: 30px; }
.data-section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.data-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}
.data-stat-card {
    border-radius: 12px;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    border: 1px solid rgba(0,0,0,0.02);
    transition: transform 0.2s;
}
.data-stat-card.green {
    background-color: #ECFDF5;
    border-color: #D1FAE5;
}
.data-stat-card.red {
    background-color: #FEF2F2;
    border-color: #FEE2E2;
}
.data-stat-title {
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}
.data-stat-card.green .data-stat-title { color: #059669; }
.data-stat-card.red .data-stat-title { color: #DC2626; }

.data-stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
}
.data-stat-card.green .data-stat-value { color: #047857; }
.data-stat-card.red .data-stat-value { color: #B91C1C; }

/* 3. List View */
.data-filter-btn {
    background: #F3F4F6;
    color: #4B5563;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.data-station-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.data-list-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 1px solid rgba(0,0,0,0.02);
}
.data-list-card:active {
    transform: scale(0.98);
}
.data-list-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.data-list-station-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    max-width: 75%;
}
.data-list-station-dist {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-orange);
    white-space: nowrap;
}

.data-pill-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.data-status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    color: #4B5563;
}
.data-status-pill.avail { color: #059669; border-color: #10B981; background: #ECFDF5; }
.data-status-pill.limit { color: #D97706; border-color: #F59E0B; background: #FFFBEB; }
.data-status-pill.out { color: #DC2626; border-color: #EF4444; background: #FEF2F2; }

/* 4. About Modal & Info Button */
.btn-info-floating {
    position: absolute;
    left: 15px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: var(--accent-orange);
    transition: all 0.2s;
    outline: none;
}
.btn-info-floating:active {
    transform: scale(0.95);
    background: #f9fafb;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000; /* Higher than map controls and bottom sheet */
}

.about-modal {
    position: relative;
    width: 92%;
    max-width: 500px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    animation: modal-slide-up 0.3s ease-out;
}

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

.about-body {
    padding: 10px 24px 24px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.about-footer-sticky {
    padding: 15px 24px;
    background: white;
    border-top: 1px solid #f3f4f6;
    display: flex;
    justify-content: center;
}

.about-section {
    margin-bottom: 20px;
}
.about-section h3 {
    font-weight: 700;
    margin-top: 0;
}

/* Floating Guide Button */
.btn-guide-floating {
    position: absolute;
    top: calc(var(--header-height) + var(--safe-top) + 75px);
    right: 15px;
    z-index: 900;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-orange);
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: all 0.2s;
    border: 1px solid #f3f4f6;
}
.btn-guide-floating:active {
    transform: scale(0.95);
}
@media (max-width: 360px) {
    .guide-text { display: none; }
    .btn-guide-floating { padding: 8px; border-radius: 50%; width: 36px; height: 36px; justify-content: center; }
}

