/* ==========================================================================
   Contabilidad General Express - Módulo Fiscal y Retenciones SENIAT
   Archivo: css/sync/fiscal.css
   Diseño UX/UI Profesional para Libros Fiscales y Emisión de Retenciones
   Regla: minúsculas, inglés, sin separadores en nombres de archivo
   ========================================================================== */

/* Contenedor Principal */
.fiscal-container {
    padding: 24px 32px 60px 32px;
    max-width: 1600px;
    margin: 0 auto;
    font-family: inherit;
}

/* Barra Superior */
.fiscal-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 16px;
}

.fiscal-topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.fiscal-title {
    font-size: 1.55rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 2px 0;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
}

.fiscal-subtitle {
    margin: 0;
    color: #64748b;
    font-size: 0.88rem;
    font-weight: 500;
}

/* Navegación por pestañas */
.fiscal-nav-tabs {
    display: flex;
    gap: 8px;
    background: #f8fafc;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    margin-bottom: 20px;
    overflow-x: auto;
}

.fiscal-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.88rem;
    font-weight: 700;
    color: #64748b;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.fiscal-tab-btn:hover {
    color: #1e293b;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.fiscal-tab-btn.active {
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.fiscal-tab-btn.tab-vat.active {
    background: #059669;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.fiscal-tab-btn.tab-islr.active {
    background: #7c3aed;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.fiscal-tab-btn.tab-igtf.active {
    background: #d97706;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.25);
}

/* Tarjeta de Filtros y Barra de Acciones */
.fiscal-filters-card {
    background: #ffffff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    padding: 18px 24px;
    margin-bottom: 22px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
}

.fiscal-filters-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    row-gap: 14px;
}

.fiscal-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 160px;
}

.fiscal-filter-group label {
    font-size: 0.74rem;
    font-weight: 800;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fiscal-filter-group .form-control {
    height: 40px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
    font-size: 0.88rem;
    color: #0f172a;
    transition: all 0.15s ease;
}

.fiscal-filter-group .form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

.fiscal-filter-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-left: auto;
}

/* Botón Consultar Principal */
#btn-fiscal-query {
    height: 40px;
    padding: 0 20px;
    font-size: 0.88rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 8px;
    background: #2563eb;
    border: 1px solid #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.2);
    transition: all 0.15s ease;
}

#btn-fiscal-query:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

/* Barra Segmentada de Botones de Exportación */
.fiscal-export-toolbar {
    display: inline-flex;
    align-items: center;
    background: #f8fafc;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    gap: 4px;
}

.fiscal-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.fiscal-export-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.fiscal-export-btn.btn-excel {
    color: #059669;
    border-color: #a7f3d0;
}
.fiscal-export-btn.btn-excel:hover {
    background: #ecfdf5;
    color: #047857;
    border-color: #6ee7b7;
}

.fiscal-export-btn.btn-xml {
    color: #7c3aed;
    border-color: #ddd6fe;
}
.fiscal-export-btn.btn-xml:hover {
    background: #f5f3ff;
    color: #6d28d9;
    border-color: #c4b5fd;
}

.fiscal-export-btn.btn-txt {
    color: #2563eb;
    border-color: #bfdbfe;
}
.fiscal-export-btn.btn-txt:hover {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #93c5fd;
}

/* ==========================================================================
   Tarjetas de Indicadores KPI (Rediseño Limpio y Balanceado)
   ========================================================================== */
.fiscal-kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

@media (max-width: 1400px) {
    .fiscal-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 860px) {
    .fiscal-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 540px) {
    .fiscal-kpi-grid {
        grid-template-columns: 1fr;
    }
}

.fiscal-kpi-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    min-width: 0;
}

.fiscal-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
    border-color: #cbd5e1;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.kpi-icon.icon-primary   { background: #eff6ff; color: #2563eb; }
.kpi-icon.icon-secondary { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; }
.kpi-icon.icon-accent    { background: #eef2ff; color: #4f46e5; }
.kpi-icon.icon-warning   { background: #fffbeb; color: #d97706; }
.kpi-icon.icon-success   { background: #ecfdf5; color: #059669; }
.kpi-icon.icon-purple    { background: #f5f3ff; color: #7c3aed; }

.kpi-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.kpi-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.kpi-value {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-value.text-primary { color: #2563eb; }
.kpi-value.text-indigo  { color: #4f46e5; }
.kpi-value.text-warning { color: #d97706; }
.kpi-value.text-success { color: #059669; }
.kpi-value.text-purple  { color: #7c3aed; }

/* ==========================================================================
   Tablas Fiscales y Prevención de Solapamiento
   ========================================================================== */
.fiscal-table-wrapper {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    margin-bottom: 24px;
    overflow: hidden;
}

.fiscal-table-scroll {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 680px;
    -webkit-overflow-scrolling: touch;
}

/* Personalización elegante de la barra de desplazamiento */
.fiscal-table-scroll::-webkit-scrollbar {
    height: 9px;
    width: 9px;
}
.fiscal-table-scroll::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.fiscal-table-scroll::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.fiscal-table-scroll::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.fiscal-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82rem;
}

/* Encabezados Fijos (Sticky Header) */
.fiscal-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f8fafc;
    color: #334155;
    font-weight: 800;
    padding: 10px 14px;
    border-bottom: 2px solid #cbd5e1;
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.fiscal-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
    white-space: nowrap;
}

/* Filas alternadas suaves y hover */
.fiscal-table tbody tr:nth-child(even) td {
    background-color: #fafbfc;
}

.fiscal-table tbody tr:hover td {
    background-color: #f0f7ff !important;
}

/* Pie de tabla con totales fijos */
.fiscal-table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 4;
    background: #f1f5f9;
    font-weight: 800;
    border-top: 2px solid #94a3b8;
    color: #0f172a;
    padding: 12px 14px;
    white-space: nowrap;
}

/* Corrección de Anchos y Prevención de Solapamiento por Columna */
.col-oper {
    width: 50px;
    min-width: 50px;
    text-align: center;
}

.col-fecha {
    min-width: 95px;
    text-align: center;
}

.col-rif {
    min-width: 110px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Razón Social / Nombre: Garantizar truncado seguro sin solapamiento */
.col-nombre {
    min-width: 220px;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-truncate {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-factura {
    min-width: 110px;
    font-weight: 700;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    text-align: center;
    white-space: nowrap;
}
}

.col-control {
    min-width: 140px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.col-monto {
    min-width: 125px;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.col-alicuota {
    min-width: 60px;
    text-align: center;
}

.col-badge {
    min-width: 65px;
    text-align: center;
}

.col-comprobante {
    min-width: 130px;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Botón de Edición Rápida en Tabla */
.btn-table-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    margin-left: 6px;
    padding: 0;
    cursor: pointer;
    font-size: 0.72rem;
    transition: all 0.15s ease;
    vertical-align: middle;
}

.btn-table-edit:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
    transform: scale(1.08);
}

/* Botones Pills de Emisión de Comprobantes Oficiales */
.btn-voucher-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    line-height: 1;
}

.btn-voucher-pill.pill-vat {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}
.btn-voucher-pill.pill-vat:hover {
    background: #059669;
    color: #ffffff;
    border-color: #059669;
}

.btn-voucher-pill.pill-islr {
    background: #f5f3ff;
    color: #6d28d9;
    border-color: #ddd6fe;
}
.btn-voucher-pill.pill-islr:hover {
    background: #7c3aed;
    color: #ffffff;
    border-color: #7c3aed;
}

/* Badges y Alertas */
.badge-doc {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
    font-weight: 700;
}

.badge-alert {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fde68a;
    margin-left: 4px;
}

.badge-concept {
    font-family: ui-monospace, monospace;
    font-size: 0.72rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #e9d5ff;
    font-weight: 700;
}

/* ==========================================================================
   Resumen Oficial Forma 30 SENIAT
   ========================================================================== */
.forma30-card {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 20px 24px;
    margin-top: 24px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.forma30-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 12px;
    margin-bottom: 14px;
}

.forma30-title {
    font-size: 1rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.01em;
}

.forma30-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.forma30-table th {
    background: #f8fafc;
    padding: 10px 14px;
    border-bottom: 2px solid #94a3b8;
    color: #1e293b;
    font-weight: 800;
    text-transform: uppercase;
    font-size: 0.74rem;
    letter-spacing: 0.03em;
}

.forma30-table td {
    padding: 10px 14px;
    border-bottom: 1px solid #e2e8f0;
}

.forma30-table tbody tr:hover td {
    background: #f8fafc;
}

.forma30-table tr:last-child td {
    border-bottom: none;
    font-weight: 800;
    background: #f1f5f9;
}
