/* =====================================================================
   Fiestas Yoselin v6.2.0 — Módulo Comprobante Fiscal (NCF)
   Toma facturas/cotizaciones existentes y les emite el NCF.
   Complementa styles.css (usa sus tokens).
   ===================================================================== */

.fx-intro {
    display: flex; gap: 14px; align-items: flex-start;
    background: linear-gradient(135deg, var(--t-primary), transparent);
    border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 16px 18px; margin-bottom: 18px;
}
.fx-intro .fx-ic { font-size: 26px; line-height: 1; }
.fx-intro h3 { font-size: 16px; font-weight: 700; color: var(--brand-navy); margin-bottom: 2px; }
.fx-intro p { color: var(--text-secondary); font-size: 13.5px; }

.fx-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.fx-tabs { display: inline-flex; background: var(--bg-card); border-radius: 999px; padding: 4px; }
.fx-tabs button { border: none; background: transparent; color: var(--text-secondary); padding: 9px 16px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13.5px; transition: var(--transition); }
.fx-tabs button.active { background: var(--primary); color: #fff; box-shadow: 0 8px 16px -10px rgba(30,94,255,.9); }
.fx-search { flex: 1; min-width: 200px; padding: 10px 14px; font-size: 14px; color: var(--text-primary); background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-md); }
.fx-search:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

/* Lista de documentos (cards) */
.fx-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.fx-card {
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 8px; transition: var(--transition);
}
.fx-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.fx-card .fx-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.fx-card .fx-num { font-weight: 800; color: var(--brand-navy); letter-spacing: -.01em; }
.fx-card .fx-cli { color: var(--text-primary); font-weight: 600; font-size: 14px; }
.fx-card .fx-meta { color: var(--text-muted); font-size: 12px; }
.fx-card .fx-total { font-size: 20px; font-weight: 800; color: var(--brand-navy); }
.fx-card .fx-actions { margin-top: 4px; display: flex; gap: 8px; }
.fx-empty { color: var(--text-muted); text-align: center; padding: 40px 0; grid-column: 1 / -1; }

/* Panel de emisión dentro del modal */
.fx-emit-summary { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 14px; margin-bottom: 16px; }
.fx-emit-summary .row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; }
.fx-emit-summary .row.total { margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--border-color); font-size: 18px; font-weight: 800; }
.fx-emit-summary .row.total span:last-child { color: var(--success-dark); }

.fx-ncf-live { background: var(--t-info); border: 1px solid rgba(2,132,199,.3); border-radius: var(--radius-md); padding: 10px 12px; font-size: 13px; margin: 6px 0 14px; }
.fx-ncf-live .num { font-weight: 800; color: var(--info); letter-spacing: .5px; }
.fx-ncf-live .warn { color: var(--danger-dark); font-weight: 700; }

.fx-alert { background: var(--t-warning); border: 1px solid rgba(217,119,6,.35); color: var(--warning); border-radius: var(--radius-md); padding: 10px 12px; font-size: 13px; margin-bottom: 12px; font-weight: 600; }

.fx-items { width: 100%; border-collapse: collapse; margin: 6px 0 14px; }
.fx-items th, .fx-items td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-color); font-size: 13px; }
.fx-items th { color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
.fx-items td.num, .fx-items th.num { text-align: right; }

@media (max-width: 768px) {
    .fx-list { grid-template-columns: 1fr; }
}

/* =====================================================================
   v6.5.0 — Comprobantes autorizados (secuencias NCF) + buscador RNC
   ===================================================================== */

/* Panel de secuencias — ocupa todo el ancho aunque #fx-list sea grid */
.fx-seq-wrap { grid-column: 1 / -1; }
.fx-seq-head p { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 14px; }
.fx-seq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.fx-seq-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.fx-seq-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.fx-seq-pref { font-weight: 800; font-size: 16px; color: #fff; background: var(--primary); border-radius: 8px; padding: 3px 10px; letter-spacing: .04em; }
.fx-seq-lbl { font-weight: 600; color: var(--text-primary); }
.fx-seq-active { margin-left: auto; font-size: 12.5px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.fx-seq-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.fx-seq-stats > div { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 8px; text-align: center; }
.fx-seq-stats span { display: block; font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.fx-seq-stats strong { font-size: 18px; color: var(--brand-navy); font-weight: 800; }
.fx-seq-stats .is-low strong { color: var(--danger-dark); }

.fx-seq-next { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }
.fx-seq-next b { color: var(--info); letter-spacing: .5px; }

.fx-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-left: 4px; }
.fx-badge.danger { background: var(--t-danger); color: var(--danger-dark); }
.fx-badge.warn { background: var(--t-warning); color: var(--warning); }
.fx-badge.muted { background: var(--bg-input); color: var(--text-muted); }

.fx-seq-fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.fx-seq-fields label { font-size: 11.5px; color: var(--text-muted); display: flex; flex-direction: column; gap: 3px; }
.fx-seq-fields input { padding: 8px 10px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-input); color: var(--text-primary); font-size: 14px; }
.fx-seq-hint { margin-top: 8px; font-size: 11.5px; color: var(--text-muted); }
.fx-seq-actions { margin-top: 16px; display: flex; justify-content: flex-end; }

/* Buscador de RNC dentro del modal de emisión */
.fx-rnc { background: var(--bg-input); border: 1px dashed var(--border-color); border-radius: var(--radius-md); padding: 12px; margin-bottom: 14px; }
.fx-rnc > label { display: block; font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.fx-rnc-row { display: flex; gap: 8px; }
.fx-rnc-row input { flex: 1; min-width: 0; padding: 9px 11px; border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary); font-size: 15px; }
.fx-rnc-res { margin-top: 10px; font-size: 13.5px; }
.fx-rnc-res .muted { color: var(--text-muted); }
.fx-rnc-res .warn { color: var(--danger-dark); font-weight: 600; }
.fx-rnc-ok { background: var(--t-success, rgba(16,185,129,.12)); border: 1px solid rgba(16,185,129,.3); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 10px; }
.fx-rnc-estado { color: var(--success-dark); font-weight: 700; }
.fx-rnc-src { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

@media (max-width: 768px) {
    .fx-seq-grid { grid-template-columns: 1fr; }
    .fx-seq-fields { grid-template-columns: 1fr 1fr; }
}

/* v6.6.0 — Notas de crédito (B04) */
.fx-nc-wrap { grid-column: 1 / -1; }
.fx-nc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.fx-ncf { font-weight: 700; color: var(--info); font-size: 13px; letter-spacing: .3px; }
.fx-nc-hist { margin-top: 22px; }
.fx-nc-hist h4 { font-size: 14px; font-weight: 700; color: var(--brand-navy); margin-bottom: 10px; }
.fx-radio { display: flex; gap: 18px; flex-wrap: wrap; }
.fx-radio label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-primary); cursor: pointer; }
.req { color: var(--danger); }
.fx-emit-summary .row.total span:last-child { color: var(--brand-navy); }
@media (max-width: 768px) { .fx-nc-grid { grid-template-columns: 1fr; } }

/* v6.7.0 — Edición de artículos en el modal de emisión */
.fx-edit-head { display:flex; align-items:center; justify-content:space-between; margin:6px 0 8px; }
.fx-edit-head strong { color: var(--brand-navy); font-size: 14px; }
.fx-items-edit input { padding:6px 8px; border:1px solid var(--border-color); border-radius:8px; background:var(--bg-input); color:var(--text-primary); font-size:13px; width:100%; }
.fx-items-edit td:nth-child(2){ width:70px; } .fx-items-edit td:nth-child(3){ width:100px; }
.fx-add-row { position:relative; margin:10px 0; }
.fx-add-row input { width:100%; padding:9px 11px; border:1px solid var(--border-color); border-radius:var(--radius-md); background:var(--bg-input); color:var(--text-primary); font-size:14px; }
.fx-add-res { border:1px solid var(--border-color); border-radius:var(--radius-md); margin-top:4px; max-height:180px; overflow:auto; }
.fx-add-res:empty { display:none; }
.fx-add-item { padding:8px 12px; cursor:pointer; font-size:13px; border-bottom:1px solid var(--border-color); }
.fx-add-item:last-child { border-bottom:none; }
.fx-add-item:hover { background:var(--t-primary); }
.fx-desc-edit { display:flex; align-items:center; gap:10px; margin-top:10px; }
.fx-desc-edit label { font-size:13px; color:var(--text-secondary); }
.fx-desc-edit input { width:140px; padding:8px 10px; border:1px solid var(--border-color); border-radius:var(--radius-md); background:var(--bg-input); color:var(--text-primary); }

/* v6.7.0 — Panel de comprobantes integrado en Configuración */
.config-card-wide { grid-column: 1 / -1; }
.ncfc-head { display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap; margin-bottom:14px; }
.ncfc-head p { color: var(--text-secondary); font-size:13px; max-width:640px; }
.ncfc-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap:14px; }
.ncfc-card { background: var(--bg-card); border:1px solid var(--border-color); border-radius: var(--radius-lg); padding:14px 16px; box-shadow: var(--shadow-sm); }
.ncfc-title { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:10px; }
.ncfc-lbl { font-weight:600; color: var(--text-primary); }
.ncfc-active { margin-left:auto; font-size:12.5px; color: var(--text-secondary); display:inline-flex; align-items:center; gap:6px; cursor:pointer; }
.ncfc-stats { display:grid; grid-template-columns: repeat(3,1fr); gap:8px; margin-bottom:8px; }
.ncfc-stats > div { background: var(--bg-input); border:1px solid var(--border-color); border-radius: var(--radius-md); padding:8px; text-align:center; }
.ncfc-stats span { display:block; font-size:11px; color: var(--text-muted); text-transform:uppercase; letter-spacing:.03em; }
.ncfc-stats strong { font-size:18px; color: var(--brand-navy); font-weight:800; }
.ncfc-stats .is-low strong { color: var(--danger-dark); }
.ncfc-next { font-size:13px; color: var(--text-secondary); margin-bottom:10px; }
.ncfc-next b { color: var(--info); letter-spacing:.5px; }
.ncfc-fields { display:grid; grid-template-columns: repeat(2,1fr); gap:8px; }
.ncfc-fields label { font-size:11.5px; color: var(--text-muted); display:flex; flex-direction:column; gap:3px; }
.ncfc-fields input { padding:8px 10px; border:1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-input); color: var(--text-primary); font-size:14px; }
.ncfc-hint { margin-top:8px; font-size:11.5px; color: var(--text-muted); }
.ncfc-actions { margin-top:16px; display:flex; justify-content:flex-end; }
@media (max-width:768px){ .ncfc-grid { grid-template-columns:1fr; } }

/* v6.7.1 — Panel de cliente / RNC en el modal de emisión */
.fx-cli-panel { background: var(--bg-input); border:1px solid var(--border-color); border-radius: var(--radius-md); padding:12px; margin-bottom:14px; }
.fx-cli-panel.need { border-color: rgba(217,119,6,.5); background: var(--t-warning); }
.fx-cli-top { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; margin-bottom:8px; }
.fx-cli-name { font-weight:700; color: var(--brand-navy); }
.fx-badge.ok { background: var(--t-success, rgba(16,185,129,.14)); color: var(--success-dark); }
.fx-cli-rnc { display:flex; gap:8px; }
.fx-cli-rnc input { flex:1; min-width:0; padding:9px 11px; border:1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary); font-size:15px; }
.fx-cli-res { margin-top:10px; font-size:13.5px; }
.fx-cli-res .muted { color: var(--text-muted); }
.fx-cli-res .warn { color: var(--danger-dark); font-weight:600; }
.fx-cli-actions { display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }
.fx-cli-search { margin-top:10px; }
.fx-cli-search input { width:100%; padding:9px 11px; border:1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-card); color: var(--text-primary); font-size:14px; }

/* v6.7.2 — Lista de artículos editable con scroll propio (no se pierde el foco) */
.fx-items-scroll { max-height: 42vh; overflow-y: auto; overflow-x: auto; border: 1px solid var(--border-color); border-radius: 10px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.fx-items-scroll .fx-items { margin: 0; }
.fx-items-scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-card); box-shadow: 0 1px 0 var(--border-color); }
.fx-items-edit input { padding: 6px 8px; }

/* v6.8.0 — Estado del padrón RNC en Configuración */
.ncfc-padron { display:flex; flex-direction:column; gap:8px; }
.ncfc-padron-stat { font-size:14px; }
.ncfc-ok { color: var(--success-dark); font-weight:700; }
.ncfc-warn { color: var(--warning); font-weight:600; }
.ncfc-muted { color: var(--text-muted); font-size:13px; }
.ncfc-solo { display:inline-flex; align-items:center; gap:8px; font-size:13.5px; color: var(--text-secondary); cursor:pointer; }
.ncfc-padron-actions { display:flex; gap:8px; flex-wrap:wrap; }
.ncfc-padron code { background: var(--bg-input); padding:2px 6px; border-radius:6px; }

/* v6.8.1 — pista de facturación a nombre del titular del RNC */
.fx-cli-hint { margin-top: 8px; font-size: 12.5px; color: var(--text-secondary); }

/* v6.10.0 — Pestaña "Para declarar (NCF)" en Facturas */
.fac-tabs { display:inline-flex; background: var(--bg-card); border-radius:999px; padding:4px; margin-bottom:16px; flex-wrap:wrap; }
.fac-tabs button { border:none; background:transparent; color: var(--text-secondary); padding:9px 16px; border-radius:999px; cursor:pointer; font-weight:600; font-size:13.5px; transition: var(--transition); }
.fac-tabs button.active { background: var(--primary); color:#fff; box-shadow:0 8px 16px -10px rgba(30,94,255,.9); }
.decl-toolbar { display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; margin-bottom:14px; }
.decl-toolbar label { font-size:12.5px; color: var(--text-muted); display:flex; flex-direction:column; gap:4px; }
.decl-toolbar input, .decl-toolbar select { padding:9px 11px; border:1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-input); color: var(--text-primary); font-size:14px; }
.decl-summary { margin-bottom:14px; }
.decl-stats-row { display:grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap:10px; }
.decl-tipos { margin-top:12px; background: var(--bg-card); border:1px solid var(--border-color); border-radius: var(--radius-md); padding:10px 12px; }
.decl-tipos-title { font-size:11px; text-transform:uppercase; letter-spacing:.03em; color: var(--text-muted); margin-bottom:8px; font-weight:700; }
.decl-tipo { display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:6px 0; border-top:1px solid var(--border-color); font-size:13px; }
.decl-tipo:first-of-type { border-top:none; }
.decl-tipo-k { font-weight:700; color: var(--brand-navy); min-width:180px; }
.decl-tipo-n { color: var(--text-muted); font-size:12px; }
.decl-tipo-m { margin-left:auto; color: var(--text-secondary); font-weight:600; }
.decl-stat { background: var(--bg-card); border:1px solid var(--border-color); border-radius: var(--radius-md); padding:10px 12px; }
.decl-stat span { display:block; font-size:11px; text-transform:uppercase; letter-spacing:.03em; color: var(--text-muted); }
.decl-stat strong { font-size:18px; color: var(--brand-navy); font-weight:800; }
.decl-stat em { font-style:normal; color: var(--danger-dark); font-size:12px; }
.decl-stat.total strong { color: var(--primary); }
.decl-table-wrap { overflow-x:auto; }
.decl-table td.num, .decl-table th.num { text-align:right; }
.decl-table .row-anulada { opacity:.6; text-decoration: line-through; }
