/* ==========================================================================
   Contabilidad General Express - Módulo Asientos Contables (Journal Entries CSS)
   Layout de Dos Paneles + Grilla de Edición Continuada Estilo Procesador
   ========================================================================== */

.journalentries-wrapper {
    display: flex;
    min-height: calc(100vh - 70px);
    background-color: #f8fafc;
    width: 100%;
}

/* ==========================================================================
   PANEL IZQUIERDO: Listado y Filtros
   ========================================================================== */
.journal-left-panel {
    width: 380px;
    min-width: 340px;
    background-color: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.journal-left-panel .panel-header {
    padding: 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.journal-left-panel .panel-title-box {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.journal-left-panel .panel-title-box > div {
    min-width: 0;
    flex: 1;
}

.journal-left-panel .panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.journal-left-panel .panel-subtitle {
    font-size: 0.775rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#btn-new-entry {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: 600;
}

.filters-bar {
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    background-color: #fafafa;
}

.filters-bar .search-box {
    position: relative;
    margin-bottom: 10px;
}

.filters-bar .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.filters-bar .search-box input {
    padding-left: 32px;
    border-radius: var(--radius-md);
}

.filters-row {
    display: flex;
    gap: 8px;
}

.filters-row .filter-col {
    flex: 1;
}

/* Lista de Asientos */
.entries-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Paginación del Panel Izquierdo */
.entries-pagination-bar {
    padding: 10px 16px;
    background-color: #ffffff;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.entries-pagination-bar .btn-page {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: #ffffff;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.entries-pagination-bar .btn-page:hover:not(:disabled) {
    background-color: #f1f5f9;
    border-color: var(--border-hover);
    color: #2563eb;
}

.entries-pagination-bar .btn-page:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.entries-pagination-bar .pagination-info {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.entry-card-item {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.entry-card-item:hover {
    border-color: var(--border-hover);
    background-color: #f8fafc;
    box-shadow: var(--shadow-sm);
}

.entry-card-item.active {
    border-color: #f59e0b; /* Acento Amarillo Cálido */
    background-color: #fffbeb;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.entry-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.entry-date {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.entry-status-icon {
    font-size: 0.9rem;
}

.entry-status-icon.closed {
    color: #ef4444; /* Candado rojo */
}

.entry-status-icon.draft {
    color: #f59e0b; /* Lápiz amarillo borrador */
}

.entry-summary-title {
    font-size: 0.925rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.35;
    word-break: break-word;
}

.entry-card-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.775rem;
    color: var(--text-muted);
    border-top: 1px dashed #e2e8f0;
    padding-top: 6px;
}

.entry-ref-badge {
    background-color: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

.entry-amount-badge {
    font-weight: 700;
    color: #0f172a;
}

.entry-unbalanced-tag {
    color: #dc2626;
    font-weight: 700;
}

/* ==========================================================================
   PANEL DERECHO: Editor de Asiento
   ========================================================================== */
.journal-right-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    overflow-y: auto;
}

/* Barra de Acciones Superior */
.editor-action-bar {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background-color: #ffffff;
}

.editor-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.editor-id-badge {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.status-draft {
    background-color: #fef3c7;
    color: #92400e;
}

.status-badge.status-closed {
    background-color: #fee2e2;
    color: #991b1b;
}

.editor-buttons-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Formulario Cabecera */
.editor-header-form {
    padding: 20px 24px 16px 24px;
    background-color: #fafafa;
    border-bottom: 1px solid var(--border-color);
}

.form-row-header {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row-header .col-summary {
    flex: 2;
    min-width: 260px;
}

.form-row-header .col-ref {
    flex: 1;
    min-width: 140px;
}

.form-row-header .col-date {
    flex: 1;
    min-width: 140px;
}

/* Grilla Continuada Estilo Procesador */
.editor-grid-wrapper {
    flex: 1;
    padding: 16px 24px;
    overflow-x: auto;
    position: relative;
}

.clean-grid-table {
    width: 100%;
    border-collapse: collapse;
}

.clean-grid-table th {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 10px 12px;
    border-bottom: 2px solid #e2e8f0;
    text-align: left;
}

.clean-grid-table th.col-acc { width: 34%; }
.clean-grid-table th.col-desc { width: 36%; }
.clean-grid-table th.col-amt { width: 14%; text-align: right !important; }
.clean-grid-table th.col-act { width: 6%; }

.clean-grid-row {
    border-bottom: 1px solid #f1f5f9;
    transition: background-color var(--transition-fast);
}

.clean-grid-row:hover {
    background-color: #f8fafc;
}

.clean-grid-row.focused {
    background-color: #fffbeb; /* Foco amarillo cálido */
}

.clean-grid-row td {
    padding: 6px 6px;
    vertical-align: middle;
    position: relative;
}

/* Campos Limpios Sin Bordes Rígidos */
.grid-input-clean {
    width: 100%;
    border: none;
    background: transparent;
    font-size: 0.9rem;
    color: var(--text-main);
    padding: 8px 10px;
    border-radius: 4px;
    outline: none;
    transition: all var(--transition-fast);
}

.grid-input-clean:focus {
    background-color: #ffffff;
    box-shadow: inset 0 -2px 0 #f59e0b; /* Subrayado amarillo al enfocar */
}

.grid-input-clean:disabled {
    color: #64748b;
    cursor: not-allowed;
    background: transparent;
}

.grid-input-clean.num-input {
    text-align: right;
    font-family: monospace;
    font-weight: 600;
}

/* Badge selector de cuenta */
.account-badge-box {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
}

.code-pill {
    background-color: #f1f5f9;
    color: #334155;
    font-family: monospace;
    font-weight: 700;
    font-size: 0.8rem;
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    user-select: none;
    flex-shrink: 0;
}

.grid-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
}

.btn-add-line {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: background-color var(--transition-fast);
}

.btn-add-line:hover {
    background-color: var(--primary-light);
}

.keyboard-tip {
    font-size: 0.775rem;
    color: var(--text-muted);
}

/* Menu Dropdown de Autocompletado */
.account-autocomplete-menu {
    position: absolute;
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 240px;
    overflow-y: auto;
    z-index: 1050;
    min-width: 320px;
}

.autocomplete-item {
    padding: 8px 14px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color var(--transition-fast);
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #fffbeb;
    color: #92400e;
}

.autocomplete-item .acc-code {
    font-family: monospace;
    font-weight: 700;
    color: #475569;
}

.autocomplete-item.active .acc-code {
    color: #92400e;
}

.autocomplete-mayor-item {
    padding: 8px 14px;
    font-size: 0.825rem;
    font-weight: 700;
    color: #64748b;
    background-color: #f8fafc;
    cursor: not-allowed;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    user-select: none;
}

.autocomplete-mayor-item .mayor-badge {
    background-color: #e2e8f0;
    color: #475569;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Totales y Footer */
.editor-totals-footer {
    padding: 16px 24px;
    border-top: 2px solid var(--border-color);
    background-color: #fafafa;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.balance-indicator-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    background-color: #ffffff;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.totals-group {
    display: flex;
    align-items: center;
    gap: 24px;
}

.total-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.total-label {
    color: var(--text-muted);
}

.total-value {
    font-family: monospace;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
}

.balance-item .total-value {
    font-size: 1.15rem;
}

/* ==========================================================================
   RETRACTABLE SIDEBAR & TABLET RESPONSIVENESS
   ========================================================================== */

.btn-toggle-sidebar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

.journal-left-panel.is-hidden,
.journalentries-wrapper.sidebar-is-closed .journal-left-panel,
.journalentries-wrapper.sidebar-collapsed .journal-left-panel {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    display: none !important;
    opacity: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border-right: none !important;
}

.journalentries-wrapper.sidebar-is-closed .journal-right-panel,
.journalentries-wrapper.sidebar-collapsed .journal-right-panel {
    width: 100% !important;
    flex: 1 !important;
}

/* Tablet & iPad Mini Adaptations (768px - 1024px) */
@media (max-width: 1024px) {
    .journal-left-panel {
        width: 260px;
        min-width: 240px;
    }

    .journal-left-panel .panel-header {
        padding: 10px 12px;
        gap: 6px;
    }

    .journal-left-panel .panel-title {
        font-size: 0.95rem;
    }

    #btn-new-entry {
        padding: 4px 8px;
        font-size: 0.775rem;
    }

    .editor-action-bar {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .editor-title-group {
        gap: 8px;
        flex-wrap: wrap;
    }

    .editor-buttons-group {
        gap: 6px;
    }

    .editor-header-form {
        padding: 12px 14px;
    }

    .form-row-header {
        gap: 8px;
    }

    .form-row-header .col-summary {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .form-row-header .col-ref,
    .form-row-header .col-date {
        flex: 1;
        min-width: 120px;
    }

    .editor-grid-wrapper {
        overflow-x: auto;
        width: 100%;
    }

    .clean-grid-table {
        min-width: 520px;
        table-layout: fixed;
        width: 100%;
    }

    .clean-grid-table th.col-acc,
    .clean-grid-table td.col-acc {
        width: 30%;
        font-size: 0.825rem;
    }

    .clean-grid-table th.col-desc,
    .clean-grid-table td.col-desc {
        width: 36%;
        font-size: 0.825rem;
    }

    .clean-grid-table th.col-amt,
    .clean-grid-table td.col-amt {
        width: 17%;
        font-size: 0.85rem;
    }

    .editor-totals-footer {
        padding: 10px 14px;
        gap: 10px;
        flex-wrap: wrap;
    }

    .balance-indicator-box {
        padding: 4px 12px;
        font-size: 0.825rem;
    }

    .totals-group {
        gap: 12px;
        flex-wrap: wrap;
    }

    .total-item {
        font-size: 0.825rem;
    }

    .total-value {
        font-size: 0.95rem;
    }
}

@media (max-width: 768px) {
    .clean-grid-table {
        min-width: 480px;
    }
}

/* ==========================================================================
   🖨️ IMPRESIÓN CONDENSADA DE COMPROBANTE CONTABLE (@media print & Modal)
   ========================================================================== */
.printable-voucher-sheet {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #0f172a;
    font-size: 8.5pt;
    line-height: 1.3;
}

.voucher-print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 8px;
    border-bottom: 2px solid #0f172a;
    margin-bottom: 10px;
}

.vhead-company h2 {
    font-size: 11pt;
    font-weight: 800;
    margin: 0;
    color: #0f172a;
    text-transform: uppercase;
}

.vhead-company p {
    font-size: 8pt;
    margin: 2px 0 0 0;
    color: #475569;
}

.vhead-docinfo {
    text-align: right;
}

.vdoc-title {
    font-size: 11pt;
    font-weight: 800;
    margin: 0 0 4px 0;
    color: #1e3a8a;
    letter-spacing: 0.5px;
}

.vdoc-meta {
    font-size: 8pt;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
    color: #334155;
}

.voucher-print-concept {
    background-color: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 8.5pt;
    margin-bottom: 12px;
}

.voucher-print-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 16px;
    font-size: 8.5pt;
}

.voucher-print-table th {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    padding: 5px 8px;
    border: 1px solid #cbd5e1;
    text-transform: uppercase;
    font-size: 7.5pt;
}

.voucher-print-table td {
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
}

.voucher-print-totals td {
    background-color: #f8fafc;
    border-top: 2px solid #0f172a !important;
    border-bottom: 2px solid #0f172a !important;
    font-size: 9pt;
    padding: 6px 8px;
}

.voucher-print-signatures {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 28px;
    padding-top: 8px;
}

.sig-box {
    text-align: center;
}

.sig-line {
    border-bottom: 1px solid #64748b;
    height: 32px;
    margin-bottom: 4px;
}

.sig-box p {
    font-size: 7.5pt;
    font-weight: 600;
    color: #475569;
    margin: 0;
    text-transform: uppercase;
}

/* REGLAS DE IMPRESIÓN DIRECTA IMPRESORA / PDF */
@media print {
    @page {
        size: A4 portrait;
        margin: 8mm 8mm 8mm 8mm;
    }
    body {
        background-color: #ffffff !important;
        color: #000000 !important;
    }
    .no-print, header, footer, nav, .main-header, .main-footer, .journalentries-wrapper, .modal-overlay:not(#modal-print-voucher) {
        display: none !important;
    }
    #modal-print-voucher {
        position: static !important;
        background: transparent !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        padding: 0 !important;
    }
    #modal-print-voucher .modal-card {
        box-shadow: none !important;
        border: none !important;
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    #modal-print-voucher .modal-body {
        padding: 0 !important;
        overflow: visible !important;
    }
    .printable-voucher-sheet {
        width: 100% !important;
    }
    .voucher-print-table th {
        background-color: #e2e8f0 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
