:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --primary-color: #002060;
    --primary-light: #004080;
    --accent-color: #2563eb;
    --bg-light: #f8fafc;
    --sidebar-bg: #0f172a;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Module Colors */
    --color-dashboard: #38bdf8; /* Sky/IT General */
    --color-portal: #f59e0b;    /* Amber/Technician Portal */
    --color-cmdb: #10b981;      /* Emerald/Maintenance Assets */
    --color-help: #f43f5e;      /* Rose/Helpdesk Support */
    --color-mgmt: #06b6d4;      /* Cyan/Logistics */
    --color-crm: #a855f7;       /* Purple/CRM */
    --color-stats: #3b82f6;     /* Blue/Analytics */
    --color-config: #94a3b8;    /* Slate/Admin */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    overflow-x: hidden;
}

#tablaEmpleados {
    white-space: nowrap;
}

#tablaEmpleados thead th, 
#tablaEmpleados tbody td {
    vertical-align: middle;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    background-color: var(--sidebar-bg);
    color: white;
    z-index: 1050;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding-top: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Premium Scrollbar for Sidebar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar .nav-link {
    color: #94a3b8;
    padding: 0.35rem 1rem;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    border-radius: 12px;
    margin: 0.03rem 0.8rem;
    transition: all 0.25s ease;
    white-space: nowrap;
    border: 1px solid transparent;
}

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

.sidebar .nav-link.active {
    background: rgba(37, 99, 235, 0.1);
    color: white;
    border-color: rgba(37, 99, 235, 0.2);
}

.sidebar .nav-link.active i {
    color: var(--accent-color);
}

/* Module Specific Icon Colors & Shadows */
.nav-module-dashboard i { color: var(--color-dashboard) !important; filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.45)); }
.nav-module-portal i { color: var(--color-portal) !important; filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.45)); }
.nav-module-cmdb i { color: var(--color-cmdb) !important; filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.45)); }
.nav-module-help i { color: var(--color-help) !important; filter: drop-shadow(0 0 4px rgba(244, 63, 94, 0.45)); }
.nav-module-mgmt i { color: var(--color-mgmt) !important; filter: drop-shadow(0 0 4px rgba(6, 182, 212, 0.45)); }
.nav-module-crm i { color: var(--color-crm) !important; filter: drop-shadow(0 0 4px rgba(168, 85, 247, 0.45)); }
.nav-module-stats i { color: var(--color-stats) !important; filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.45)); }
.nav-module-config i { color: var(--color-config) !important; filter: drop-shadow(0 0 4px rgba(148, 163, 184, 0.45)); }

/* Dynamic Indicator Border & Glowing Background on active/hover */
.sidebar .nav-link {
    position: relative;
    overflow: hidden;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 4px;
    height: 60%;
    border-radius: 0 6px 6px 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
}

/* Hover and Active border triggers */
.nav-module-dashboard:hover::before, .nav-module-dashboard.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-dashboard::before { transform: translateY(-50%) scaleY(1); }
.nav-module-portal:hover::before, .nav-module-portal.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-portal::before { transform: translateY(-50%) scaleY(1); }
.nav-module-cmdb:hover::before, .nav-module-cmdb.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-cmdb::before { transform: translateY(-50%) scaleY(1); }
.nav-module-help:hover::before, .nav-module-help.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-help::before { transform: translateY(-50%) scaleY(1); }
.nav-module-mgmt:hover::before, .nav-module-mgmt.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-mgmt::before { transform: translateY(-50%) scaleY(1); }
.nav-module-crm:hover::before, .nav-module-crm.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-crm::before { transform: translateY(-50%) scaleY(1); }
.nav-module-stats:hover::before, .nav-module-stats.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-stats::before { transform: translateY(-50%) scaleY(1); }
.nav-module-config:hover::before, .nav-module-config.active::before, .sidebar .nav-link[aria-expanded="true"].nav-module-config::before { transform: translateY(-50%) scaleY(1); }

.nav-module-dashboard::before { background-color: var(--color-dashboard); }
.nav-module-portal::before { background-color: var(--color-portal); }
.nav-module-cmdb::before { background-color: var(--color-cmdb); }
.nav-module-help::before { background-color: var(--color-help); }
.nav-module-mgmt::before { background-color: var(--color-mgmt); }
.nav-module-crm::before { background-color: var(--color-crm); }
.nav-module-stats::before { background-color: var(--color-stats); }
.nav-module-config::before { background-color: var(--color-config); }

/* Premium Glassmorphic active backgrounds corresponding to module colors */
.sidebar .nav-link.nav-module-dashboard.active, .sidebar .nav-link[aria-expanded="true"].nav-module-dashboard { background: rgba(56, 189, 248, 0.08); border-color: rgba(56, 189, 248, 0.15); color: #fff; }
.sidebar .nav-link.nav-module-portal.active, .sidebar .nav-link[aria-expanded="true"].nav-module-portal { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.15); color: #fff; }
.sidebar .nav-link.nav-module-cmdb.active, .sidebar .nav-link[aria-expanded="true"].nav-module-cmdb { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.15); color: #fff; }
.sidebar .nav-link.nav-module-help.active, .sidebar .nav-link[aria-expanded="true"].nav-module-help { background: rgba(244, 63, 94, 0.08); border-color: rgba(244, 63, 94, 0.15); color: #fff; }
.sidebar .nav-link.nav-module-mgmt.active, .sidebar .nav-link[aria-expanded="true"].nav-module-mgmt { background: rgba(6, 182, 212, 0.08); border-color: rgba(6, 182, 212, 0.15); color: #fff; }
.sidebar .nav-link.nav-module-crm.active, .sidebar .nav-link[aria-expanded="true"].nav-module-crm { background: rgba(168, 85, 247, 0.08); border-color: rgba(168, 85, 247, 0.15); color: #fff; }
.sidebar .nav-link.nav-module-stats.active, .sidebar .nav-link[aria-expanded="true"].nav-module-stats { background: rgba(59, 130, 246, 0.08); border-color: rgba(59, 130, 246, 0.15); color: #fff; }
.sidebar .nav-link.nav-module-config.active, .sidebar .nav-link[aria-expanded="true"].nav-module-config { background: rgba(148, 163, 184, 0.08); border-color: rgba(148, 163, 184, 0.15); color: #fff; }

.sidebar .nav-link i {
    font-size: 1.25rem;
    transition: transform 0.3s ease;
}

.sidebar .nav-link:hover i {
    transform: scale(1.1);
}

.sidebar .nav-link .bi-chevron-down {
    margin-left: auto;
    font-size: 0.7rem;
    transition: transform 0.3s ease;
}

.sidebar .nav-link[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

.sidebar .nav-sub-link {
    padding: 0.25rem 1.2rem 0.25rem 3.5rem;
    font-size: 0.85rem;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    text-decoration: none;
    border-radius: 8px;
    margin: 0;
}

.sidebar .nav-sub-link:hover, .sidebar .nav-sub-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.sidebar .nav-sub-link.active {
    color: white;
    font-weight: 600;
    position: relative;
}

.sidebar .nav-sub-link.active::before {
    content: '';
    position: absolute;
    left: 1.5rem;
    width: 4px;
    height: 4px;
    background: var(--accent-color);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--accent-color);
}

/* Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 2rem;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
}

@media (max-width: 1200px) {
    .main-content { padding: 1.5rem; }
}

@media (max-width: 992px) {
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 0; /* Full bleed on mobile */
    }
}

/* Top Bar */
.top-bar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    padding: 0.8rem 2rem;
    margin: -2rem -2rem 2rem -2rem; /* Matches main-content padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

@media (max-width: 1200px) {
    .top-bar { padding: 0.8rem 1.5rem; margin: -1.5rem -1.5rem 1.5rem -1.5rem; }
}

@media (max-width: 992px) {
    .top-bar { 
        padding: 0.8rem 1rem; 
        margin: 0; /* Reset margin on mobile since padding is 0 */
        background: white; 
        border-bottom: 1px solid #e2e8f0;
    }
}

/* Cards */
.card {
    border: 1px solid rgba(0,0,0,0.03);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    max-width: 100%;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--card-shadow-hover);
}

/* Industrial Scada UI */
.scada-card {
    background: var(--bg-dark-industrial);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: 20px;
    color: white;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.status-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
    animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.premium-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

/* DataTables Overrides */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px;
    padding: 5px 12px;
}

table.dataTable thead th {
    background-color: #f8fafc;
    color: var(--text-main);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    padding: 15px 20px;
    border-bottom: 2px solid #e2e8f0 !important;
}

table.dataTable tbody td {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f5f9;
}

/* Badge Styling */
.badge {
    padding: 0.6em 1em;
    font-weight: 600;
    border-radius: 8px;
    letter-spacing: 0.02em;
}

/* PJAX Transitions & Loader */
#pjax-content-wrapper {
    transition: opacity 0.2s ease-in-out;
}

#pjax-loader {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(to right, var(--accent-color), var(--color-log));
    z-index: 9999;
    width: 0;
    display: none;
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
    transition: width 0.4s ease;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1040;
}

/* Responsiveness */
@media (max-width: 992px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width));
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    }
    .sidebar.show {
        left: 0;
    }
    .sidebar.show ~ .sidebar-overlay {
        display: block;
    }
    
    /* Standard padding for non-scada responsive elements */
    .responsive-padding {
        padding: 1.25rem !important;
    }

    /* Custom Responsive Utils */
    .border-end-md { border-right: none !important; }

    .bg-industrial-dark {
        padding: 1.5rem 1rem !important;
    }
    
    .bg-industrial-dark h4 {
        font-size: 1.15rem;
    }

    .chart-container {
        padding: 1rem !important;
    }

    .sensor-card {
        padding: 0.5rem !important;
    }
    
    .sensor-card [id^="gauge"] {
        height: 120px !important;
    }
}

@media (min-width: 768px) {
    .border-end-md {
        border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
}

@media (max-width: 576px) {
    .card { border-radius: 12px; }
    .card-body { padding: 1.25rem; }
    h2 { font-size: 1.35rem; }
    h3 { font-size: 1.15rem; }
    .top-bar .dropdown-toggle span { display: none; }
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    padding: 0;
}

@media (max-width: 992px) {
    .mobile-toggle {
        display: block;
    }
}
/* Dashboard Style Circular Buttons */
.dash-btn-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid;
    background: white;
    padding: 15px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.dash-btn-circle i {
    font-size: 1.4rem;
    margin-bottom: 6px;
    display: block;
}

.dash-btn-circle:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.dash-btn-blue-outline {
    border-color: #3b82f6;
    color: #2563eb;
}

.dash-btn-blue-outline:hover {
    background: #eff6ff;
}

.dash-btn-dark-outline {
    border-color: #334155;
    color: #1e293b;
}

.dash-btn-dark-outline:hover {
    background: #f8fafc;
}

.dash-btn-navy-filled {
    background: #002060;
    border-color: #002060;
    color: white !important;
}

.dash-btn-navy-filled:hover {
    background: #003399;
    box-shadow: 0 10px 15px -3px rgba(0, 32, 96, 0.3);
}

@media (max-width: 768px) {
    .dash-btn-circle {
        width: 100px;
        height: 100px;
        font-size: 0.75rem;
    }
}

/* --- Phase 6: Specialized Ticket UI --- */

/* Specialized Banners for Ticket Modals */
.modal-banner-maint {
    background-color: #020617 !important;
    background-image: 
        radial-gradient(rgba(56, 189, 248, 0.15) 1px, transparent 1px), 
        linear-gradient(135deg, #020617 0%, #1e293b 100%) !important;
    background-size: 15px 15px, 100% 100% !important;
    background-position: center center !important;
    position: relative;
    overflow: hidden;
    color: #ffffff !important;
    border-bottom: 3px solid #38bdf8 !important;
}

.modal-banner-maint::after {
    content: "\f631"; 
    font-family: "bootstrap-icons";
    position: absolute;
    right: 15px;
    bottom: -20px;
    font-size: 100px;
    color: rgba(255, 255, 255, 0.05);
    transform: rotate(-15deg);
    pointer-events: none;
}

.modal-banner-it {
    background: linear-gradient(rgba(56, 189, 248, 0.05) 1px, transparent 1px),
                linear-gradient(90deg, rgba(56, 189, 248, 0.05) 1px, transparent 1px),
                linear-gradient(135deg, #0f172a 0%, #172554 100%) !important;
    background-size: 30px 30px, 30px 30px, 100% 100% !important;
    position: relative;
    overflow: hidden;
    color: white !important;
}

.modal-banner-it::after {
    content: "\f2c9"; 
    font-family: "bootstrap-icons";
    position: absolute;
    right: 15px;
    bottom: -20px;
    font-size: 100px;
    color: rgba(56, 189, 248, 0.07);
    transform: rotate(10deg);
    pointer-events: none;
}

/* Nav Pill Customization (Premium) */
.nav-pills-premium .nav-link {
    background: white;
    color: var(--text-muted);
    border: 1px solid #e2e8f0;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.nav-pills-premium .nav-link.active {
    background: var(--text-main);
    color: white;
    border-color: var(--text-main);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.nav-pills-premium .nav-link:hover:not(.active) {
    background: #f1f5f9;
    color: var(--text-main);
}

/* Helper for hiding cards during filtering */
.ticket-hide {
    display: none !important;
}

.ticket-show {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* Background Floating Icons Experience */
.floating-icon {
    animation: floating-icon-anim 15s ease-in-out infinite;
    opacity: 0.12;
    color: white;
}

.blur-sm { filter: blur(2px); }
.blur-md { filter: blur(4px); }

@keyframes floating-icon-anim {
    0%, 100% { transform: translateY(0) rotate(var(--rot-orig)); }
    50% { transform: translateY(-20px) rotate(calc(var(--rot-orig) + 5deg)); }
}

/* --- Mobile Optimizations & Defensive CSS --- */
@media (max-width: 768px) {
    .kpi-card { padding: 1rem !important; }
    .kpi-card h3 { font-size: 1.25rem !important; }
    .icon-box { width: 40px !important; height: 40px !important; margin-bottom: 0.5rem !important; }
    .icon-box i { font-size: 1.2rem !important; }
}

@media (max-width: 576px) {
    .asset-tile { padding: 0.5rem !important; }
    .asset-tile i { font-size: 1.2rem !important; }
    .asset-tile .fw-bold { font-size: 0.7rem !important; }
    
    /* Ensure modals take full width on very small screens */
    .modal-dialog { margin: 0.5rem; }
    
    /* Sticky bottom buttons for technical portal */
    .btn-action { height: 50px !important; font-size: 0.9rem !important; }
}

/* Prevent horizontal scroll on tables within cards */
.card .table-responsive {
    border-radius: 0 0 20px 20px;
    margin: 0;
}

/* Tooltip responsiveness */
.tooltip { font-size: 0.7rem !important; }

/* --- Fix para Menús Dropdown en Tablas --- */
.table-responsive {
    overflow: visible !important;
}

@media (max-width: 991.98px) {
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

.dropdown-menu {
    z-index: 1060 !important; /* Asegurar que esté por encima de otros elementos */
}

/* Evitar que las filas de la tabla tapen el dropdown */
.table-hover tbody tr:hover {
    z-index: 1;
    position: relative;
}

/* Vertical text column utility */
.vertical-text-column {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-orientation: mixed;
    white-space: nowrap;
    display: inline-block;
    font-size: 0.68rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

