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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* HEADER */
header {
    background: linear-gradient(135deg, #1e88e5 0%, #26a69a 100%);
    color: white;
    padding: 1.2rem 2rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Ajustar para que el contenido se alinee arriba */
    position: relative;
    gap: 1rem; /* Espacio entre elementos */
}

.header-left {
    display: flex;
    flex-direction: column;
    flex: 1; /* Tomar el espacio disponible */
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0; /* No crece */
    margin: 0 auto; /* Centrar horizontalmente */
}

.header-left-tools {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1rem;
    margin-right: auto; /* Empujar a la izquierda */
}

.header-right {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-left: auto; /* Empujar a la derecha */
}

.header-right .header-tools {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.header-right .header-tabs {
    display: flex;
    gap: 0.5rem;
}

.header-left h1 {
    font-size: 1.8rem;
    margin-bottom: 0.4rem;
}

.subtitle {
    opacity: 0.95;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.header-tabs {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    margin-bottom: 0; /* Remover margen extra */
}

/* Estilos para el logo del cliente */
.logo-container {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.client-logo {
    max-height: 100px; /* Ajustar al tamaño deseado */
    max-width: 200px; /* Ajustar al tamaño deseado */
    object-fit: contain;
}

/* Estilo para herramientas en el header */
.header-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.header-btn {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.header-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    transform: scale(1.05);
}

/* Selectores de tema */
.theme-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
}

.theme-selector label {
    font-size: 0.9rem;
    white-space: nowrap;
}

.theme-selector select {
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

.tab-btn {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
}

.tab-btn.active {
    background: white;
    color: #1e88e5;
    border-color: white;
}

/* MAIN CONTENT */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 400px;
    background: white;
    overflow-y: auto;
    box-shadow: 2px 0 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.tab-content {
    display: none;
    flex-direction: column;
    height: 100%;
}

.tab-content.active {
    display: flex;
}

.search-box {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.search-box input {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.search-box input:focus {
    outline: none;
    border-color: #1e88e5;
}

.filters {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.filters h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 0.8rem;
    font-weight: 600;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-bottom: 1.5rem;
}

.filter-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
}

.filter-group input[type="checkbox"] {
    margin-right: 0.6rem;
    cursor: pointer;
    width: 18px;
    height: 18px;
}

#ratingFilter {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
}

.stats {
    display: flex;
    gap: 1rem;
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, #1e88e515 0%, #26a69a15 100%);
    border-radius: 10px;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #1e88e5;
}

.stat-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
}

.business-list {
    flex: 1;
    overflow-y: auto;
}

.business-card {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
}

.business-card:hover {
    background-color: #f8f9fa;
}

.business-card.active {
    background-color: #e8eaf6;
    border-left: 4px solid #1e88e5;
}

.business-card.selected {
    background-color: #e0f2f1;
    border-left: 4px solid #4caf50;
}

.business-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.4rem;
}

.business-rating {
    color: #ffa500;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.business-address {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 0.3rem;
}

.business-categories {
    font-size: 0.75rem;
    color: #999;
}

.business-category-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: #f0f0f0;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-right: 0.3rem;
    margin-top: 0.3rem;
}

/* RUTAS */
.routes-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.routes-header h2 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 0.3rem;
}

.routes-header p {
    color: #666;
    font-size: 0.9rem;
}

.routes-list {
    flex: 1;
    overflow-y: auto;
}

.route-card {
    padding: 1.2rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
}

.route-card:hover {
    background-color: #f8f9fa;
}

.route-card.active {
    background-color: #e8eaf6;
}

.route-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 0.5rem;
}

.route-icon {
    font-size: 2rem;
}

.route-info {
    flex: 1;
}

.route-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.2rem;
}

.route-description {
    font-size: 0.85rem;
    color: #666;
}

.route-stats {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #999;
}

/* CREAR RUTA */
.create-route-form {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.create-route-form h2 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 0.5rem;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1e88e5;
}

.color-picker input[type="color"] {
    width: 100%;
    height: 50px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
}

.selected-businesses {
    min-height: 150px;
    max-height: 300px;
    overflow-y: auto;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 2rem 1rem;
}

.selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.selected-item-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.remove-btn {
    background: #ff5252;
    color: white;
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.btn-primary,
.btn-secondary,
.btn-export {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #1e88e5 0%, #26a69a 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #666;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-export {
    background: #4caf50;
    color: white;
}

.btn-export:hover {
    background: #45a049;
}

/* MAPA */
.map-container {
    flex: 1;
    position: relative;
}

/* Map container expands when context panel is hidden */
body.context-panel-hidden .map-container {
    flex: 1 1 100%; /* Expand to full available width */
}

body.context-panel-hidden .context-panel {
    width: 0;
    min-width: 0;
    overflow: hidden;
    box-shadow: none;
}

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

.map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.map-btn {
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: all 0.3s;
}

.map-btn:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

/* POPUP */
.leaflet-popup-content {
    margin: 1rem;
    max-width: 320px;
}

.popup-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
}

.popup-rating {
    color: #ffa500;
    margin-bottom: 0.5rem;
}

.popup-category {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: #e8eaf6;
    color: #1e88e5;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.popup-address {
    margin-bottom: 0.5rem;
    color: #666;
}

.popup-phone,
.popup-website {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.popup-website a {
    color: #1e88e5;
    text-decoration: none;
    font-weight: 500;
}

.popup-hours {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #666;
    max-height: 100px;
    overflow-y: auto;
}

.popup-actions {
    margin-top: 0.8rem;
    display: flex;
    gap: 0.5rem;
}

.popup-btn {
    flex: 1;
    padding: 0.5rem;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.popup-btn-primary {
    background: #1e88e5;
    color: white;
}

.popup-btn-secondary {
    background: #e0e0e0;
    color: #666;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        max-height: 45vh;
    }

    .header-content h1 {
        font-size: 1.4rem;
    }

    .header-tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.business-card,
.route-card {
    animation: fadeIn 0.3s ease;
}
