:root {
    --primary-color: #252c61;
    --header-public-height: 90px;
    /* Azul AGVP */
    --primary-light: #252c61;
    --accent-color: #252c96;
    /* Celeste Vial */
    --secondary-color: #ffcc00;
    /* Amarillo Señalización */
    --danger-color: #d90429;
    --success-color: #2b9348;
    --warning-color: #ff9f1c;

    --bg-color: #f0f2f5;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1d2d35;
    --text-muted: #546e7a;
    --border-color: #cfd8dc;

    --sidebar-width: 260px;
    --header-height: 70px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

/* --- Login Styles (preserved and improved) --- */
.login-body {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 3rem;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.institutional-logo h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
}

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

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: 0.3s;
}

input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(0, 168, 225, 0.1);
}

/* --- Layout Principal --- */
.app-container {
    display: flex;
    min-height: 100vh;
    padding-top: var(--header-public-height);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: var(--header-public-height);
    height: calc(100vh - var(--header-public-height));
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.sidebar-header img {
    max-width: 140px;
    height: auto;
    margin-bottom: 12px;
}

.sidebar-header h2 {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Base Table Styles --- */
.route-table-container {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
    overflow: hidden;
}

.route-header {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    /* Enforces strict widths from th */
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.data-table th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
    text-align: left;
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:nth-child(even) {
    background-color: #f8faf9;
}

.data-table tbody tr:hover {
    background-color: #f1f5f9;
}

/* --- Table Controls --- */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.search-wrapper i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-wrapper input {
    padding-left: 40px;
}

.pagination {
    display: flex;
    gap: 5px;
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.2s;
}

.page-btn:hover:not(:disabled) {
    background: #f1f3f4;
    border-color: var(--accent-color);
}

.page-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* Sorting Indicators */
.sortable {
    cursor: pointer;
    position: relative;
    padding-right: 25px !important;
}

.sortable::after {
    content: '\f0dc';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 8px;
    opacity: 0.3;
}

.sort-asc::after {
    content: '\f0de';
    opacity: 1;
    color: var(--accent-color);
}

.sort-desc::after {
    content: '\f0dd';
    opacity: 1;
    color: var(--accent-color);
}

/* --- Column Filters --- */
.header-filters {
    background: #f8fafc;
}

.header-filters th {
    padding: 8px 10px !important;
    border-top: 1px solid var(--border-color);
}

.column-filter {
    width: 100%;
    padding: 6px 10px !important;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-main);
    background: white;
    transition: all 0.2s;
}

.column-filter:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 168, 225, 0.1);
    outline: none;
}

.column-filter::placeholder {
    color: #cbd5e1;
    font-style: italic;
}

.search-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    color: var(--primary-color);
    margin: 0;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

.detail-row {
    display: flex;
    padding: 12px 0;
    border-bottom: 1px solid #f1f3f4;
}

.detail-label {
    width: 160px;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.detail-value {
    flex: 1;
    color: var(--text-main);
    word-break: break-all;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 0;
}

.nav-item {
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    transition: all 0.2s;
    border-left: 4px solid transparent;
}

.nav-item i {
    font-size: 1.2rem;
}

.nav-item:hover {
    background: rgba(0, 71, 114, 0.04);
    color: var(--primary-color);
}

.nav-item.active {
    background: rgba(0, 71, 114, 0.08);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* Header */
.top-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: var(--header-public-height);
    z-index: 900;
    display: none;
    /* Oculto ya que usaremos el public-header global */
}

/* --- Public Header Global --- */
.public-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    padding: 10px 2rem;
    color: white;
    box-shadow: var(--shadow-md);
    z-index: 1100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-public-height);
}

.public-branding {
    display: flex;
    align-items: center;
    gap: 15px;
}

.public-branding img {
    height: 60px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.public-branding h1 {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.1;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.public-branding small {
    display: block;
    font-size: 0.7rem;
    opacity: 0.9;
    font-weight: 600;
}

.public-branding-text {
    display: flex;
    align-items: center;
    gap: 15px;
}

.public-branding-shield {
    height: 70px;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
    padding-left: 15px;
    margin-left: 5px;
}

.header-info-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-info-text {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
}


.header-title {
    font-weight: 700;
    color: var(--primary-color);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: #f1f3f4;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-logout-icon {
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 50%;
    transition: 0.2s;
}

.btn-logout-icon:hover {
    background: #fee2e2;
}

/* Dashboard Global Styles */
.content-body {
    padding: 32px;
}

.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Quick Stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-box {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    border-bottom: 4px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.stat-box .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 700;
}

.stat-box .value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-main);
    margin-top: 4px;
}

.stat-box.blue {
    border-bottom-color: var(--primary-color);
}

.stat-box.cyan {
    border-bottom-color: var(--accent-color);
}

.stat-box.yellow {
    border-bottom-color: var(--secondary-color);
}

/* Leaflet Overrides */
#map {
    height: 500px;
    width: 100%;
    border-radius: var(--border-radius);
    z-index: 1;
}

/* Custom UI Elements (Elegantes) */
.status-chip {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
    letter-spacing: 0.5px;
    text-align: center;
}

.status-chip.visible {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.status-chip.historico {
    background-color: #fff3e0;
    color: #ed6c02;
    border: 1px solid #ffe0b2;
}

.status-chip.sin-parte {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.btn-action-primary {
    background-color: rgba(25, 118, 210, 0.1);
    color: #1976d2;
    border: 1px solid rgba(25, 118, 210, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action-primary:hover {
    background-color: rgba(25, 118, 210, 0.2);
    border-color: rgba(25, 118, 210, 0.4);
}

.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.btn-action-warning {
    background-color: rgba(237, 108, 2, 0.1);
    color: #ed6c02;
    border: 1px solid rgba(237, 108, 2, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action-warning:hover {
    background-color: rgba(237, 108, 2, 0.2);
    border-color: rgba(237, 108, 2, 0.4);
}

.btn-action-danger {
    background-color: rgba(211, 47, 47, 0.1);
    color: #d32f2f;
    border: 1px solid rgba(211, 47, 47, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action-danger:hover {
    background-color: rgba(211, 47, 47, 0.2);
    border-color: rgba(211, 47, 47, 0.4);
}

/* .btn-action-info {
    background-color: rgba(2, 136, 209, 0.05);
    color: #0288d1;
    border: 1px solid rgba(2, 136, 209, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
} */

.btn-action-info {
    background-color: #f5f5f5;
    /* Gris casi blanco */
    color: #616161;
    /* Gris grafito */
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* .btn-action-info:hover {
   background-color: rgba(2, 136, 209, 0.2);
    border-color: rgba(2, 136, 209, 0.4); 
} */

.btn-action-info:hover {
    background-color: #eeeeee;
    color: #424242;
    border-color: #bdbdbd;
}

.btn-action-success {
    background-color: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
    border: 1px solid rgba(46, 125, 50, 0.2);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-action-success:hover {
    background-color: rgba(46, 125, 50, 0.2);
    border-color: rgba(46, 125, 50, 0.4);
}

.notification-area {
    position: fixed;
    top: 110px; /* Debajo de la cabecera */
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    display: none; /* Se activa con .show */
    align-items: center;
    gap: 12px;
    opacity: 0;
    transition: all 0.3s ease-in-out;
    max-width: 500px;
    width: auto; /* Evita stretching si el contenido es corto */
    height: auto; /* Evita stretching vertical */
    z-index: 9999;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.notification-area.show {
    display: flex;
    opacity: 1;
}

/* Tipos de Notificaciones */
.notification-area.success {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #10b981;
}

.notification-area.error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.notification-area.warning {
    background-color: #fffbeb;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.text-center {
    text-align: center !important;
}

/* Responsive */
@media (max-width: 900px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header h2,
    .nav-item span {
        display: none;
    }

    .main-wrapper {
        margin-left: 70px;
    }
}

/* --- Route Selector Right Panel --- */
#route-selector-panel {
    position: absolute;
    top: 20px;
    right: 150px;
    width: 250px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

#route-selector-panel.active {
    display: flex;
}

.route-selector-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    text-align: center;
    letter-spacing: 0.5px;
}

.route-selector-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.route-option-card {
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
    display: flex;
    align-items: center;
    gap: 10px;
}

.route-option-card:hover {
    border-color: #bdbdbd;
    background: white;
}

.route-option-card.selected {
    border-color: var(--accent-color);
    background: rgba(37, 44, 150, 0.05);
    box-shadow: 0 2px 4px rgba(37, 44, 150, 0.1);
}

.route-option-icon {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.route-option-card.selected .route-option-icon {
    color: var(--accent-color);
}

.route-option-details {
    display: flex;
    flex-direction: column;
}

.route-option-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
}

.route-option-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    #route-selector-panel {
        top: auto;
        bottom: 120px;
        right: 10px;
        left: 10px;
        width: auto;
    }
}

/* ============================================
   NOTIFICACIONES TIPO TOAST
   Usadas en partes.js, crear-parte.js, ver-parte.js, funciones.js
   Convenciones: .notify-success o .success / .notify-error o .error
   ============================================ */
.notification-area {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    min-width: 280px;
    max-width: 420px;
    padding: 14px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    background-color: #334155;
    color: #ffffff;
}

.notification-area.show {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Convención: notify-success (partes.js, crear-parte.js) */
.notification-area.notify-success,
.notification-area.success {
    background-color: #ecfdf5 !important;
    color: #065f46 !important;
    border-left: 5px solid #10b981;
}

/* Convención: notify-error (partes.js, crear-parte.js) */
.notification-area.notify-error,
.notification-area.error {
    background-color: #fef2f2 !important;
    color: #991b1b !important;
    border-left: 5px solid #ef4444;
}

/* Convención: notify-warning (partes.js) */
.notification-area.notify-warning,
.notification-area.warning {
    background-color: #fffbeb !important;
    color: #92400e !important;
    border-left: 5px solid #f59e0b;
}

.notification-area i {
    font-size: 1.1rem;
    flex-shrink: 0;
}
