/* style.css — Sistema de Facturación CFDI 4.0 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #f5f4f0;
  --surface:  #ffffff;
  --border:   #e2e0d8;
  --text:     #1a1a18;
  --muted:    #6b6a65;
  --hint:     #9c9a92;
  --blue:     #185FA5;
  --blue-bg:  #E6F1FB;
  --green:    #0F6E56;
  --green-bg: #E1F5EE;
  --purple:   #534AB7;
  --purple-bg:#EEEDFE;
  --amber:    #854F0B;
  --amber-bg: #FAEEDA;
  --red:      #A32D2D;
  --red-bg:   #FCEBEB;
  --radius:   10px;
  --shadow:   0 1px 3px rgba(0,0,0,.08);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* Header */
.header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.header-inner { max-width: 1100px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.logo-icon { font-size: 20px; }
.logo-version { font-size: 11px; background: var(--blue-bg); color: var(--blue); padding: 1px 6px; border-radius: 4px; font-weight: 500; vertical-align: middle; }
.nav { display: flex; gap: 4px; }
.nav-btn { background: none; border: none; padding: 6px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--muted); transition: background .15s, color .15s; }
.nav-btn:hover, .nav-btn.active { background: var(--bg); color: var(--text); font-weight: 500; }

/* Main */
.main { max-width: 1100px; margin: 0 auto; padding: 24px; }
.seccion {}

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card-small { grid-column: span 1; }

/* Form grid */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.card-small { grid-column: 1 / -1; }

/* Fields */
.field-group { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=number], select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s;
  width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--blue); }

/* Badges */
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }

/* Conceptos table */
.concepto-header {
  display: grid;
  grid-template-columns: 2fr 1fr 80px 60px 110px 100px 36px;
  gap: 8px;
  padding: 0 4px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.concepto-row {
  display: grid;
  grid-template-columns: 2fr 1fr 80px 60px 110px 100px 36px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.concepto-row input { font-size: 13px; }
.importe-cell { font-family: monospace; font-size: 13px; color: var(--muted); padding: 8px 4px; }
.btn-del { background: none; border: none; color: var(--hint); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 6px; transition: background .15s, color .15s; }
.btn-del:hover { background: var(--red-bg); color: var(--red); }

@media (max-width: 720px) {
  .concepto-header { display: none; }
  .concepto-row { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
}

/* Botones */
.btn { border-radius: 8px; padding: 9px 18px; font-size: 13px; cursor: pointer; font-weight: 500; transition: opacity .15s, background .15s; border: 1px solid transparent; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: var(--bg); color: var(--text); border-color: var(--border); margin-top: 10px; }
.btn-ghost:hover { background: var(--border); }
.btn-grande { padding: 12px 28px; font-size: 14px; }

/* Totales */
.totales-row { display: flex; justify-content: flex-end; align-items: flex-end; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.totales-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; min-width: 260px; box-shadow: var(--shadow); }
.total-line { display: flex; justify-content: space-between; gap: 40px; padding: 5px 0; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
.total-line:last-child { border-bottom: none; }
.total-final { font-size: 15px; font-weight: 600; color: var(--text); margin-top: 4px; padding-top: 10px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; max-width: 560px; width: 100%; box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 20px 20px 0; }
.modal-icon { font-size: 22px; }
.modal-header h3 { flex: 1; font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--hint); padding: 4px 8px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 16px 20px; }
.modal-footer { padding: 0 20px 20px; display: flex; gap: 10px; justify-content: flex-end; }

/* XML preview */
.xml-preview {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: monospace;
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  max-height: 200px;
  overflow-y: auto;
  white-space: pre;
  margin-top: 12px;
}

/* Historial */
.historial-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.historial-item:last-child { border-bottom: none; }
.empty-msg { font-size: 13px; color: var(--hint); text-align: center; padding: 20px 0; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 200; opacity: 0; transition: opacity .3s; pointer-events: none; }
.toast.show { opacity: 1; }
