/* =======================================================
   Sistema Documental — Estilos Personalizados
   ======================================================= */

/* ── Sidebar ── */
.sidebar {
    border-right: 1px solid #e9ecef;
}
.sidebar .nav-link {
    border-radius: 8px;
    font-size: .88rem;
    transition: background .15s, color .15s;
}
.sidebar .nav-link:hover {
    background-color: #f0f4ff;
    color: #0d6efd !important;
}
.sidebar .nav-link.active-link {
    background-color: #e7f0ff;
    color: #0d6efd !important;
    font-weight: 600;
}

/* ── Badges de estado documental ── */
.badge-borrador    { background-color: #adb5bd; }
.badge-enviado     { background-color: #0d6efd; }
.badge-recibido    { background-color: #20c997; }
.badge-en_tramite  { background-color: #fd7e14; }
.badge-archivado   { background-color: #6c757d; }

/* ── Tarjetas ── */
.card,
.card-header,
.card-footer,
.card-img-top,
.card-img-bottom {
    border-radius: 0px !important;
}

/* ═══════════════════════════════════════════════════════
   BANDEJA — Contenedor principal
═══════════════════════════════════════════════════════ */
.tray-wrapper {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

/* ── Cabecera de bandeja ── */
.tray-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 10px;
    border-bottom: 1px solid #f1f3f4;
    background: #fff;
    gap: 16px;
}

.tray-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #202124;
    white-space: nowrap;
    flex-shrink: 0;
}

.tray-title .bi {
    font-size: 1.1rem;
    color: #5f6368;
}

.tray-title-star {
    color: #f0b429;
    font-size: .95rem;
    cursor: pointer;
    transition: transform .15s;
}
.tray-title-star:hover { transform: scale(1.2); }

/* ── Barra de búsqueda interna de la bandeja ── */
.tray-search {
    flex: 1;
    max-width: 420px;
    position: relative;
}
.tray-search input {
    width: 100%;
    border: 1px solid #dadce0;
    border-radius: 24px;
    padding: 6px 14px 6px 36px;
    font-size: .84rem;
    background: #f1f3f4;
    color: #202124;
    outline: none;
    transition: background .15s, box-shadow .15s;
}
.tray-search input:focus {
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.18);
    border-color: #b2c2ef;
}
.tray-search .bi-search {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #70757a;
    font-size: .85rem;
    pointer-events: none;
}

.tray-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Botón Nuevo — todas las pantallas */
.tray-header-actions a.btn {
    background-color: #0f6cbd !important;
    color: #fff !important;
    border: none !important;
    border-radius: 4px !important;
}

/* ═══════════════════════════════════════════════════════
   TABLA DE BANDEJA
═══════════════════════════════════════════════════════ */
.tray-table-container {
    overflow-x: auto;
    width: 100%;
}
.tray-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

/* Columnas */
.tray-table col.col-avatar   { width: 36px; }
.tray-table col.col-sender   { width: 200px; }
.tray-table col.col-subject  { width: auto; }
.tray-table col.col-date     { width: 90px; }
.tray-table col.col-priority { width: 38px; }
.tray-table col.col-signature { width: 38px; }
.tray-table col.col-attachment { width: 38px; }

/* ── Cabecera de columnas ── */
.tray-table thead th {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #70757a;
    font-weight: 500;
    padding: 6px 8px;
    border-bottom: 1px solid #f1f3f4;
    background: #fff;
    white-space: nowrap;
    overflow: hidden;
}
.tray-table thead th.th-center { text-align: center; }
.tray-table thead th.th-right  { text-align: right; }

/* ── Filas ── */
.tray-table tbody tr.doc-row {
    border-bottom: 1px solid #dde3ec;
    cursor: pointer;
    transition: background-color 0.08s, box-shadow 0.08s;
    position: relative;
    font-size: .83rem;
}

.tray-table tbody tr.doc-row.row-even {
    background-color: #ffffff;
}

.tray-table tbody tr.doc-row.row-odd {
    background-color: #edf2fb;   /* azul muy pálido intercalado */
}

.tray-table tbody tr.doc-row.unread {
    background-color: #dceeff !important;
    font-weight: 700;
}

.tray-table tbody tr.doc-row:hover {
    background-color: #dceeff !important;
    box-shadow: inset 2px 0 0 #1a73e8, inset -1px 0 0 #c5d2e8,
                0 2px 4px rgba(60,64,67,.12);
    z-index: 5;
}

/* Fila de reasignado ya atendido/archivado */
.doc-row-archived {
    background-color: #f1f3f4 !important;
    opacity: 0.7;
    filter: grayscale(0.8);
}
.doc-row-archived:hover {
    opacity: 0.9;
    filter: grayscale(0.4);
}

/* Celdas */
.tray-table tbody td {
    padding: 5px 8px;
    vertical-align: middle;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   AVATAR con iniciales
═══════════════════════════════════════════════════════ */
.sender-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .55rem;
    font-weight: 700;
    letter-spacing: 0;
    flex-shrink: 0;
    margin: 0 auto;
    color: #fff;
    text-transform: uppercase;
    user-select: none;
    overflow: hidden;
}
.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Paleta de colores para avatares */
.av-color-0 { background-color: #1a73e8; }
.av-color-1 { background-color: #d93025; }
.av-color-2 { background-color: #188038; }
.av-color-3 { background-color: #e37400; }
.av-color-4 { background-color: #7b1fa2; }
.av-color-5 { background-color: #00838f; }
.av-color-6 { background-color: #c2185b; }
.av-color-7 { background-color: #5d4037; }

/* ═══════════════════════════════════════════════════════
   CELDA EMISOR / DESTINATARIO
═══════════════════════════════════════════════════════ */
.sender-name {
    font-size: .83rem;
    font-weight: 400;
    color: #5f6368;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
.doc-row.unread .sender-name {
    font-weight: 800;
    color: #0d2240;    /* negro azulado para máximo contraste */
}

/* ═══════════════════════════════════════════════════════
   CELDA ASUNTO + PREVIEW
═══════════════════════════════════════════════════════ */
.subject-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
}

.subject-main {
    font-size: .83rem;
    font-weight: 400;
    color: #5f6368;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 55%;
}
.doc-row.unread .subject-main {
    font-weight: 800;
    color: #0d2240;    /* negro azulado */
}

.subject-sep {
    color: #bdc1c6;
    font-size: .78rem;
    flex-shrink: 0;
}

.subject-preview {
    font-size: .82rem;
    color: #70757a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Código de rastreo (tracking code) */
.doc-code-sm {
    font-family: 'Courier New', monospace;
    font-size: .62rem;
    color: #70757a;
    background: #f1f3f4;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    flex-shrink: 0;
}
.doc-row.unread .doc-code-sm {
    background: #e8f0fe;
    color: #1a73e8;
    font-weight: 700;
}

/* label-pill (tipo documental, estado) */
.label-pill {
    font-size: .62rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   CELDA FECHA
═══════════════════════════════════════════════════════ */
.date-cell {
    text-align: right;
    font-size: .8rem;
    color: #70757a;
    white-space: nowrap;
    position: relative;
}
.doc-row.unread .date-cell {
    font-weight: 600;
    color: #202124;
}

/* Acciones flotantes al hover */
.row-actions {
    display: none;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    gap: 4px;
    background: linear-gradient(to right, transparent, #eaf1fb 28%);
    padding-left: 24px;
    align-items: center;
}
.doc-row:hover .date-text    { visibility: hidden; }
.doc-row:hover .row-actions  { display: flex; }

/* ═══════════════════════════════════════════════════════
   CELDA PRIORIDAD — Bandera de color
═══════════════════════════════════════════════════════ */
.priority-cell {
    text-align: center;
}
.priority-flag {
    display: inline-flex;
    font-size: 1rem;
    opacity: .85;
}
.priority-flag.pf-high   { color: #d93025; }
.priority-flag.pf-normal { color: #34a853; }
.priority-flag.pf-low    { color: #bdc1c6; }

/* ═══════════════════════════════════════════════════════
   CELDA FIRMA / ADJUNTOS
═══════════════════════════════════════════════════════ */
/* Iconos de Firma / Adjuntos */
.bi.has-sig { 
    color: #1a73e8 !important; /* Azul */
    font-size: 1.1rem;
}
.bi.has-att { 
    color: #1e8e3e !important; /* Verde */
    font-size: 1.1rem;
}

/* ═══════════════════════════════════════════════════════
   ESTADO VACÍO
═══════════════════════════════════════════════════════ */
.tray-empty {
    padding: 56px 24px;
    text-align: center;
    color: #9aa0a6;
}
.tray-empty .bi {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 16px;
    opacity: .3;
}
.tray-empty p {
    font-size: .9rem;
    margin: 0;
}

/* ═══════════════════════════════════════════════════════
   PAGINACIÓN
═══════════════════════════════════════════════════════ */
.tray-pagination {
    padding: 10px 20px;
    border-top: 1px solid #f1f3f4;
    font-size: .8rem;
    color: #70757a;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    background: #fff;
}

/* ─── Formularios ─── */
.form-label { font-size: .875rem; }

/* ─── Filtro en tiempo real de bandeja ─── */
.tray-search-hidden { display: none !important; }

/* ── Estilos para Bandeja de Documentos en Móviles (Estilo Outlook) ── */
@media (max-width: 767.98px) {
    /* Ajustes generales de la tabla en móvil para remover bordes de celda y añadir espaciado limpio */
    .tray-wrapper {
        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }
    
    .tray-table-container {
        overflow-x: hidden !important;
        width: 100% !important;
    }
    
    .tray-table {
        border-collapse: collapse !important;
        width: 100% !important;
        table-layout: auto !important;
    }
    
    .tray-table tbody tr.doc-row {
        border-bottom: 1px solid #dde3ec !important;
        transition: background-color 0.15s ease;
    }
    .tray-table tbody tr.doc-row.row-even {
        background-color: #ffffff !important;
    }
    .tray-table tbody tr.doc-row.row-odd {
        background-color: #edf2fb !important;
    }
    
    .tray-table tbody tr.doc-row:hover {
        background-color: #dceeff !important;
        box-shadow: none !important;
    }
    
    /* Fila no leída (alternada con borde azul) */
    .tray-table tbody tr.doc-row.unread {
        /* Mantiene el intercalado en móviles, el borde azul izquierdo lo diferencia */
    }
    
    /* Celda móvil */
    .outlook-mobile-td {
        padding: 6px 10px !important; /* Margen y padding mínimos */
        position: relative !important;
        border-left: 4px solid transparent !important;
    }
    
    .outlook-mobile-td .gap-3 {
        gap: 8px !important; /* Reducir separación del avatar */
    }
    
    .outlook-mobile-td .mb-1 {
        margin-bottom: 2px !important; /* Espaciado mínimo vertical */
    }
    
    .outlook-mobile-td .mt-1 {
        margin-top: 2px !important;
    }
    
    .unread .outlook-mobile-td {
        border-left-color: #0078d4 !important; /* Azul Outlook */
    }
    
    /* Avatar móvil estilo Outlook */
    .outlook-avatar {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 500;
        font-size: 0.8rem;
        color: #ffffff;
        flex-shrink: 0;
        position: relative;
    }
    
    /* Fila 1: Remitente y fecha */
    .outlook-sender-name {
        font-size: 0.8rem; /* Tamaño proporcional */
        color: #323130;
        font-weight: 400;
    }
    .unread .outlook-sender-name {
        font-weight: 700;
        color: #242424 !important;
    }
    
    .outlook-date {
        font-size: 0.68rem;
        color: #605e5c;
    }
    .unread .outlook-date {
        font-weight: 600;
        color: #0078d4 !important;
    }
    
    /* Fila 2: Asunto */
    .outlook-subject {
        font-size: 0.72rem; /* 2px menos (aprox. 11.5px) */
        color: #323130;
        font-weight: 400;
    }
    .unread .outlook-subject {
        font-weight: 500;
        color: #0078d4 !important;
    }
    
    /* Fila 3: Preview de 2 líneas */
    .outlook-preview {
        font-size: 0.78rem;
        color: #605e5c;
        line-height: 1.35;
        margin-bottom: 6px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: normal;
    }
    .unread .outlook-preview {
        color: #005a9e !important;
    }
    
    /* Fila 4: Badges estilo Outlook (sutiles y pequeños) */
    .outlook-badge {
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
        border-radius: 4px !important;
        font-weight: 500 !important;
        border: none !important;
    }
    
    .outlook-badge-priority {
        background-color: #f2f2f2 !important;
        color: #323130 !important;
    }
    .outlook-badge-priority-alta {
        background-color: #fde7e9 !important;
        color: #a80000 !important;
    }
    .outlook-badge-priority-normal {
        background-color: #e6f4ea !important;
        color: #137333 !important;
    }
    .outlook-badge-priority-baja {
        background-color: #f3f2f1 !important;
        color: #605e5c !important;
    }
    
    .outlook-badge-signed {
        background-color: #e8f0fe !important;
        color: #1a73e8 !important;
    }
    
    .outlook-badge-attachments {
        background-color: #e6f4ea !important;
        color: #137333 !important;
    }
    
    .outlook-badge-status {
        background-color: #f3f2f1 !important;
        color: #323130 !important;
    }
    /* ── Cabecera de bandeja en móviles ── */
    .tray-header {
        display: grid !important;
        grid-template-columns: 1fr auto !important;
        grid-template-rows: auto auto !important;
        row-gap: 8px !important;
        column-gap: 12px !important;
        padding: 10px 12px !important;
        align-items: center !important;
        background: #ffffff !important;
        border-bottom: 1px solid #f3f2f1 !important;
    }
    
    .tray-title {
        grid-column: 1 !important;
        grid-row: 1 !important;
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        color: #242424 !important;
        max-width: 50vw !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .tray-header-actions {
        grid-column: 2 !important;
        grid-row: 1 !important;
        justify-self: end !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }
    
    /* Ocultar el contador de documentos en móvil para dar espacio completo al botón Nuevo */
    .tray-header-actions .badge {
        display: none !important;
    }
    
    /* Hacer el botón Nuevo más compacto en móviles */
    .tray-header-actions a.btn {
        padding: 3px 10px !important;
        font-size: 0.72rem !important;
        border-radius: 4px !important;
        white-space: nowrap !important;
        background-color: #0f6cbd !important;
        color: #fff !important;
        border: none !important;
    }
    
    .tray-search {
        grid-column: 1 / span 2 !important;
        grid-row: 2 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    .tray-search input {
        border-radius: 8px !important;
        background-color: #f3f2f1 !important;
        border: 1px solid transparent !important;
        font-size: 0.8rem !important;
        padding: 6px 12px 6px 32px !important;
    }
    
    .tray-search input:focus {
        background-color: #ffffff !important;
        border-color: #0078d4 !important;
        box-shadow: none !important;
    }
    
    .tray-search .bi-search {
        left: 10px !important;
        font-size: 0.78rem !important;
    }
    
    /* ── Pestañas de Detalle de Documento ── */
    .quipux-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
        scrollbar-width: none !important; /* Firefox */
        border-bottom: 1px solid #edebe9 !important;
        padding-bottom: 2px !important;
        max-width: 100% !important;
    }
    .quipux-tabs::-webkit-scrollbar {
        display: none !important; /* Safari and Chrome */
    }
    .quipux-tab {
        padding: 6px 12px !important;
        font-size: 0.78rem !important;
        flex-shrink: 0 !important;
    }
    .quipux-tab-content {
        padding: 8px !important;
        border-top: none !important;
    }
    
    /* ── Ribbon de Acciones Móvil ── */
    .office-ribbon {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        background-color: #f3f2f1 !important;
        border: none !important;
        margin-bottom: 8px !important;
        border-radius: 4px !important;
    }
    .office-ribbon-content {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        padding: 2px 5px !important;
        min-height: 52px !important;
        gap: 0 !important;
        margin: 0 !important;
        background-color: #f3f2f1 !important;
    }
    .office-ribbon-content::-webkit-scrollbar {
        display: none !important;
    }
    .office-ribbon-group {
        border-right: none !important;
        padding: 0 !important;
        margin: 0 !important;
        display: flex !important;
        gap: 0 !important;
        flex-shrink: 0 !important;
    }
    .office-ribbon-group-title {
        display: none !important;
    }
    .office-btn {
        min-width: 44px !important;
        padding: 4px 6px !important;
        font-size: 0.65rem !important;
        flex-shrink: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        background: linear-gradient(to bottom, #ffffff 0%, #e8e8e8 100%) !important;
        border: none !important;
        border-radius: 2px !important;
        margin: 0 !important;
        box-shadow: inset 0 1px 0 rgba(255,255,255,0.85), 0 1px 2px rgba(0,0,0,0.08) !important;
    }
    .office-btn i {
        font-size: 1.1rem !important;
        margin-bottom: 2px !important;
        display: block !important;
    }
    .office-btn > span {
        font-size: 0.58rem !important;
        line-height: 1 !important;
        margin-top: 1px !important;
    }
    
    /* ── Tabla de Metadatos Apilada ── */
    .quipux-table-sla {
        border-left: 4px solid #ccc !important; /* Mantener la barra SLA */
    }
    .quipux-table, 
    .quipux-table tbody, 
    .quipux-table tr, 
    .quipux-table th, 
    .quipux-table td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .quipux-table tr {
        border: none !important;
        margin-bottom: 6px !important;
    }
    .quipux-table th {
        text-align: left !important;
        background-color: #f3f2f1 !important;
        color: #323130 !important;
        font-size: 0.72rem !important;
        padding: 4px 8px !important;
        font-weight: 700 !important;
        border: none !important;
        border-radius: 2px !important;
    }
    .quipux-table td {
        background-color: #ffffff !important;
        color: #323130 !important;
        padding: 4px 8px 8px 8px !important;
        font-size: 0.76rem !important;
        border-bottom: 1px solid #f3f2f1 !important;
        margin-bottom: 8px !important;
    }
    /* Permitir que los campos "Para" y "Con copia a" aprovechen el ancho completo sin cortarse */
    .quipux-table td div[style*="max-width"] {
        max-width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    
    /* Contenedor de PDF móvil: ajustar altura y evitar desbordamiento horizontal */
    .pdf-container {
        min-height: auto !important;
        height: 500px !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
        background-color: #f8fafc !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 6px !important;
        padding: 0 !important; /* Eliminar padding para que el embed ocupe el ancho total */
    }
    .pdf-container embed,
    .pdf-container iframe {
        width: 100% !important;
        max-width: 100% !important;
        height: 100% !important;
        display: block !important;
        box-sizing: border-box !important;
    }
}
