/**
 * SIRYC - Sistema de Mantenimiento de Peajes
 * Estilos principales - MACROGRAM Developer System
 *
 * Paleta de colores:
 * - Primary (SIRYC): #1a3a5c
 * - Secondary (MACROGRAM): #f57c00
 * - Dark: #0d1f30
 * - Light: #f8f9fa
 */

:root {
    --siryc-primary: #1a3a5c;
    --siryc-primary-dark: #0d1f30;
    --siryc-primary-light: #2a5a8c;
    --macrogram-orange: #f57c00;
    --macrogram-orange-dark: #c56200;
    --macrogram-orange-light: #ff9d3f;
    --text-dark: #2c3e50;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --bg-light: #f4f6f9;
    --bg-white: #ffffff;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 58px;
    --transition-speed: 0.3s;
}

/* Reset y base */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-dark);
    background-color: var(--bg-light);
    margin: 0;
    min-height: 100vh;
}

/* Layout principal */
.wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ===== SIDEBAR ===== */
.main-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--siryc-primary-dark) 0%, var(--siryc-primary) 100%);
    z-index: 1030;
    transition: transform var(--transition-speed) ease, width var(--transition-speed) ease;
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
}

.sidebar-nav-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.1);
}

.sidebar-brand img {
    max-height: 42px;
    width: auto;
}

.sidebar-brand .brand-text {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    margin-left: 0.75rem;
    white-space: nowrap;
}

/* Navegación sidebar */
.sidebar-nav {
    padding: 0.5rem 0;
    list-style: none;
    margin: 0;
}

.nav-section {
    padding: 0.75rem 1.25rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.4);
}

.nav-item {
    margin: 2px 8px;
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.85rem;
}

.nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.nav-link.active {
    color: #fff;
    background: var(--macrogram-orange);
    box-shadow: 0 2px 8px rgba(245, 124, 0, 0.4);
}

.nav-link i {
    width: 20px;
    margin-right: 0.75rem;
    font-size: 1rem;
    text-align: center;
}

.nav-link .badge {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0.25em 0.5em;
}

/* Submenu */
.nav-treeview {
    list-style: none;
    padding: 0;
    margin: 0;
    padding-left: 1rem;
}

.nav-treeview .nav-link {
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
}

.menu-open > .nav-treeview {
    display: block;
}

.nav-treeview {
    display: none;
}

/* Flecha submenu */
.nav-link[data-toggle="collapse"]::after {
    content: '\f105';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    margin-left: auto;
    transition: transform 0.2s;
}

.nav-link[data-toggle="collapse"][aria-expanded="true"]::after {
    transform: rotate(90deg);
}

/* User panel en sidebar */
.user-panel {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
    display: flex;
    align-items: center;
}

.user-panel .user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--macrogram-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.9rem;
    margin-right: 0.75rem;
}

.user-panel .user-info {
    flex: 1;
    min-width: 0;
}

.user-panel .user-name {
    color: #fff;
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-panel .user-role {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
}

/* ===== SIDEBAR COLAPSADO ===== */
.sidebar-collapsed .main-sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-collapsed .sidebar-brand .brand-text,
.sidebar-collapsed .nav-section,
.sidebar-collapsed .nav-link span,
.sidebar-collapsed .nav-link .badge,
.sidebar-collapsed .user-panel .user-info {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
}

.sidebar-collapsed .sidebar-brand {
    padding: 1rem 0.5rem;
}

.sidebar-collapsed .sidebar-brand .logo-full {
    display: none;
}

.sidebar-collapsed .sidebar-brand .logo-mini {
    display: block !important;
}

.sidebar-brand .logo-mini {
    display: none;
    max-height: 36px;
    width: auto;
}

.sidebar-brand .logo-full {
    max-height: 42px;
    width: auto;
}

.sidebar-collapsed .nav-item {
    margin: 2px 8px;
}

.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar-collapsed .nav-link i {
    margin-right: 0;
    font-size: 1.1rem;
}

.sidebar-collapsed .user-panel {
    justify-content: center;
    padding: 1rem 0.5rem;
}

.sidebar-collapsed .user-panel .user-avatar {
    margin-right: 0;
}

.sidebar-collapsed .content-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* Tooltip en modo colapsado - usando elemento .nav-tooltip */
.nav-tooltip {
    position: absolute;
    left: calc(var(--sidebar-collapsed-width) + 10px);
    top: 50%;
    transform: translateY(-50%) translateX(-5px);
    background: var(--siryc-primary-dark);
    color: #fff;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease, transform 0.15s ease;
    z-index: 1060;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.nav-tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: var(--siryc-primary-dark);
}

.sidebar-collapsed .nav-item:hover .nav-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* ===== CONTENIDO PRINCIPAL ===== */
.content-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: calc(100% - var(--sidebar-width));
    flex: 1;
    transition: margin-left var(--transition-speed) ease, width var(--transition-speed) ease;
}

.sidebar-collapsed .content-wrapper {
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* Navbar superior */
.main-navbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    height: var(--navbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.navbar-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    margin-right: 1rem;
    cursor: pointer;
    color: var(--text-dark);
    font-size: 1.1rem;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.navbar-toggle:hover {
    color: var(--macrogram-orange);
    background: var(--bg-light);
}

.navbar-breadcrumb {
    flex: 1;
}

.navbar-breadcrumb h1 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-dark);
}

.navbar-breadcrumb .breadcrumb {
    margin: 0;
    padding: 0;
    background: none;
    font-size: 0.75rem;
}

.navbar-breadcrumb .breadcrumb-item a {
    color: var(--text-muted);
    text-decoration: none;
}

.navbar-breadcrumb .breadcrumb-item.active {
    color: var(--macrogram-orange);
}

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

.navbar-actions .btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border: none;
    color: var(--text-dark);
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

.navbar-actions .btn-icon:hover {
    background: var(--siryc-primary);
    color: #fff;
}

.navbar-actions .btn-icon .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.65rem;
    padding: 0.2em 0.4em;
    background: var(--macrogram-orange);
}

/* Contenido */
.content {
    flex: 1;
    padding: 1.5rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-white);
    border: none;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.card-header {
    background: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-dark);
}

.card-tools {
    display: flex;
    gap: 0.5rem;
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
}

/* Cards de estadísticas */
.stat-card {
    border-left: 4px solid var(--siryc-primary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card.primary { border-left-color: var(--siryc-primary); }
.stat-card.success { border-left-color: #28a745; }
.stat-card.warning { border-left-color: var(--macrogram-orange); }
.stat-card.danger { border-left-color: #dc3545; }
.stat-card.info { border-left-color: #17a2b8; }

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card.primary .stat-icon { background: rgba(26,58,92,0.1); color: var(--siryc-primary); }
.stat-card.success .stat-icon { background: rgba(40,167,69,0.1); color: #28a745; }
.stat-card.warning .stat-icon { background: rgba(245,124,0,0.1); color: var(--macrogram-orange); }
.stat-card.danger .stat-icon { background: rgba(220,53,69,0.1); color: #dc3545; }
.stat-card.info .stat-icon { background: rgba(23,162,184,0.1); color: #17a2b8; }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.stat-card .stat-change {
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

.stat-card .stat-change.positive { color: #28a745; }
.stat-card .stat-change.negative { color: #dc3545; }

/* ===== TABLAS ===== */
.table-responsive {
    border-radius: 8px;
    overflow: hidden;
}

.table {
    margin-bottom: 0;
    font-size: 0.85rem;
}

.table thead th {
    background: var(--bg-light);
    border-bottom: 2px solid var(--border-color);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: rgba(26,58,92,0.02);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ===== BOTONES ===== */
.btn {
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

.btn-lg {
    font-size: 0.95rem;
    padding: 0.65rem 1.5rem;
}

.btn-primary {
    background: var(--siryc-primary);
    border-color: var(--siryc-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--siryc-primary-dark);
    border-color: var(--siryc-primary-dark);
    color: #fff;
}

.btn-secondary {
    background: var(--macrogram-orange);
    border-color: var(--macrogram-orange);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--macrogram-orange-dark);
    border-color: var(--macrogram-orange-dark);
    color: #fff;
}

.btn-outline-primary {
    border-color: var(--siryc-primary);
    color: var(--siryc-primary);
}

.btn-outline-primary:hover {
    background: var(--siryc-primary);
    color: #fff;
}

.btn-light {
    background: var(--bg-light);
    border-color: var(--border-color);
    color: var(--text-dark);
}

.btn-light:hover {
    background: #e9ecef;
    border-color: #dde2e6;
}

/* ===== FORMULARIOS ===== */
.form-control, .form-select {
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--siryc-primary);
    box-shadow: 0 0 0 3px rgba(26,58,92,0.1);
}

.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.4rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.input-group-text {
    background: var(--bg-light);
    border-color: var(--border-color);
    font-size: 0.875rem;
}

/* ===== BADGES ===== */
.badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 4px;
}

.badge-primary { background: var(--siryc-primary); }
.badge-secondary { background: var(--macrogram-orange); }
.badge-success { background: #28a745; }
.badge-danger { background: #dc3545; }
.badge-warning { background: #ffc107; color: #212529; }
.badge-info { background: #17a2b8; }

/* Estados de mantenimiento */
.badge-estado-programado { background: #6c757d; }
.badge-estado-asignado { background: #17a2b8; }
.badge-estado-en-ruta { background: #007bff; }
.badge-estado-en-sitio { background: #fd7e14; }
.badge-estado-en-ejecucion { background: var(--macrogram-orange); }
.badge-estado-pendiente-aprobacion { background: #ffc107; color: #212529; }
.badge-estado-aprobado { background: #28a745; }
.badge-estado-rechazado { background: #dc3545; }
.badge-estado-completado { background: var(--siryc-primary); }

/* ===== ALERTS ===== */
.alert {
    border: none;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.1rem;
    margin-top: 0.1rem;
}

.alert-success { background: rgba(40,167,69,0.1); color: #155724; }
.alert-danger { background: rgba(220,53,69,0.1); color: #721c24; }
.alert-warning { background: rgba(255,193,7,0.15); color: #856404; }
.alert-info { background: rgba(23,162,184,0.1); color: #0c5460; }

/* ===== PAGINATION ===== */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: 6px;
    border: 1px solid var(--border-color);
    color: var(--text-dark);
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
}

.page-link:hover {
    background: var(--bg-light);
    border-color: var(--border-color);
    color: var(--siryc-primary);
}

.page-item.active .page-link {
    background: var(--siryc-primary);
    border-color: var(--siryc-primary);
}

/* ===== DROPDOWNS ===== */
.dropdown-menu {
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 0.5rem;
    font-size: 0.875rem;
}

.dropdown-item {
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-item:hover {
    background: var(--bg-light);
}

.dropdown-item i {
    width: 16px;
    color: var(--text-muted);
}

.dropdown-divider {
    margin: 0.5rem 0;
}

/* ===== MODALES ===== */
.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.modal-title {
    font-size: 1rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    gap: 0.5rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
    .main-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .main-sidebar.show {
        transform: translateX(0);
    }

    .content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar-collapsed .main-sidebar {
        width: var(--sidebar-width) !important;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1025;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 767.98px) {
    html {
        font-size: 13px;
    }

    .content {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

/* ===== UTILIDADES ===== */
.text-primary { color: var(--siryc-primary) !important; }
.text-secondary { color: var(--macrogram-orange) !important; }
.bg-primary { background-color: var(--siryc-primary) !important; }
.bg-secondary { background-color: var(--macrogram-orange) !important; }

.border-primary { border-color: var(--siryc-primary) !important; }
.border-secondary { border-color: var(--macrogram-orange) !important; }

.shadow-sm { box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important; }
.shadow { box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important; }
.shadow-lg { box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important; }

/* Scrollbar personalizado */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--siryc-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1100;
}

.toast {
    background: var(--bg-white);
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 300px;
}

.toast-header {
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
}

.toast-body {
    padding: 0.75rem 1rem;
}

/* Footer */
.main-footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-footer a {
    color: var(--siryc-primary);
    text-decoration: none;
}

.main-footer a:hover {
    color: var(--macrogram-orange);
}
