﻿/* ═══════════════════════════════════════════════════════════════
   Atlantek · Gestión de Clientes y Facturación — admin.css
   v2 "Control Room" — mismo sistema visual que style.css / dashboard.css
   La hoja del documento (.sheet) se mantiene BLANCA: réplica imprimible
   de la proforma oficial en papel.
   ═══════════════════════════════════════════════════════════════ */

:root {
  --navy:       #00273d;
  --navy-light: #1a4a6b;
  --navy-dark:  #001a2a;
  --rec:        #1a4a6b;

  --bg:     #0f1923;
  --bg2:    #131f2b;
  --card:   #182635;
  --line:   rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);

  --ink:    #E9EDF0;
  --muted:  #8E9AA4;
  --faint:  #5C6870;
  --green:  #33D17A;
  --amber:  #E5B54A;

  --font: "Sora", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;

  --radius: 2px;
}

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

html { font-size: 16px; color-scheme: dark; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  line-height: 1.6;
}

::selection { background: var(--navy); color: #fff; }

/* ═══════════ LAYOUT ═══════════ */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.main {
  padding: 40px 48px 64px;
  max-width: 1160px;
  width: 100%;
}

/* ═══════════ SIDEBAR ═══════════ */

.sidebar {
  background: #080C0F;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
}

.sidebar__brand {
  padding: 26px 22px 22px;
  border-bottom: 1px solid var(--line);
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  line-height: 1;
}

.logo__img {
  height: 48px;
  width: auto;
  object-fit: contain;
  border-radius: 0;
  flex-shrink: 0;
}

.logo__word {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: .5px;
}

.sidebar__tag {
  display: block;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar__nav {
  padding: 22px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .3px;
  padding: 11px 12px;
  border-radius: var(--radius);
  border-left: 2px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}

.nav-item__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .45;
  flex: none;
}

.nav-item:hover { background: rgba(74, 144, 217, .08); color: var(--ink); }

.nav-item.is-active {
  background: rgba(206, 18, 18, .12);
  border-left-color: var(--navy-light);
  color: var(--ink);
}
.nav-item.is-active .nav-item__dot { background: var(--navy-light); opacity: 1; }

.nav-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--navy);
  border-radius: 9px;
  padding: 3px 7px;
}

.sidebar__cta { padding: 0 16px 18px; }

.sidebar__foot {
  padding: 16px 22px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .6px;
  color: var(--faint);
}

.sync-badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 10px;
  margin-bottom: 8px;
  align-self: flex-start;
}
.sync-badge--ok   { color: var(--green); }
.sync-badge--busy { color: var(--amber); }
.sync-badge--err  { color: var(--navy-light); }

/* ═══════════ COMPONENTES BASE ═══════════ */

.btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .4px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .18s, color .18s, border-color .18s, transform .12s, box-shadow .18s;
}
.btn:active { transform: translateY(1px); }

.btn--red { background: #4A90D9; color: #fff; }
.btn--red:hover {
  background: #3a7bc8;
  box-shadow: 0 6px 28px -6px rgba(74, 144, 217, .55);
}

.btn--slate {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line-2);
}
.btn--slate:hover { border-color: var(--ink); }

.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-2);
}
.btn--ghost:hover { border-color: var(--ink); }

.btn--block { width: 100%; }
.btn--sm { padding: 7px 12px; font-size: 11.5px; }

.btn--icon {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 5px 8px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
}
.btn--icon:hover { color: #4A90D9; border-color: var(--line-2); }

.input {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  width: 100%;
  transition: border-color .15s;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: #4A90D9; }
.input--sm { padding: 7px 10px; font-size: 13px; width: auto; }
.input--select { appearance: auto; }
textarea.input { resize: vertical; min-height: 72px; line-height: 1.5; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field__label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ═══════════ ENCABEZADOS DE VISTA ═══════════ */

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.view-head__kicker {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 2.6px;
  text-transform: uppercase;
  color: var(--navy-light);
  display: block;
  margin-bottom: 8px;
}

.view-head h1 {
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

/* ═══════════ DASHBOARD ═══════════ */

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 34px;
}

.stat--link { text-decoration: none; color: inherit; transition: background .15s; }
.stat--link:hover { background: var(--card); }

.stat {
  background: var(--bg2);
  padding: 20px 20px 18px;
}
.stat--red { box-shadow: inset 0 2px 0 var(--navy-light); }

.stat__label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 10px;
}

.stat__value {
  font-size: clamp(20px, 2.4vw, 27px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stat--red .stat__value { color: var(--navy-light); }

.stat__hint {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  margin-top: 8px;
  display: block;
}

/* ═══════════ FILTROS ═══════════ */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.filters #f-q { flex: 1; min-width: 200px; }
.filters .input--select { width: auto; }

/* ═══════════ TABLAS ═══════════ */

.panel {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel__title {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
}

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

.table th {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 11px 20px;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}

.table td {
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,.025); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.num { text-align: right; }

.table .row-link { cursor: pointer; }

.doc-num {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: .5px;
  color: var(--ink);
}

.money { font-family: var(--mono); font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.money--red { color: var(--navy-light); }

.empty {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .8px;
  color: var(--faint);
  text-align: center;
  padding: 48px 20px;
}

/* Chips de estado — outline mono, como dashboard.css */
.chip {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  border: 1px solid var(--line-2);
  padding: 3px 8px;
  color: var(--muted);
}
.chip--borrador { color: var(--muted); }
.chip--enviada  { color: var(--amber);      border-color: rgba(229, 181, 74, .35); }
.chip--pagada   { color: var(--green);      border-color: rgba(51, 209, 122, .35); }
.chip--proforma { color: var(--navy-light); border-color: rgba(26, 74, 107, .4); }
.chip--factura  { color: var(--ink);        border-color: var(--line-2); }

/* Días de atraso de un documento enviado */
.due {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .6px;
  color: var(--faint);
  margin-left: 8px;
  white-space: nowrap;
}
.due--amber { color: var(--amber); }
.due--red   { color: var(--navy-light); font-weight: 600; }

/* ═══════════ LEADS ═══════════ */

.lead-count {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.lead-fecha {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.lead-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .4px;
  color: var(--faint);
  margin-top: 3px;
}

.mono-cell { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }

.lead-msg {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12.5px;
}

.lead-row--nuevo td { background: rgba(206, 18, 18, .05); }
.lead-row--nuevo .lead-fecha { color: var(--navy-light); }

.lead-estado { min-width: 130px; font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }

.lead-actions { white-space: nowrap; }
.lead-wa { text-decoration: none; }
.lead-wa:hover { color: var(--green); }

/* ═══════════ EDITOR DE DOCUMENTO ═══════════ */

.editor { display: flex; flex-direction: column; gap: 20px; }

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

.editor__items .table td { padding: 8px 12px; }
.editor__items .table th { padding: 10px 12px; }
.editor__items .input { padding: 8px 10px; font-size: 13px; }
.editor__items .input.num { text-align: right; font-family: var(--mono); font-size: 12.5px; }

.editor__totalbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 18px;
  padding: 18px 20px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--navy-light);
  border-radius: var(--radius);
}

.editor__totalbar .label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
}

.editor__totalbar .value {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--navy-light);
}

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

/* ═══════════ MODAL ═══════════ */

.modal { position: fixed; inset: 0; z-index: 60; }

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 8, .72);
  backdrop-filter: blur(4px);
}

.modal__panel {
  position: relative;
  background: var(--card);
  width: min(520px, calc(100vw - 32px));
  margin: 8vh auto 0;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  border-top: 2px solid var(--navy-light);
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  padding: 26px 26px 24px;
}

.modal__title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}

.modal__form { display: flex; flex-direction: column; gap: 14px; }

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   VISTA DOCUMENTO — réplica de la proforma PDF de Atlantek
   La hoja es PAPEL: se mantiene clara aunque la app sea dark.
   Variables re-declaradas localmente para no heredar el tema oscuro.
   ═══════════════════════════════════════════════════════════════ */

.docview {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow-y: auto;
  padding-bottom: 60px;
}

.docview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(11, 16, 20, .9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

.docview__bar-right { display: flex; align-items: center; gap: 10px; }

/* La hoja — proporción carta · SIEMPRE clara */
.sheet {
  --paper-red:   #CE1212;
  --paper-slate: #37424C;
  --paper-line:  #E3E3E0;
  --paper-card:  #EFEFEF;

  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #fff;
  width: 816px;              /* 8.5in @ 96dpi */
  min-height: 1056px;        /* 11in  @ 96dpi */
  margin: 28px auto 0;
  box-shadow: 0 8px 48px rgba(0,0,0,.5);
  color: #1B1B1B;
  display: flex;
  flex-direction: column;
}

/* Banda roja superior */
.sheet__band {
  background: var(--paper-red);
  padding: 34px 46px 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.sheet__logo {
  background: var(--paper-card);
  padding: 22px 34px 18px 26px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  color: #1B1B1B;
}

.sheet__logo .sheet__logo-img { width: 34px; height: 34px; object-fit: cover; border-radius: 4px; margin-bottom: -5px; }
.sheet__logo .logo__word { font-size: 46px; font-weight: 800; letter-spacing: -1px; font-family: Arial, sans-serif; }

.sheet__doctitle { text-align: right; color: #fff; }

.sheet__doctitle h2 {
  font-size: 26px;
  font-weight: 400;
  line-height: 1.15;
  margin-bottom: 14px;
  white-space: pre-line;
  letter-spacing: 0;
}

.sheet__doctitle .mail { font-size: 12px; color: rgba(255,255,255,.9); }

/* Barra slate de metadatos */
.sheet__meta {
  background: var(--paper-slate);
  color: #fff;
  display: flex;
  padding: 12px 46px;
  gap: 0;
  font-size: 11px;
}

.sheet__meta-item {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex: 1;
}

.sheet__meta-item b {
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
}

/* FROM / TO / TOTAL */
.sheet__parties {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 24px;
  padding: 26px 46px 22px;
}

.sheet__party { font-size: 12.5px; line-height: 1.55; }

.sheet__party b {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-bottom: 4px;
}

.sheet__party--total { border-left: 1px solid var(--paper-line); padding-left: 24px; }

.sheet__totaldue {
  font-size: 30px;
  font-weight: 400;
  color: var(--paper-red);
  letter-spacing: -0.5px;
  margin-top: 2px;
}

.sheet__intro {
  padding: 6px 46px 14px;
  font-size: 12px;
  font-style: italic;
  border-top: 1px solid var(--paper-line);
  border-bottom: 1px solid var(--paper-line);
}

/* Tabla de líneas */
.sheet__items { padding: 0 46px; flex: 1; }

.sheet__table { width: 100%; border-collapse: collapse; }

.sheet__table th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  text-align: left;
  padding: 18px 8px 10px 0;
  border-bottom: 1px solid #9AA0A6;
  color: #1B1B1B;
  font-family: inherit;
}

.sheet__table th.num, .sheet__table td.num { text-align: right; padding-right: 0; }

.sheet__table td {
  font-size: 11.5px;
  padding: 12px 8px 12px 0;
  border-bottom: 1px solid var(--paper-line);
  vertical-align: top;
  font-family: inherit;
}

.sheet__table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.sheet__total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--paper-line);
}

.sheet__total-row .label { font-size: 15px; font-weight: 700; }
.sheet__total-row .value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }

.sheet__notes {
  padding: 14px 46px 40px;
  font-size: 10.5px;
  font-style: italic;
  line-height: 1.6;
  color: #333;
}

/* ═══════════ RESPONSIVE ═══════════ */

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 24px 18px 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats .stat--link { grid-column: 1 / -1; }
  .editor__grid { grid-template-columns: 1fr 1fr; }
  .sheet { width: 100%; min-height: 0; }
  .sheet__parties { grid-template-columns: 1fr; }
  .sheet__party--total { border-left: none; padding-left: 0; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .table { font-size: 12px; }
  .table th, .table td { padding: 10px 12px; }
  .table th { font-size: 8.5px; letter-spacing: 1px; }
  .money { font-size: 11.5px; }
  .doc-num { font-size: 11px; }
}

/* ═══════════ IMPRESIÓN — solo la hoja ═══════════ */

@media print {
  html { color-scheme: light; }
  body { background: #fff; }
  .app, .no-print, .modal { display: none !important; }
  .docview {
    position: static;
    background: #fff;
    overflow: visible;
    padding: 0;
  }
  .sheet {
    width: 100%;
    min-height: 0;
    margin: 0;
    box-shadow: none;
  }
  .sheet__band, .sheet__meta, .sheet__logo {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

@page { size: letter; margin: 0; }
