/* ============================================================
   F944 Bienes Inmuebles — styles.css
   Ministerio de Hacienda El Salvador
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
.btn[href] {
  text-decoration: none;
}
:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f0efeb;
  --border: #dddbd4;
  --border-strong: #b8b5ad;
  --text: #1a1a18;
  --text-2: #5a5a56;
  --text-3: #9a9892;
  --blue: #185FA5;
  --blue-dark: #0C447C;
  --blue-light: #E6F1FB;
  --green: #3B6D11;
  --green-dark: #27500A;
  --green-light: #EAF3DE;
  --red: #A32D2D;
  --red-dark: #791F1F;
  --red-light: #FCEBEB;
  --amber-light: #FAEEDA;
  --amber: #854F0B;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Consolas', 'Courier New', monospace;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---- Layout ---- */
.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ---- Header ---- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header h1 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.subtitle {
  font-size: 12px;
  color: var(--text-2);
}

.db-status {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
}

.db-status.ok {
  color: var(--green);
  border-color: #c0dd97;
  background: var(--green-light);
}

.db-status.err {
  color: var(--red);
  border-color: #f7c1c1;
  background: var(--red-light);
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 1.25rem;
}

.tab {
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-2);
  transition: all 0.15s;
}

.tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tab.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 500;
}

/* ---- Panels ---- */
.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

/* ---- Section titles ---- */
.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 1rem;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.section-title.no-border {
  border: none;
  margin: 0;
  padding: 0;
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-3);
}

/* ---- Grids ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

@media (max-width: 720px) {
  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  .tabs {
    flex-wrap: wrap;
  }
}

/* ---- Fields ---- */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
}

.field input,
.field select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 95, 165, 0.1);
  background: var(--surface);
}

.field input::placeholder {
  color: var(--text-3);
}

.hint {
  font-size: 11px;
  color: var(--text-3);
  line-height: 1.4;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.btn.primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
}

.btn.success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.btn.success:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.btn.danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.btn.danger:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.btn.small {
  padding: 4px 12px;
  font-size: 12px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  z-index: 9999;
  display: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.2s ease;
}

.toast.ok  { background: var(--green); }
.toast.err { background: var(--red); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---- Stats ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1rem;
}

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

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat-n {
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  color: var(--blue);
}

.stat-l {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 5px;
}

/* ---- Table ---- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 8px 10px;
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: var(--surface-2);
}

.col-table th, .col-table td {
  font-size: 12px;
}

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge.si {
  background: var(--green-light);
  color: var(--green);
}

.badge.no {
  background: var(--red-light);
  color: var(--red);
}

/* ---- Empty state ---- */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-3);
  font-size: 13px;
}

/* ---- Export ---- */
.info-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.info-text code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
}

.export-note {
  background: var(--amber-light);
  border: 1px solid #FAC775;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--amber);
  line-height: 1.6;
}

.export-note code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
}

.csv-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  min-height: 70px;
  word-break: break-all;
  line-height: 1.9;
  white-space: pre-wrap;
  margin-bottom: 1rem;
}

/* ---- Mono in table ---- */
.mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

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

/* ============================================================
   SELECTOR DE MÓDULO
   ============================================================ */
.modulos {
  display: flex;
  gap: 8px;
  margin-bottom: 1.25rem;
}

.modulo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
  flex: 1;
  justify-content: center;
}

.modulo:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.modulo.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

.modulo-icon {
  font-size: 18px;
  line-height: 1;
}

/* ---- Módulo panels ---- */
.modulo-panel {
  display: none;
}

.modulo-panel.active {
  display: block;
}

@media (max-width: 480px) {
  .modulos {
    flex-direction: column;
  }
}

/* ============================================================
   BOTÓN EDITAR + ACCIONES
   ============================================================ */
.btn.edit {
  background: #185FA5;
  color: #fff;
  border-color: #185FA5;
}
.btn.edit:hover {
  background: #0C447C;
  border-color: #0C447C;
}

.btn.warning {
  background: #854F0B;
  color: #fff;
  border-color: #854F0B;
}
.btn.warning:hover {
  background: #633806;
  border-color: #633806;
}

.acciones-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}

/* ============================================================
   AVISO MODO EDICIÓN
   ============================================================ */
.edit-aviso {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #FAEEDA;
  border: 1px solid #FAC775;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  color: #854F0B;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.edit-aviso-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ============================================================
   MODAL DE CONFIRMACIÓN
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem 1.25rem;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-msg {
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.modal-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================
   IMPORTAR CSV — preview y log
   ============================================================ */
.rb-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1rem;
}

.csv-log {
  margin-bottom: 1rem;
}

.csv-log-item {
  font-size: 12px;
  color: var(--red);
  padding: 3px 0;
  border-bottom: 0.5px solid var(--border);
  line-height: 1.5;
}

.csv-log-item:last-child {
  border: none;
}

/* ============================================================
   RADIO BUTTONS — modo importación
   ============================================================ */
.rb-modo-wrap {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.rb-radio {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 8px;
  cursor: pointer;
}

.rb-radio input[type="radio"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--blue);
}

/* ============================================================
   MÓDULO RESPALDO
   ============================================================ */
.respaldo-card {
  text-align: center;
  padding: 2rem 1.5rem;
}

.respaldo-icon-wrap {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.respaldo-titulo {
  font-size: 18px;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.respaldo-desc {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  max-width: 560px;
  margin: 0 auto;
}

.respaldo-resumen {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 1rem;
}

@media (max-width: 560px) {
  .respaldo-resumen { grid-template-columns: repeat(2, 1fr); }
}

.respaldo-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  text-align: center;
}

.respaldo-stat span {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: var(--blue);
  line-height: 1;
}

.respaldo-stat small {
  display: block;
  font-size: 11px;
  color: var(--text-2);
  margin-top: 4px;
}

.respaldo-stat-total span {
  color: var(--green);
}

/* input[type=file] básico */
input[type="file"] {
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  padding: 6px 0;
  cursor: pointer;
}
