@import 'tokens.css';

/* --- SISTEMA DE DISEÑO PREMIUM - GRUPO ALLEGUE (INCIDENCIAS) --- */

:root {
    --primary-color: #bd0f32; /* Rojo Corporativo Oficial */
    --primary-hover: #9c0c28;
    --secondary-color: #d97706; /* Dorado elegante */
    --secondary-hover: #b45309;
    --dark-bg: #2b2b2b; /* Gris oscuro para textos principales */
    --dark-surface: #374151; /* Gris carbón */
    --light-bg: #ebebeb; /* Gris claro oficial */
    --text-main: #222222;
    --text-muted: #555555;
    --white: #ffffff;
    --border-color: #cccccc;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --shadow-premium: 0 10px 20px -3px rgba(189, 15, 50, 0.1), 0 4px 6px -4px rgba(189, 15, 50, 0.05);
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Open Sans', sans-serif;
    
    --font-weight-regular: 400;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    
    --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: var(--font-body);
    font-size: var(--body-font-size);
    background-color: var(--light-bg);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100%;
    overflow-x: hidden;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: var(--font-weight-bold);
    letter-spacing: -0.01em;
    color: var(--dark-bg);
}

h1 { font-size: var(--h1-size); }
h2 { font-size: var(--h2-size); }

/* --- BOTONES --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: var(--font-weight-semibold);
    padding: var(--btn-padding-y) var(--btn-padding-x);
    height: var(--btn-height);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-size: 0.9rem;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--white);
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-dark {
    background-color: var(--dark-bg);
    color: var(--white);
}

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

.btn-light {
    background-color: var(--white);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-light:hover {
    background-color: #f3f4f6;
    border-color: #999;
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    height: auto;
    border-radius: var(--radius-sm);
}

/* --- ESTRUCTURA GENERAL DEL LAYOUT (SI LA SESIÓN ESTÁ INICIADA) --- */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--white);
    color: var(--text-main);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    flex-shrink: 0;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 99;
    border-right: 1px solid var(--border-color);
}

/* Botón flotante para colapsar sidebar */
.sidebar-toggle-btn {
    position: absolute;
    top: 20px;
    right: -10px;
    width: 20px;
    height: 20px;
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    color: var(--text-muted);
    z-index: 100;
    transition: var(--transition);
}

.sidebar-toggle-btn:hover {
    color: var(--primary-color);
    background-color: #f8fafc;
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.sidebar-toggle-btn i {
    font-size: 0.75rem;
    transition: transform 0.3s ease-in-out;
}

/* --- ESTADO COLAPSADO DEL SIDEBAR --- */
.app-container.sidebar-collapsed .sidebar {
    width: 60px; /* Ancho compacto */
    padding: var(--space-md) var(--space-xs); /* Menos padding lateral */
}

/* Ocultar elementos de texto y user profile */
.app-container.sidebar-collapsed .sidebar-title,
.app-container.sidebar-collapsed .sidebar-user,
.app-container.sidebar-collapsed .sidebar-link span,
.app-container.sidebar-collapsed .sidebar-footer span {
    display: none !important;
}

/* Ajustar el logo en modo colapsado */
.app-container.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding-bottom: var(--space-xs);
    border-bottom: none;
}
.app-container.sidebar-collapsed .sidebar-logo {
    height: 32px;
}

/* Centrar los iconos en los enlaces */
.app-container.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 10px 0;
    position: relative;
}

.app-container.sidebar-collapsed .sidebar-link i {
    margin: 0;
    font-size: 1.2rem;
}

/* Badge de chat flotante en modo colapsado */
.app-container.sidebar-collapsed .sidebar-link .contact-badge {
    position: absolute;
    top: 2px;
    right: 6px;
    margin-left: 0;
    font-size: 0.65rem;
    padding: 1px 4px;
    min-width: 14px;
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

@media (max-width: 768px) {
    .sidebar-toggle-btn {
        display: none !important;
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    height: 36px;
    width: auto;
}

.sidebar-title {
    color: var(--text-main);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.sidebar-user {
    padding: var(--space-sm);
    background-color: #f1f5f9;
    color: var(--text-main);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-xs);
    border: 1px solid var(--border-color);
}

.sidebar-user .name {
    font-weight: var(--font-weight-semibold);
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .role {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-grow: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
}

.sidebar-link i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: var(--transition);
}

.sidebar-link:hover, .sidebar-link.active {
    color: var(--white);
    background-color: var(--primary-color);
}

.sidebar-link:hover i, .sidebar-link.active i {
    color: var(--white);
}

.sidebar-footer {
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.sidebar-logout {
    color: #e11d48 !important;
}

.sidebar-logout i {
    color: #e11d48 !important;
}

.sidebar-logout:hover {
    background-color: #be123c !important;
    color: var(--white) !important;
}

.sidebar-logout:hover i {
    color: var(--white) !important;
}

/* --- MAIN CONTENT AREA --- */
.main-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-width: 0;
}

.top-bar {
    height: 56px;
    background-color: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 90;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--dark-bg);
}

.top-bar-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.main-content {
    flex-grow: 1;
    padding: var(--space-lg);
    overflow-y: auto;
    min-width: 0;
}

/* --- RESPONSIVE SIDEBAR MOBILE --- */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        top: 0;
        bottom: 0;
        box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .main-content {
        padding: var(--space-md);
    }
    
    .top-bar {
        padding: 0 var(--space-md);
    }
}

/* --- PORTAL DE LOGIN --- */
.login-body {
    background-color: var(--light-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-md);
}

.login-card {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-premium);
    width: 100%;
    max-width: 420px;
    padding: var(--space-xl) var(--space-lg);
    border-top: 5px solid var(--primary-color);
    animation: fadeInUp 0.4s ease-out;
}

.login-logo-container {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.login-logo {
    height: 60px;
    width: auto;
}

.login-title {
    text-align: center;
    font-size: 1.6rem;
    margin-bottom: var(--space-xs);
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: var(--space-lg);
}

/* --- FORMULARIOS --- */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-weight: var(--font-weight-semibold);
    font-size: 0.88rem;
    margin-bottom: 6px;
    color: var(--dark-bg);
}

.form-control {
    width: 100%;
    padding: var(--input-padding-y) var(--input-padding-x);
    height: var(--input-height);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--white);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(189, 15, 50, 0.15);
}

.form-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- BANNER DE ALERTAS --- */
.alert {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    border: 1px solid transparent;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: #d1fae5;
    border-color: #a7f3d0;
    color: #065f46;
}

.alert-danger {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.alert-warning {
    background-color: #fef3c7;
    border-color: #fcd34d;
    color: #92400e;
}

/* --- CARDS Y LAYOUT DE DASHBOARD --- */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--grid-gap);
    margin-bottom: var(--space-lg);
}

.metric-card {
    background-color: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.metric-card.primary { border-left-color: var(--primary-color); }
.metric-card.success { border-left-color: var(--success); }
.metric-card.warning { border-left-color: var(--warning); }
.metric-card.danger { border-left-color: var(--danger); }
.metric-card.info { border-left-color: var(--info); }

.metric-card-info h3 {
    font-size: 1.8rem;
    line-height: 1.2;
}

.metric-card-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-card-icon {
    font-size: 1.8rem;
    color: #9ca3af;
}

.metric-card.primary .metric-card-icon { color: var(--primary-color); }
.metric-card.success .metric-card-icon { color: var(--success); }
.metric-card.warning .metric-card-icon { color: var(--warning); }
.metric-card.danger .metric-card-icon { color: var(--danger); }
.metric-card.info .metric-card-icon { color: var(--info); }

/* --- SECCIÓN GRID DASHBOARD Y AVISOS --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--grid-gap);
    align-items: start;
    min-width: 0;
}

.dashboard-grid > div {
    min-width: 0;
}

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

/* Custom grid 3:2 layout for Coordinadoras */
.dashboard-grid.grid-3-2 {
    grid-template-columns: 3fr 2fr;
}

/* Generic form grid rows that stack on mobile/tablet */
.form-grid-2-1,
.form-grid-1-1 {
    display: grid;
    gap: var(--grid-gap);
}

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

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

@media (max-width: 992px) {
    .dashboard-grid.grid-3-2 {
        grid-template-columns: 1fr;
    }
    .form-grid-2-1,
    .form-grid-1-1 {
        grid-template-columns: 1fr;
    }
}

.card {
    background-color: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-lg);
    min-width: 0;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* --- TABLÓN DE ANUNCIOS / CENTRO DE AVISOS --- */
.avisos-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
}

.aviso-item {
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    transition: var(--transition);
}

.aviso-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: #bbb;
}

.aviso-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.aviso-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
}

.aviso-badge.RPA { background-color: #fee2e2; color: #991b1b; }
.aviso-badge.RPH { background-color: #fef3c7; color: #92400e; }
.aviso-badge.RPJ { background-color: #d1fae5; color: #065f46; }
.aviso-badge.RAN { background-color: #e0f2fe; color: #0369a1; }
.aviso-badge.RBN { background-color: #f3e8ff; color: #6b21a8; }
.aviso-badge.ADMIN { background-color: #e2e8f0; color: #334155; }

.aviso-item-title {
    font-size: 0.95rem;
    font-weight: var(--font-weight-semibold);
    color: var(--dark-bg);
    margin-bottom: 4px;
}

.aviso-item-body {
    font-size: 0.85rem;
    color: #374151;
}

.aviso-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    margin-top: 8px;
    color: var(--text-muted);
}

/* --- TABLAS RESPONSIVAS --- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--white);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    text-align: left;
}

.table th {
    background-color: #f3f4f6;
    color: var(--dark-bg);
    font-weight: var(--font-weight-semibold);
    padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

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

.table tr:hover td {
    background-color: #f9fafb;
}

/* Badges de Estado */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 30px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-pendiente { background-color: #fef3c7; color: #d97706; }
.badge-procesado { background-color: #e0f2fe; color: #0284c7; }
.badge-solucionado { background-color: #d1fae5; color: #059669; }
.badge-rechazado { background-color: #fee2e2; color: #dc2626; }

.badge-prioridad-baja { background-color: #f3f4f6; color: #4b5563; }
.badge-prioridad-media { background-color: #eff6ff; color: #2563eb; }
.badge-prioridad-alta { background-color: #fff7ed; color: #ea580c; }
.badge-prioridad-critica { background-color: #fef2f2; color: #dc2626; }

.badge-tiempo-alerta {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    animation: pulseRed 2s infinite;
}

@keyframes pulseRed {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* --- FILTROS Y BARRA DE BÚSQUEDA --- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    background-color: #f3f4f6;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    border: 1px solid var(--border-color);
}

.filter-item {
    flex: 1 1 180px;
}

/* --- MODALES --- */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    backdrop-filter: blur(2px);
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
}
.modal-close:hover {
    color: var(--dark-bg);
}

.modal-body {
    padding: var(--space-lg);
    flex-grow: 1;
}

.modal-footer {
    padding: var(--space-sm) var(--space-lg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* --- EVIDENCIAS EN MODAL (4 IMÁGENES) --- */
.evidencia-galeria {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.evidencia-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
}

.evidencia-card-title {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 6px;
    background-color: #f3f4f6;
    text-align: center;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.evidencia-img-container {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
}

.evidencia-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    width: 100%;
    height: 100%;
}

.evidencia-empty {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* --- CHAT PRIVADO --- */
.chat-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 120px);
    background-color: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

@media (max-width: 768px) {
    .chat-container {
        grid-template-columns: 1fr;
    }
    
    .chat-sidebar {
        display: block;
    }
    .chat-sidebar.hidden-mobile {
        display: none;
    }
    
    .chat-area {
        display: none;
    }
    .chat-area.active-mobile {
        display: flex !important;
    }
}

.chat-sidebar {
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: #f9fafb;
}

.chat-search {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.chat-contacts-list {
    flex-grow: 1;
    overflow-y: auto;
    list-style: none;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: var(--transition);
}

.contact-item:hover, .contact-item.active {
    background-color: #f3f4f6;
}

.contact-item.active {
    border-left: 4px solid var(--primary-color);
}

.contact-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--dark-bg);
    flex-shrink: 0;
}

.contact-info {
    flex-grow: 1;
    min-width: 0;
}

.contact-info-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 2px;
}

.contact-name {
    font-size: 0.85rem;
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--dark-bg);
}

.contact-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.contact-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-badge {
    background-color: var(--primary-color);
    color: var(--white);
    font-size: 0.68rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 700;
}

/* Chat window area */
.chat-area {
    display: flex;
    flex-direction: column;
    background-color: #f3f4f6;
    height: 100%;
}

.chat-header {
    background-color: var(--white);
    padding: 12px var(--space-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding-right: 8px;
}

@media (max-width: 768px) {
    .chat-back-btn {
        display: block;
    }
}

.chat-messages {
    flex-grow: 1;
    padding: var(--space-md);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
    position: relative;
}

.message-bubble.incoming {
    background-color: var(--white);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message-bubble.outgoing {
    background-color: var(--primary-color);
    color: var(--white);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.message-time {
    font-size: 0.65rem;
    color: rgba(0,0,0,0.4);
    text-align: right;
    margin-top: 4px;
}

.message-bubble.outgoing .message-time {
    color: rgba(255,255,255,0.7);
}

.chat-input-area {
    background-color: var(--white);
    padding: 12px;
    border-top: 1px solid var(--border-color);
}

.chat-form {
    display: flex;
    gap: 10px;
}

/* --- ANIMACIÓN ENTRADA --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- ESTILOS DE IMPRESIÓN / EXPORTACIÓN PDF --- */
@media print {
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
        font-size: 10pt !important;
        padding: 0 !important;
    }
    
    .sidebar, .top-bar, .no-print, .btn, .filter-bar, .chat-input-area, .chat-sidebar {
        display: none !important;
    }
    
    .main-wrapper, .main-content, .card {
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        background: none !important;
    }
    
    .table {
        font-size: 9pt !important;
        border: 1px solid #000000 !important;
    }
    
    .table th, .table td {
        border: 1px solid #000000 !important;
        padding: 6px !important;
    }
    
    .table th {
        background-color: #eaeaea !important;
        color: #000000 !important;
    }
    
    .print-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        border-bottom: 2px solid #000000;
        padding-bottom: 10px;
        margin-bottom: 20px;
    }
    
    .print-logo {
        height: 40px;
        width: auto;
    }
}

.print-header {
    display: none;
}

/* --- ESTILOS DE SEMÁFORO Y TABLA DE CARNES PREMIUM --- */
.corte-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    margin-bottom: var(--space-md);
    background-color: var(--white);
}

.corte-table th, .corte-table td {
    border: 1px solid var(--border-color);
    padding: 8px var(--space-xs);
    vertical-align: middle;
    text-align: center;
}

.corte-table th {
    background-color: #f3f4f6;
    font-weight: 700;
    color: var(--dark-bg);
}

.corte-table td.left-align {
    text-align: left;
    font-weight: 600;
}

.corte-table input[type="text"],
.corte-table input[type="number"],
.corte-table input[type="time"],
.corte-table select {
    width: 100%;
    padding: 4px 6px;
    height: 32px;
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Semáforo de Aceptación */
.semaforo-group {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.semaforo-btn {
    border: 1px solid var(--border-color);
    background-color: var(--white);
    padding: 4px 8px;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
}

.semaforo-btn.green.active, .semaforo-btn.green:hover {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
    color: var(--white) !important;
}

.semaforo-btn.yellow.active, .semaforo-btn.yellow:hover {
    background-color: var(--warning) !important;
    border-color: var(--warning) !important;
    color: var(--white) !important;
}

.semaforo-btn.red.active, .semaforo-btn.red:hover {
    background-color: var(--danger) !important;
    border-color: var(--danger) !important;
    color: var(--white) !important;
}

/* Contenedor de subida de evidencias por corte */
.corte-uploads {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    padding: 10px;
    background-color: #f9fafb;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    margin-top: 8px;
    text-align: left;
}

.corte-upload-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.corte-upload-item label {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
}

.corte-upload-item input[type="file"] {
    font-size: 0.68rem;
}

/* Badge semáforo */
.badge-semaforo {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}
.badge-semaforo.aceptado { background-color: #d1fae5; color: #065f46; }
.badge-semaforo.condicionado { background-color: #fef3c7; color: #92400e; }
.badge-semaforo.rechazado { background-color: #fee2e2; color: #991b1b; }

.corte-row-disabled {
    background-color: #f3f4f6;
    opacity: 0.6;
}

/* --- GRID PARA SUBIR ARCHIVOS GENERALES Y OPTIMIZACIONES --- */
.file-upload-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gap);
}

@media (max-width: 768px) {
    .file-upload-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Corrección de altura y padding en selectores de archivos nativos */
input[type="file"].form-control {
    height: auto !important;
    padding: 6px 10px !important;
    font-size: 0.8rem;
    line-height: 1.5;
}
