/* Variables globales */
:root {
    --bg-dark: #1a1a2e;
    --bg-darker: #16213e;
    --accent: #e94560;
    --text: #ffffff;
    --text-muted: #b0b0b0;
    --border: #2d3561;
}

/* Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
}

body {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    font-family: 'Courier New', 'Courier', monospace;
    background-color: var(--bg-dark);
    color: var(--text);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

/* ===== HEADER ===== */
.app-header {
    background-color: var(--bg-darker);
    border-bottom: 2px solid var(--accent);
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    gap: 1rem;
    width: 100%;
}

.sidebar-toggle-mobile {
    display: none;
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--accent);
    margin: 0;
}

.header-info {
    display: flex;
    gap: 2rem;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.location-info, .update-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.location-info::before {
    content: "📍";
}

.update-info::before {
    content: "🔄";
}

.header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 3px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
}

.header-btn:hover {
    background-color: rgba(233, 69, 96, 0.2);
    transform: scale(1.1);
}

.header-btn:active {
    transform: scale(0.95);
}

/* Container layout */
.container {
    display: flex;
    width: 100%;
    flex: 1;
    min-height: 0;
}

/* ===== SIDEBAR ===== */
.sidebar {
    display: flex;
    flex-direction: column;
    width: 350px;
    background-color: var(--bg-darker);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    z-index: 100;
}

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

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--accent);
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
}

/* Control groups (selects) */
.control-group {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group select {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 3px;
    transition: border-color 0.2s;
}

.control-group select:hover {
    border-color: var(--accent);
}

.control-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(233, 69, 96, 0.2);
}


/* Stations list container */
.stations-list-container {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.stations-list {
    padding: 0.5rem;
}

.station-item {
    padding: 1rem;
    margin: 0.5rem 0;
    background-color: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.station-item:hover {
    border-color: var(--accent);
    background-color: rgba(233, 69, 96, 0.1);
}

.station-item.active {
    border-color: var(--accent);
    background-color: rgba(233, 69, 96, 0.15);
}

.station-name {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.station-location {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.station-price {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    font-family: 'Courier New', monospace;
}

.station-distance {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.station-directions {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.4rem 0.8rem;
    background-color: rgba(233, 69, 96, 0.2);
    color: var(--accent);
    text-decoration: none;
    border-radius: 3px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid var(--accent);
}

.station-directions:hover {
    background-color: rgba(233, 69, 96, 0.3);
}

.loading {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.error {
    padding: 1rem;
    margin: 0.5rem;
    background-color: rgba(233, 69, 96, 0.2);
    border: 1px solid var(--accent);
    border-radius: 3px;
    font-size: 0.85rem;
    color: var(--text);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-muted);
}

/* ===== MAP ===== */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

/* Popup personalizado Leaflet */
.leaflet-popup-content-wrapper {
    background-color: var(--bg-dark);
    border: 2px solid var(--accent);
    border-radius: 3px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

.leaflet-popup-content {
    margin: 0;
    color: var(--text);
}
.leaflet-popup-content div{
    padding: 12px;
}

.leaflet-popup-content p {
    margin: 0.5rem 0;
    font-size: 0.85rem;
}

.leaflet-popup-content strong {
    color: var(--accent);
}

.leaflet-popup-tip {
    background-color: var(--bg-dark);
}

/* Controles de Leaflet siempre visibles */
.leaflet-control-container {
    z-index: 200 !important;
}

/* ===== MOBILE ===== */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem 1rem;
    }

    .header-content {
        gap: 0.75rem;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }

    .sidebar-toggle-mobile {
        display: flex !important;
        position: relative !important;
        top: auto !important;
        left: auto !important;
        z-index: auto !important;
        width: 2.5rem !important;
        height: 2.5rem !important;
        background-color: transparent !important;
        border: none !important;
        font-size: 1.5rem !important;
        cursor: pointer !important;
        color: var(--accent) !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
    }

    .header-title {
        flex: 1;
        min-width: 0;
    }

    .header-title h1 {
        font-size: 1.2rem;
        margin: 0;
    }

    .header-buttons {
        gap: 0.25rem;
        flex-shrink: 0;
    }

    .header-btn {
        font-size: 1.1rem;
        width: 2.3rem;
        height: 2.3rem;
    }

    .header-info {
        gap: 1rem;
        font-size: 0.8rem;
        order: 3;
        width: 100%;
        justify-content: flex-start;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
        padding-left: 2.5rem;
        margin-top: 0.5rem;
    }

    .container {
        flex-direction: column;
    }

    .sidebar {
        position: absolute;
        top: 60px;
        left: 0;
        width: 100%;
        height: 0;
        max-height: calc(100vh - 60px - 40px);
        border-right: none;
        border-bottom: 1px solid var(--border);
        transition: height 0.3s ease;
        overflow: hidden;
        z-index: 90;
    }

    .sidebar.open {
        height: calc(100vh - 60px - 40px);
        overflow-y: auto;
        z-index: 1000;
    }

    .sidebar-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .sidebar-toggle {
        display: block;
    }


    .map-container {
        flex: 1;
        z-index: 1;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
    }

    .sidebar-header h1 {
        font-size: 1rem;
    }

    .control-group {
        padding: 0.75rem;
    }

    .station-item {
        padding: 0.75rem;
        margin: 0.25rem 0;
    }

    .sidebar-footer {
        padding: 0.75rem;
    }

    .app-footer {
        padding: 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .app-footer {
        padding: 0.5rem 1rem;
        font-size: 0.75rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .footer-links {
        gap: 1rem;
        font-size: 0.75rem;
    }

    .modal-content {
        padding: 1.5rem;
        max-width: 90%;
    }

    .modal-content h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .modal-content p {
        font-size: 0.9rem;
        margin: 0.5rem 0;
    }
}

/* ===== SCROLLBAR ===== */
.sidebar::-webkit-scrollbar,
.stations-list-container::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track,
.stations-list-container::-webkit-scrollbar-track {
    background-color: var(--bg-dark);
}

.sidebar::-webkit-scrollbar-thumb,
.stations-list-container::-webkit-scrollbar-thumb {
    background-color: var(--border);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.stations-list-container::-webkit-scrollbar-thumb:hover {
    background-color: var(--accent);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.spinner-border {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(233, 69, 96, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner p {
    color: var(--text);
    font-size: 1rem;
    margin: 0;
}

/* ===== FOOTER ===== */
.app-footer {
    background-color: var(--bg-darker);
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.footer-text {
    color: var(--text-muted);
    margin: 0;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.footer-link {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.footer-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--bg-dark);
    border: 2px solid var(--accent);
    border-radius: 5px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 2rem;
    cursor: pointer;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.modal-close:hover {
    opacity: 0.7;
}

.modal-content h2 {
    color: var(--accent);
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.modal-content p {
    margin: 0.75rem 0;
    line-height: 1.6;
    color: var(--text);
    font-size: 0.95rem;
}
