/* ============================================
   SISTEMA DE REPARTO - PERSAT
   Estilos Corporativos Azul/Blanco
   ============================================ */

:root {
    --primary: #1565C0;
    --primary-dark: #0D47A1;
    --primary-light: #42A5F5;
    --secondary: #00BCD4;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --info: #2196F3;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --border: #e0e0e0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* LOGIN */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0D47A1, #1565C0);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 40px 30px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-icon {
    font-size: 64px;
    margin-bottom: 10px;
}

.login-logo h1 {
    font-size: 28px;
    color: var(--primary);
    font-weight: 800;
}

.login-subtitle {
    color: var(--text-light);
    font-size: 14px;
}

.login-hint {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    background: #f5f5f5;
    padding: 8px;
    border-radius: var(--radius-sm);
}

/* NAVBAR */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    color: white;
    text-decoration: none;
    font-size: 20px;
    font-weight: 800;
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.nav-user {
    margin-left: 12px;
    padding: 4px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

/* MAIN */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 56px);
}

.container {
    width: 100%;
}

h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 20px;
}

/* CARDS */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.card-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.card-body {
    display: flex;
    flex-direction: column;
}

.card-label {
    font-size: 13px;
    color: var(--text-light);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.2;
}

.stock-value {
    color: var(--success);
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.chart-card {
    min-height: 300px;
}

/* TOOLBAR */
.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* FORM ELEMENTS */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--text);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"],
select, textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    transition: border 0.2s;
    background: white;
    font-family: inherit;
}

.input:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.1);
}

.input-lg {
    padding: 14px;
    font-size: 18px;
}

.search-input {
    max-width: 300px;
}

textarea {
    resize: vertical;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-secondary { background: #f5f5f5; color: var(--text); }
.btn-secondary:hover { background: #e0e0e0; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #388E3C; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #D32F2F; }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 14px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn-map {
    background: #4285F4;
    color: white;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

/* TABLE */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th {
    background: #f8f9fa;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-light);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.table tr:hover {
    background: #f8f9fa;
}

.inactive-row {
    opacity: 0.5;
}

.actions-cell {
    white-space: nowrap;
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-activo, .badge-en_deposito { background: #E8F5E9; color: #2E7D32; }
.badge-inactivo, .badge-dado_de_baja { background: #FFEBEE; color: #C62828; }
.badge-pendiente { background: #FFF3E0; color: #E65100; }
.badge-visitado, .badge-completada { background: #E8F5E9; color: #2E7D32; }
.badge-no_estaba { background: #FFEBEE; color: #C62828; }
.badge-en_curso { background: #E3F2FD; color: #1565C0; }
.badge-prestado { background: #E8F5E9; color: #2E7D32; }
.badge-en_reparacion { background: #FFF3E0; color: #E65100; }
.badge-entrada { background: #E8F5E9; color: #2E7D32; }
.badge-salida { background: #FFEBEE; color: #C62828; }
.badge-ajuste { background: #E3F2FD; color: #1565C0; }

/* PROGRESS BAR */
.progress-bar {
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    min-width: 80px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 30px;
    max-width: 500px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

.modal-lg { max-width: 800px; }
.modal-full {
    max-width: 100%;
    max-width: 480px;
    margin: auto;
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 20px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-light);
    background: none;
    border: none;
    line-height: 1;
}

.modal-close:hover { color: var(--text); }

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ALERTS */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}

.alert-error {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #FFCDD2;
}

.alert-success {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}

.alert-warning {
    background: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFE0B2;
}

/* TEXT */
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-bold { font-weight: 700; }
.p-4 { padding: 20px; }

/* TABS */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-light);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* REPARTIDOR VIEW (mobile-first) */
.repartidor-view {
    max-width: 600px;
    margin: 0 auto;
}

.repartidor-header {
    text-align: center;
    margin-bottom: 20px;
}

.repartidor-header h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.date-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.ruta-resumen {
    margin-bottom: 16px;
}

.ruta-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-light);
}

.paradas-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.parada-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
    cursor: pointer;
    transition: transform 0.2s;
}

.parada-card:hover { transform: translateX(4px); }

.parada-pendiente { border-left-color: var(--warning); }
.parada-visitado { border-left-color: var(--success); opacity: 0.8; }
.parada-no_estaba { border-left-color: var(--danger); opacity: 0.8; }

.parada-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.parada-orden {
    font-weight: 800;
    font-size: 14px;
    color: var(--text-light);
}

.parada-body h3 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 4px;
}

.parada-direccion {
    font-size: 13px;
    color: var(--text-light);
}

.parada-telefono {
    font-size: 13px;
    margin-top: 4px;
}

.parada-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.parada-footer {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-light);
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.btn-visita {
    flex: 1;
    justify-content: center;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.empty-state p {
    color: var(--text-light);
}

/* DETALLE DATOS */
.detalle-datos {
    font-size: 14px;
    line-height: 1.8;
}

.detalle-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 16px;
    margin-bottom: 12px;
}

@media (max-width: 480px) {
    .detalle-grid {
        grid-template-columns: 1fr;
    }
}

/* CHECKBOX LIST */
.checkbox-list {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
}

.checkbox-item {
    display: block;
    padding: 6px 8px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 4px;
}

.checkbox-item:hover {
    background: #f5f5f5;
}

.checkbox-item input {
    margin-right: 8px;
}

/* FILE INPUT */
.file-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-input-wrapper input[type="file"] {
    display: none;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .main-content {
        padding: 12px;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: 12px;
        gap: 4px;
        box-shadow: var(--shadow-lg);
    }

    .nav-menu.show {
        display: flex;
    }

    .nav-toggle {
        display: block;
    }

    .nav-user {
        margin-left: 0;
        width: 100%;
        text-align: center;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        padding: 20px;
        margin: 10px;
    }

    .modal-full {
        max-width: 100%;
        margin: 0;
        border-radius: var(--radius) var(--radius) 0 0;
        margin-top: auto;
        max-height: 85vh;
    }

    .modal.show {
        align-items: flex-end;
    }

    h1 {
        font-size: 20px;
    }

    .card-value {
        font-size: 22px;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .card {
        padding: 14px;
    }

    .card-value {
        font-size: 20px;
    }
}
