/* -------------------------------------------------------------
 * CORE DESIGN SYSTEM & STYLING
 * Project: Kích Bình Gần Nhất (Nearest Battery Rescue)
 * ------------------------------------------------------------- */

:root {
    --bg-primary: #0a0f1d;
    --bg-secondary: #13192b;
    --bg-card: rgba(26, 34, 56, 0.6);
    --bg-card-hover: rgba(35, 46, 75, 0.85);
    
    --accent-color: #00d2ff;
    --accent-hover: #00a8cc;
    --accent-glow: rgba(0, 210, 255, 0.25);
    
    --battery-color: #ff9f1c;
    --battery-glow: rgba(255, 159, 28, 0.35);
    
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(0, 210, 255, 0.3);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 15px var(--accent-glow);
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --sidebar-width: 420px;
}

/* Reset & Scrollbar overrides */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #232e4b;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

/* Base Flex Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
}

/* -------------------------------------------------------------
 * SIDEBAR SECTION
 * ------------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    flex-shrink: 0;
    position: relative;
}

.app-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(19, 25, 43, 1) 0%, rgba(10, 15, 29, 0.4) 100%);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon-wrapper {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--battery-color) 0%, #f77f00 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    font-size: 24px;
    box-shadow: 0 0 20px var(--battery-glow);
}

.battery-pulse {
    animation: batteryCharge 2s infinite ease-in-out;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
}

.tagline {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--battery-color);
    margin-top: 2px;
    text-transform: uppercase;
}

/* Control Panel Scrollable Container */
.control-panel {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Status Badge Styles */
.status-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.gps-detecting {
    background-color: rgba(0, 210, 255, 0.06);
    border-color: rgba(0, 210, 255, 0.15);
    color: var(--accent-color);
}
.gps-detecting .status-dot {
    background-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
    animation: pulseGlow 1.5s infinite alternate;
}

.gps-active {
    background-color: rgba(46, 196, 182, 0.06);
    border-color: rgba(46, 196, 182, 0.15);
    color: #2ec4b6;
}
.gps-active .status-dot {
    background-color: #2ec4b6;
    box-shadow: 0 0 10px #2ec4b6;
}

.gps-disabled {
    background-color: rgba(255, 159, 28, 0.06);
    border-color: rgba(255, 159, 28, 0.15);
    color: var(--battery-color);
}
.gps-disabled .status-dot {
    background-color: var(--battery-color);
    box-shadow: 0 0 10px var(--battery-color);
}

/* -------------------------------------------------------------
 * GLASSMORPHIC SELECT FILTERS
 * ------------------------------------------------------------- */
.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
}

.form-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.card-header i {
    font-size: 18px;
    color: var(--accent-color);
}

.card-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 16px;
    font-weight: 600;
}

.card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
    width: 100%;
}

select {
    width: 100%;
    background-color: #1a2238;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 40px 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: var(--transition-smooth);
}

select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.15);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: rgba(26, 34, 56, 0.4);
}

.select-chevron {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-secondary);
    font-size: 12px;
    transition: var(--transition-smooth);
}

select:focus + .select-chevron {
    color: var(--accent-color);
    transform: translateY(-50%) rotate(180deg);
}

/* Banners */
.info-banner {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 15px;
    border: 1px solid transparent;
}

.info-banner.warning {
    background-color: rgba(231, 29, 54, 0.08);
    border-color: rgba(231, 29, 54, 0.2);
}

.info-banner.warning h4 {
    color: #ff5e62;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.info-banner.warning p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.info-banner.warning .banner-icon {
    font-size: 18px;
    color: #ff5e62;
    margin-top: 2px;
}

/* -------------------------------------------------------------
 * RESULTS SECTION
 * ------------------------------------------------------------- */
.results-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.results-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.result-count {
    font-size: 12px;
    background-color: #1a2238;
    color: var(--accent-color);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.shop-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* -------------------------------------------------------------
 * PREMIUM SHOP CARD STYLES
 * ------------------------------------------------------------- */
.shop-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.shop-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transition: var(--transition-smooth);
}

.shop-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.shop-card:hover::before {
    background: var(--accent-color);
}

.shop-card.active {
    background: rgba(0, 210, 255, 0.05);
    border-color: var(--accent-color);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.1);
}

.shop-card.active::before {
    background: var(--accent-color);
}

.shop-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.shop-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    transition: var(--transition-smooth);
}

.shop-card:hover .shop-name {
    color: var(--accent-color);
}

/* Distances / Badges */
.distance-badge {
    background-color: rgba(0, 210, 255, 0.12);
    color: var(--accent-color);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    border: 1px solid rgba(0, 210, 255, 0.2);
}

.kich-binh-badge {
    background-color: rgba(255, 159, 28, 0.12);
    color: var(--battery-color);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 159, 28, 0.25);
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.shop-info-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.shop-info-row i {
    color: var(--text-muted);
    font-size: 14px;
    width: 16px;
    text-align: center;
    margin-top: 2px;
}

.shop-info-row span.address-text {
    flex: 1;
}

/* Ratings */
.rating-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.stars-list {
    display: flex;
    gap: 2px;
    color: #e9c46a;
}

.stars-list i {
    font-size: 12px;
}

.reviews-count {
    color: var(--text-muted);
}

/* Action Buttons */
.shop-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    outline: none;
    transition: var(--transition-smooth);
}

.btn-call {
    background-color: #2ec4b6;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(46, 196, 182, 0.2);
}
.btn-call:hover {
    background-color: #24a195;
    box-shadow: 0 6px 18px rgba(46, 196, 182, 0.35);
}

.btn-map {
    background-color: #1a2238;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}
.btn-map:hover {
    background-color: rgba(35, 46, 75, 0.4);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.btn-accent {
    background-color: var(--accent-color);
    color: var(--bg-primary);
    box-shadow: 0 4px 12px var(--accent-glow);
}
.btn-accent:hover {
    background-color: var(--accent-hover);
    color: var(--bg-primary);
    box-shadow: 0 6px 18px rgba(0, 210, 255, 0.4);
}

/* Empty / No Shops Banner */
.empty-state {
    padding: 40px 20px;
    text-align: center;
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.empty-state i {
    font-size: 36px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 14px;
    line-height: 1.5;
}

/* -------------------------------------------------------------
 * SKELETON / LOADING EFFECTS
 * ------------------------------------------------------------- */
.skeleton-card {
    height: 130px;
    background: linear-gradient(90deg, #13192b 25%, #1b233c 50%, #13192b 75%);
    background-size: 200% 100%;
    animation: loadingShimmer 1.5s infinite;
    border-radius: 16px;
    border: 1px solid var(--border-color);
}

/* Animations */
@keyframes loadingShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes pulseGlow {
    0% { transform: scale(0.9); opacity: 0.6; }
    100% { transform: scale(1.1); opacity: 1; }
}

@keyframes batteryCharge {
    0% { transform: translateY(0); opacity: 0.9; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: translateY(0); opacity: 0.9; }
}

/* -------------------------------------------------------------
 * MAP VIEWPORT STYLES
 * ------------------------------------------------------------- */
.map-view {
    flex: 1;
    height: 100%;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    background-color: var(--bg-primary);
}

/* Map Action Buttons */
.map-action-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.map-action-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    box-shadow: var(--shadow-glow);
    transform: scale(1.05);
}

/* Dark mode overrides for standard Leaflet tiles */
.leaflet-container {
    background: var(--bg-primary) !important;
}

.leaflet-tile {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-bar a {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: var(--transition-smooth);
}

.leaflet-bar a:hover {
    color: var(--accent-color) !important;
    background-color: #1a2238 !important;
}

/* Leaflet Popup Premium Styles */
.leaflet-popup-content-wrapper {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    padding: 0px !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-popup-content {
    margin: 12px 16px !important;
}

.leaflet-popup-tip {
    background-color: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-popup-close-button {
    color: var(--text-secondary) !important;
    top: 6px !important;
    right: 6px !important;
    font-size: 16px !important;
}

.leaflet-popup-close-button:hover {
    color: var(--accent-color) !important;
}

.map-popup-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 220px;
}

.map-popup-card p,
.map-popup-card h5 {
    margin: 0 !important;
    padding: 0 !important;
}

.map-popup-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 14px;
}

.map-popup-phone {
    font-weight: 600;
    color: var(--accent-color);
}

.map-popup-btn {
    margin-top: 4px;
    background-color: var(--accent-color);
    color: var(--bg-primary);
    text-align: center;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 700;
    text-decoration: none;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition-smooth);
    display: inline-block;
}

.map-popup-btn:hover {
    background-color: var(--accent-hover);
}

/* Custom pulsing map marker for user position */
.user-location-marker {
    background: none;
    border: none;
}

.user-gps-dot {
    width: 18px;
    height: 18px;
    background-color: var(--accent-color);
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.8);
    position: relative;
}

.user-gps-dot::before {
    content: '';
    position: absolute;
    width: 38px;
    height: 38px;
    border: 2px solid var(--accent-color);
    border-radius: 50%;
    top: -10px;
    left: -10px;
    animation: gpsPulse 1.8s infinite ease-out;
    opacity: 0;
}

@keyframes gpsPulse {
    0% { transform: scale(0.4); opacity: 0.8; }
    100% { transform: scale(1.3); opacity: 0; }
}

/* App Footer spacing */
.app-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    text-align: center;
    color: var(--text-muted);
    background-color: rgba(19, 25, 43, 0.5);
}

.app-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.app-footer a:hover {
    color: var(--accent-color);
}

/* Utility visibility classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------
 * MOBILE RESPONSIVE ADAPTATIONS
 * ------------------------------------------------------------- */
@media (max-width: 992px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 60vh; /* Sidebar takes bottom half of page on mobile */
        order: 2;
        border-right: none;
        border-top: 1px solid var(--border-color);
    }
    
    .map-view {
        height: 40vh; /* Map takes top 40% on mobile */
        order: 1;
    }
    
    .map-action-btn {
        bottom: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
    }
}
