/* ============================================================
   AlphaAPP CRM — Estilos v1
   Paleta: dark-tech Alpha 43
   ============================================================ */

:root {
  --bg:           #060c14;
  --bg-alt:       #0b1622;
  --bg-card:      rgba(14, 26, 50, 0.85);
  --bg-input:     rgba(11, 22, 34, 0.9);
  --sidebar-bg:   #07101a;
  --sidebar-w:    240px;
  --text:         #d0e8f8;
  --text-soft:    rgba(180, 212, 240, 0.72);
  --text-muted:   rgba(180, 212, 240, 0.42);
  --white:        #ffffff;
  --accent:       #20c4b1;
  --accent-2:     #2dd4bf;
  --electric:     #00d4ff;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --success:      #22c55e;
  --navy:         #0d1b2a;
  --border:       rgba(32, 196, 177, 0.18);
  --border-h:     rgba(32, 196, 177, 0.45);
  --grad-accent:  linear-gradient(90deg, #20c4b1 0%, #00d4ff 100%);
  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    18px;
  --font:         'Poppins', system-ui, -apple-system, sans-serif;
  --sh:           0 8px 32px rgba(0,0,0,.45);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--electric); }
h1, h2, h3, h4 { font-family: var(--font); color: var(--white); line-height: 1.2; margin: 0 0 .5em; font-weight: 700; }
p { margin: 0 0 1rem; color: var(--text-soft); }
ul { margin: 0; padding: 0; list-style: none; }

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar__logo { height: 32px; width: auto; }
.sidebar__appname {
  font-size: .9rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .05em;
  background: var(--grad-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar__nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.sidebar__section {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 8px 4px;
  margin: 0;
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: .85rem;
  font-weight: 500;
  transition: background .2s, color .2s;
}
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar__link:hover,
.sidebar__link.active {
  background: rgba(32,196,177,.1);
  color: var(--accent);
}
.sidebar__link.active { border-left: 2px solid var(--accent); margin-left: -2px; }

.sidebar__user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px;
  border-top: 1px solid var(--border);
}
.sidebar__user-name {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--white);
}
.sidebar__user-role {
  display: block;
  font-size: .7rem;
  color: var(--accent);
  text-transform: capitalize;
}
.sidebar__logout {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: color .2s;
  padding: 6px;
  border-radius: var(--radius-sm);
}
.sidebar__logout:hover { color: var(--danger); background: rgba(239,68,68,.1); }
.sidebar__logout svg { width: 18px; height: 18px; }

/* ── TOPBAR TOGGLE (móvil) ───────────────────────────────── */
.topbar__toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 200;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
}
.topbar__toggle span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: .3s;
}

/* ── MAIN CONTENT ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  flex: 1;
  padding: 32px 36px;
}

.flash-wrap { margin-bottom: 20px; }

/* ── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.6rem; margin: 0; }
.page-breadcrumb {
  font-size: .78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.page-breadcrumb a { color: var(--text-muted); }
.page-breadcrumb a:hover { color: var(--accent); }

/* ── CARDS / STAT CARDS ──────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-card__icon {
  width: 44px; height: 44px;
  background: rgba(32,196,177,.12);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--accent);
}
.stat-card__icon svg { width: 22px; height: 22px; }
.stat-card__num {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--white);
  line-height: 1;
}
.stat-card__label {
  display: block;
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── TABLE ───────────────────────────────────────────────── */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 10px;
}
.table-toolbar h2 { margin: 0; font-size: 1rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.15);
}
tbody tr {
  border-bottom: 1px solid rgba(32,196,177,.07);
  transition: background .15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(32,196,177,.04); }
tbody td { padding: 11px 16px; color: var(--text); vertical-align: middle; }
tbody td a { color: var(--accent); font-weight: 500; }
tbody td a:hover { color: var(--electric); }

/* ── BADGES / STATUS ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: capitalize;
}
.badge--draft    { background: rgba(180,212,240,.12); color: var(--text-soft); }
.badge--sent     { background: rgba(0,212,255,.15);   color: var(--electric); }
.badge--paid     { background: rgba(34,197,94,.15);   color: var(--success); }
.badge--cancelled{ background: rgba(239,68,68,.15);   color: var(--danger); }
.badge--admin    { background: rgba(32,196,177,.15);  color: var(--accent); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .84rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary {
  background: var(--grad-accent);
  color: #0d1b2a;
}
.btn--primary:hover { opacity: .88; color: #0d1b2a; }
.btn--ghost {
  background: transparent;
  border: 1px solid var(--border-h);
  color: var(--text-soft);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn--danger {
  background: rgba(239,68,68,.15);
  border: 1px solid rgba(239,68,68,.35);
  color: var(--danger);
}
.btn--danger:hover { background: rgba(239,68,68,.25); }
.btn--sm { padding: 5px 12px; font-size: .78rem; }
.btn--icon { padding: 7px; border-radius: var(--radius-sm); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 860px;
}
.form-section {
  margin-bottom: 24px;
}
.form-section h3 {
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.form-grid--2 { grid-template-columns: 1fr 1fr; }
.form-grid--3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field--full { grid-column: 1/-1; }
.field label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.field input,
.field select,
.field textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: .88rem;
  padding: 9px 12px;
  transition: border-color .2s;
  width: 100%;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32,196,177,.12);
}
.field textarea { resize: vertical; min-height: 80px; }
.field select option { background: var(--navy); }

/* ── INVOICE LINES TABLE ─────────────────────────────────── */
.lines-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.lines-table th {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.lines-table td { padding: 6px 6px; vertical-align: middle; }
.lines-table td input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: .85rem;
  padding: 7px 10px;
  width: 100%;
}
.lines-table td input:focus {
  outline: none;
  border-color: var(--accent);
}
.lines-table .col-desc { width: 45%; }
.lines-table .col-qty  { width: 12%; }
.lines-table .col-price{ width: 16%; }
.lines-table .col-total{ width: 14%; color: var(--white); font-weight: 600; text-align: right; padding-right: 14px; }
.lines-table .col-del  { width: 7%; text-align: center; }
.btn-remove-line {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color .2s;
  padding: 4px;
  border-radius: 4px;
}
.btn-remove-line:hover { color: var(--danger); background: rgba(239,68,68,.1); }
.btn-remove-line svg { width: 16px; height: 16px; display: block; }

/* ── INVOICE TOTALS ──────────────────────────────────────── */
.invoice-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-top: 8px;
}
.invoice-totals .total-row {
  display: flex;
  gap: 32px;
  font-size: .9rem;
}
.invoice-totals .total-row span:first-child { color: var(--text-muted); min-width: 100px; text-align: right; }
.invoice-totals .total-row span:last-child { color: var(--text); min-width: 110px; text-align: right; }
.invoice-totals .total-row--big span { color: var(--white); font-size: 1.1rem; font-weight: 700; }
.invoice-totals .total-row--big span:first-child { color: var(--text-soft); }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
}
.alert--success { background: rgba(34,197,94,.15);  border: 1px solid rgba(34,197,94,.3);  color: var(--success); }
.alert--error   { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.3);  color: var(--danger); }
.alert--warning { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.3); color: var(--warning); }
.alert--info    { background: rgba(32,196,177,.12); border: 1px solid var(--border); color: var(--text-soft); }

/* ── LOGIN PAGE ──────────────────────────────────────────── */
.login-wrap {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 30% 40%, rgba(32,196,177,.12) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(0,212,255,.08) 0%, transparent 50%),
              var(--bg);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 42px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--sh);
}
.login-card__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 28px;
}
.login-card__logo { height: 38px; }
.login-card__title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--white);
  text-align: center;
  margin-bottom: 6px;
}
.login-card__sub {
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; font-size: .9rem; margin-top: 6px; }

/* ── PRINT INVOICE ───────────────────────────────────────── */
@media print {
  .sidebar, .topbar__toggle, .main-content > .flash-wrap,
  .page-header .btn-group, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  body { background: #fff; color: #000; }
  .invoice-print { max-width: 100% !important; }
}

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,.5);
  }
  .topbar__toggle { display: flex; }
  .main-content { margin-left: 0; padding: 64px 18px 24px; }
  .form-grid--2, .form-grid--3 { grid-template-columns: 1fr; }
  .form-card { padding: 20px 16px; }
}
