* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f1f9ff;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.navbar {
    background-color: #2c3e50;
    padding: 15px 0;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.navbar h2 {
    margin: 0;
    font-size: 1.5rem;
}

/* --- Mobile UI/UX Redesign for Dashboard & Tables --- */
@media (max-width: 768px) {
    .container, .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .navbar {
        padding: 10px 0;
    }

    .navbar h2 {
        font-size: 1.1rem;
        padding: 0 5px;
        line-height: 1.2;
    }

    .navbar .container {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .user-info {
        flex-direction: row !important;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px !important;
        width: 100%;
    }

    .user-info span {
        font-size: 0.85rem;
    }

    .user-info a, .user-info button {
        width: 100%;
        text-align: center;
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
        border-radius: 8px !important;
    }

    /* Dashboard Grid Mobile */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Modern KPI Cards Mobile Grid */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .kpi {
        padding: 12px 10px !important;
        border-radius: 14px !important;
        background: #ffffff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
        border: 1px solid #e2e8f0 !important;
        text-align: center !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease !important;
    }

    .kpi:active {
        transform: scale(0.98) !important;
    }

    .kpi .label {
        font-size: 0.72rem !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        color: #64748b !important;
        margin-bottom: 2px !important;
    }

    .kpi .value {
        font-size: 1.4rem !important;
        font-weight: 800 !important;
    }

    /* Mobile Touch Filters Layout */
    .filters {
        padding: 16px !important;
        border-radius: 16px !important;
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03) !important;
        gap: 12px !important;
    }

    .filter-controls {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .filter-controls .field {
        width: 100% !important;
    }

    .filter-controls .field:first-child {
        grid-column: span 2 !important;
    }

    .filter-controls label {
        font-size: 0.8rem !important;
        font-weight: 700 !important;
        color: #475569 !important;
        margin-bottom: 4px !important;
        display: block !important;
    }

    .filter-controls input, 
    .filter-controls select {
        height: 42px !important;
        border-radius: 10px !important;
        border: 1px solid #cbd5e1 !important;
        font-size: 0.88rem !important;
        width: 100% !important;
        background-color: #f8fafc !important;
        padding: 6px 12px !important;
    }

    /* Mobile Ticket Cards Transformation */
    .data-table, .data-table thead, .data-table tbody, .data-table th, .data-table td, .data-table tr {
        display: block !important;
        width: 100% !important;
    }

    .data-table thead tr {
        display: none !important;
    }

    .data-table tr {
        border-radius: 16px !important;
        margin-bottom: 16px !important;
        background: #ffffff !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04) !important;
        border: 1px solid #e2e8f0 !important;
        padding: 16px !important;
        position: relative !important;
    }

    .data-table td {
        border: none !important;
        position: static !important;
        padding: 4px 0 !important;
        min-height: auto !important;
        font-size: 0.9rem !important;
    }

    .data-table td::before {
        display: none !important;
    }

    .data-table td.td-accordion-toggle {
        display: none !important;
    }

    .data-table td.collapse {
        display: block !important;
        height: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .data-table td select.status-select,
    .data-table td select.operator-select,
    .data-table td select.priority-select {
        height: 42px !important;
        font-size: 0.88rem !important;
        border-radius: 10px !important;
        margin-top: 4px !important;
        background-color: #f8fafc !important;
        border: 1px solid #cbd5e1 !important;
    }

    .data-table tr td[data-label="ID"] {
        font-weight: 800 !important;
        color: #1e293b !important;
        font-size: 0.95rem !important;
    }

    .data-table tr td[data-label="Fecha"] {
        font-size: 0.78rem !important;
        color: #64748b !important;
        margin-bottom: 6px !important;
    }

    .data-table tr td[data-label="Asunto"] {
        font-size: 1.05rem !important;
        font-weight: 700 !important;
        color: #0f172a !important;
        margin-bottom: 8px !important;
        line-height: 1.3 !important;
    }

    .data-table tr td[data-label="Acciones"] {
        margin-top: 12px !important;
        padding-top: 12px !important;
        border-top: 1px solid #f1f5f9 !important;
        display: flex !important;
        gap: 8px !important;
    }

    .data-table tr td[data-label="Acciones"] button,
    .data-table tr td[data-label="Acciones"] a {
        flex: 1 !important;
        justify-content: center !important;
        height: 42px !important;
        display: inline-flex !important;
        align-items: center !important;
        border-radius: 10px !important;
        font-weight: 700 !important;
        font-size: 0.9rem !important;
        box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2) !important;
    }

    /* Public Table Responsive Fallback */
    .public-table-responsive {
        overflow-x: auto;
        display: block;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .navbar h2 {
        font-size: 1rem;
    }
}

/* Dashboard Specific Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.dashboard-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
    transition: transform 0.3s;
    cursor: pointer;
}

.dashboard-card:hover {
    transform: translateY(-5px);
}

.card-icon {
    font-size: 40px;
    margin-bottom: 15px;
}

.kpi-panel {
    margin-top: 22px;
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); /* Más flexible */
    gap: 10px;
    margin-top: 15px;
}

.kpi {
    background: #f7fbff;
    border: 1px solid #cfe3ff;
    border-radius: 12px;
    padding: 15px 5px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    word-wrap: break-word; /* Evita que el texto se salga */
}

.kpi .label {
    color: #666;
    font-weight: 700;
    font-size: 0.9em;
    text-transform: uppercase;
}

.kpi .value {
    font-size: 2em;
    font-weight: 900;
    margin-top: 6px;
    color: #111;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.data-table th, .data-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #555;
}

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

/* Status Badges */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
}

.badge-pending { background: #ffeeba; color: #856404; }
.badge-in_progress { background: #b8daff; color: #004085; }
.badge-completed { background: #c3e6cb; color: #155724; }

.priority-high { color: #dc3545; font-weight: bold; }
.priority-medium { color: #ffc107; font-weight: bold; }
.priority-low { color: #28a745; font-weight: bold; }

/* Buttons */
.btn {
    padding: 8px 15px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.9em;
    transition: opacity 0.2s;
}

.btn:hover { opacity: 0.8; }
.btn-primary { background: #007bff; color: white; font-weight: 700; }
.btn-success { background: #28a745; color: white; }
.btn-danger { background: #dc3545; color: white; }

/* Filters */
.filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* Highlight effects for tickets with new messages */
tr.ticket-highlight-admin {
    border-left: 20px solid #ffc107;
    animation: blink-yellow 1s ease-in-out infinite;
}

tr.ticket-highlight-operator {
    border-left: 20px solid #007bff;
    animation: blink-blue 1s ease-in-out infinite;
}

@keyframes blink-yellow {
    0%, 100% { 
        border-left: 20px solid #ffc107;
        box-shadow: inset 20px 0 0 #ffc107;
    }
    50% { 
        border-left: 20px solid rgba(255, 193, 7, 0.3);
        box-shadow: inset 20px 0 0 rgba(255, 193, 7, 0.3);
    }
}

@keyframes blink-blue {
    0%, 100% { 
        border-left: 20px solid #007bff;
        box-shadow: inset 20px 0 0 #007bff;
    }
    50% { 
        border-left: 20px solid rgba(0, 123, 255, 0.3);
        box-shadow: inset 20px 0 0 rgba(0, 123, 255, 0.3);
    }
}

.filters .field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filters label {
    font-weight: bold;
    font-size: 0.9em;
}

.filters select, .filters input {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
}

/* --- Responsive Left Sidebar Layout --- */
:root {
    --sidebar-width: 280px;
    --sidebar-bg: #1e293b;
    --sidebar-color: #cbd5e1;
    --sidebar-hover-bg: #334155;
    --sidebar-active-bg: #0d6efd; /* Bootstrap Primary */
    --header-bg: #ffffff;
    --header-height: 70px;
}

.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* Sidebar */
.sidebar-nav {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg) !important;
    color: var(--sidebar-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    overflow-x: hidden;
}

.sidebar-brand {
    padding: 20px;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-user {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.sidebar-user .user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #f8fafc;
}

.sidebar-user .user-role {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.sidebar-menu {
    list-style: none;
    padding: 15px 10px !important;
    margin: 0;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-menu li {
    margin-bottom: 4px;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: #cbd5e1 !important;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    text-align: left !important;
    margin-top: 0 !important;
}

.sidebar-menu .nav-link:hover {
    background-color: var(--sidebar-hover-bg) !important;
    color: #ffffff !important;
    transform: translateX(4px);
}

.sidebar-menu .nav-link.active {
    background-color: var(--sidebar-active-bg) !important;
    color: #ffffff !important;
}

.sidebar-footer {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
}

/* Main Content Area */
.main-layout {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #f1f9ff;
}

/* Header */
.app-header {
    height: var(--header-height);
    background-color: var(--header-bg);
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #475569;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.sidebar-toggle:hover {
    background-color: #f1f5f9;
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.header-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-content {
    flex-grow: 1;
    padding: 24px 15px;
}

/* Collapsed State (Desktop) */
body.sidebar-collapsed .sidebar-nav {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-layout {
    margin-left: 0;
    width: 100%;
}

/* Mobile Sidebar Behavior */
@media (max-width: 991.98px) {
    .sidebar-nav {
        transform: translateX(-100%);
    }
    
    .main-layout {
        margin-left: 0;
        width: 100%;
    }
    
    body.sidebar-open .sidebar-nav {
        transform: translateX(0);
    }
    
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: rgba(15, 23, 42, 0.5);
        z-index: 1025;
        backdrop-filter: blur(4px);
        transition: opacity 0.3s ease;
    }
}

/* --- Table Controls Min-Widths (Desktop & general fallback) --- */
.operator-select {
    min-width: 110px;
}
.priority-select {
    min-width: 80px;
}
.status-select {
    min-width: 100px;
}

select:disabled {
    background-color: #f8fafc !important;
    color: #64748b !important;
    cursor: not-allowed;
    border-color: #e2e8f0 !important;
    opacity: 0.85;
    background-image: none !important; /* Quitar la flecha en campos deshabilitados para evitar confusión */
    padding-right: 10px !important; /* Reducir padding ya que no hay flecha */
}

/* --- Filter Inputs Equal Height & Styling --- */
.filters select, .filters input {
    height: 40px;
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: 6px;
    border: 1px solid #ddd;
    background-color: #fff;
}

/* --- Desktop Specific Table & Hover Adjustments --- */
@media (min-width: 768px) {
    .data-table th, .data-table td {
        padding: 10px 8px !important;
        vertical-align: middle;
        font-size: 0.88rem;
    }
    .data-table th {
        background-color: #f8fafc;
        color: #475569;
        font-weight: 600;
        text-transform: uppercase;
        font-size: 0.78rem;
        letter-spacing: 0.5px;
        border-bottom: 2px solid #e2e8f0;
    }
    /* Hide mobile accordion toggle column on desktop to align layout */
    .td-accordion-toggle {
        display: none !important;
    }
    /* Compact selectors in desktop table to prevent horizontal overflow */
    .status-select, .priority-select, .operator-select {
        padding: 6px 20px 6px 8px !important;
        font-size: 0.82rem !important;
        background-position: right 6px center !important;
        background-size: 12px !important;
    }
    /* Hover effects for state-colored rows */
    .row-pending:hover { background-color: #fef0cd !important; }
    .row-in_progress:hover { background-color: #bdd7ff !important; }
    .row-completed:hover { background-color: #b0e9b9 !important; }
    .row-standby:hover { background-color: #dbdcde !important; }
    .row-cancelled:hover { background-color: #f5c2c7 !important; }
}

