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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

h1 {
    background: #2c3e50;
    color: white;
    padding: 25px;
    text-align: center;
    font-size: 24px;
    font-weight: 300;
}

.section {
    padding: 30px;
}

h2 {
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.header h2 {
    border: none;
    margin: 0;
    padding: 0;
}

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

label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: #3498db;
}

small {
    display: block;
    margin-top: 5px;
    color: #888;
    font-size: 13px;
}

.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.btn-primary {
    background: #3498db;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

.btn-success {
    background: #27ae60;
    color: white;
    width: 100%;
}

.btn-success:hover {
    background: #219a52;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

.btn-secondary {
    background: #95a5a6;
    color: white;
    padding: 8px 15px;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-small {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    background: #ecf0f1;
    color: #2c3e50;
    transition: all 0.2s;
}

.btn-small:hover {
    background: #bdc3c7;
}

.hidden {
    display: none !important;
}

.error {
    background: #e74c3c;
    color: white;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
}

.token-result {
    margin: 30px 0;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #27ae60;
}

.token-result h3 {
    color: #27ae60;
    margin-bottom: 15px;
}

.token-box {
    margin-bottom: 20px;
}

.token-box textarea {
    width: 100%;
    height: 100px;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: none;
    margin-bottom: 10px;
    word-break: break-all;
}

.token-info {
    background: white;
    padding: 15px;
    border-radius: 6px;
}

.token-info p {
    margin-bottom: 8px;
    color: #555;
}

.token-info strong {
    color: #2c3e50;
}

.hint {
    margin-top: 15px;
    padding: 10px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    font-size: 13px;
}

.hint code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* ============================================
   SECCIÓN DEL MAPA
   ============================================ */
.map-section {
    margin: 30px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #3498db;
    overflow: hidden;
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

.map-header h3 {
    color: #3498db;
    margin: 0;
    font-size: 18px;
}

.map-status {
    font-size: 13px;
    color: #7f8c8d;
}

.map-status span {
    margin-left: 10px;
}

.map-container {
    display: flex;
    height: 500px;
}

/* Sidebar de rutas */
.routes-sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.sidebar-header h4 {
    margin: 0;
    color: #2c3e50;
    font-size: 14px;
}

.sidebar-actions {
    display: flex;
    gap: 5px;
}

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

.loading-routes,
.empty-routes,
.error-routes {
    text-align: center;
    padding: 30px 20px;
    color: #7f8c8d;
    font-size: 14px;
}

.error-routes {
    color: #e74c3c;
}

.route-item {
    padding: 10px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.route-item:hover {
    background: #ecf0f1;
}

.route-item.checked {
    border-color: #3498db;
    background: #ebf5fb;
}

.route-checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 5px;
}

.route-checkbox {
    margin-right: 8px;
    cursor: pointer;
}

.route-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid rgba(0,0,0,0.2);
}

.route-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route-info {
    display: flex;
    justify-content: space-between;
    padding-left: 28px;
    font-size: 11px;
    color: #7f8c8d;
}

.route-points {
    font-weight: 500;
}

.sidebar-footer {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #ddd;
    font-size: 12px;
    color: #7f8c8d;
    text-align: center;
}

/* Mapa Leaflet */
.map {
    flex: 1;
    min-height: 400px;
}

/* Popup de ruta */
.route-popup h4 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 14px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 5px;
}

.route-popup p {
    margin: 5px 0;
    font-size: 12px;
    color: #555;
}

/* ============================================
   SECCIÓN DE DOCUMENTACIÓN
   ============================================ */
.docs-section {
    margin-top: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #3498db;
}

.docs-section h3 {
    color: #3498db;
    margin-bottom: 20px;
    font-size: 18px;
}

.endpoint {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.endpoint:last-child {
    margin-bottom: 0;
}

.endpoint h4 {
    color: #2c3e50;
    margin-bottom: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.endpoint p {
    color: #555;
    margin-bottom: 10px;
    font-size: 14px;
}

.endpoint ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

.endpoint li {
    color: #666;
    font-size: 13px;
    margin-bottom: 5px;
}

.endpoint code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #e74c3c;
}

.endpoint pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    margin-top: 10px;
}

.endpoint pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 12px;
    line-height: 1.5;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .map-container {
        flex-direction: column;
        height: auto;
    }

    .routes-sidebar {
        width: 100%;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }

    .map {
        height: 400px;
    }
}

@media (max-width: 600px) {
    .container {
        margin: 10px;
    }

    .section {
        padding: 20px;
    }

    .header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .map-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .map-status {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }

    .map-status span {
        margin-left: 0;
    }

    .docs-section {
        padding: 15px;
    }

    .endpoint pre {
        padding: 10px;
    }
}
