/* ============================================================
   Pixelart Helpdesk — Panel de administración
   Estilo inspirado en Linear.app
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --navy:        #0a1628;
  --navy-border: rgba(255,255,255,.08);
  --blue:        #1e88e5;
  --blue-dark:   #1565c0;
  --blue-alpha:  rgba(30,136,229,.1);

  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --border:      #e5e7eb;
  --border-soft: #f0f2f5;

  --text-primary:   #111827;
  --text-secondary: #6b7280;
  --text-tertiary:  #9ca3af;

  --green:       #16a34a;
  --green-light: #dcfce7;
  --orange:      #d97706;
  --orange-light:#fef3c7;
  --red:         #dc2626;
  --red-light:   #fee2e2;

  --sidebar-w:  220px;
  --radius:     8px;
  --radius-sm:  6px;
  --shadow-xs:  0 1px 2px rgba(0,0,0,.04);
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);

  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px 36px 48px;
  min-width: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--navy-border);
  flex-shrink: 0;
}

.sidebar-logo img {
  height: 100px;
  width: auto;
  object-fit: contain;
}

.sidebar-nav {
  list-style: none;
  flex: 1;
  padding: 8px;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -.01em;
  transition: background .12s, color .12s;
  text-decoration: none;
}

.sidebar-nav li a:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
  text-decoration: none;
}

.sidebar-nav li a.active {
  background: rgba(255,255,255,.1);
  color: #ffffff;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--navy-border);
  flex-shrink: 0;
}

.sidebar-footer a {
  color: rgba(255,255,255,.4);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: color .12s;
}

.sidebar-footer a:hover { color: rgba(255,255,255,.7); }

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.025em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  letter-spacing: -.01em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .12s, border-color .12s;
}

.btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
  box-shadow: none;
}

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

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-warning {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #ffffff;
  box-shadow: none;
}

.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
  color: #ffffff;
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
  box-shadow: none;
}

.btn-success:hover {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
}

.btn-whatsapp {
  background: #25d366;
  border-color: #25d366;
  color: #ffffff;
  font-weight: 600;
  box-shadow: none;
}

.btn-whatsapp:hover {
  background: #1fb857;
  border-color: #1fb857;
  color: #ffffff;
}

.btn-full { width: 100%; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.alert-success {
  background: var(--green-light);
  border-color: #bbf7d0;
  color: #14532d;
}

.alert-error {
  background: var(--red-light);
  border-color: #fecaca;
  color: #7f1d1d;
}

/* ── Forms ───────────────────────────────────────────────────── */
.form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 640px;
  box-shadow: var(--shadow-sm);
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="month"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
  appearance: none;
  -webkit-appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-alpha);
}

.form-group textarea { resize: vertical; min-height: 88px; }

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: 7px;
  accent-color: var(--blue);
}

.form-group input[type="file"] {
  width: 100%;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
}

/* ── Filters bar ─────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--surface);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.filters select,
.filters input[type="month"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color .12s, box-shadow .12s;
  min-width: 150px;
  appearance: none;
  -webkit-appearance: none;
}

.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-alpha);
}

/* ── Table ───────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-tertiary);
  background: var(--bg);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.table thead tr th:first-child { border-top-left-radius:  var(--radius); }
.table thead tr th:last-child  { border-top-right-radius: var(--radius); }

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr:last-child td              { border-bottom: none; }
.table tbody tr:last-child td:first-child  { border-bottom-left-radius:  var(--radius); }
.table tbody tr:last-child td:last-child   { border-bottom-right-radius: var(--radius); }

.table tbody tr:hover td { background: #f9fafc; }

.table tfoot td {
  padding: 11px 14px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.table tfoot tr:last-child td:first-child { border-bottom-left-radius:  var(--radius); }
.table tfoot tr:last-child td:last-child  { border-bottom-right-radius: var(--radius); }

.estatus-abierto   > td:first-child { border-left: 2px solid var(--green); }
.estatus-cerrado   > td:first-child { border-left: 2px solid var(--orange); }
.estatus-facturado > td:first-child { border-left: 2px solid var(--blue); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.badge-abierto   { background: var(--green-light);  color: #14532d; }
.badge-cerrado   { background: var(--orange-light); color: #78350f; }
.badge-facturado { background: #dbeafe;             color: #1e3a8a; }

/* ── Dashboard stats ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}

.stat-number {
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.03em;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Sections ────────────────────────────────────────────────── */
.section { margin-bottom: 28px; }

.section h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.01em;
  margin-bottom: 12px;
}

/* ── Detail card ─────────────────────────────────────────────── */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.detail-card h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-tertiary);
  margin: 22px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}

.detail-card h3:first-child { margin-top: 0; }

.detail-card p {
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.75;
}

.detail-list {
  display: grid;
  grid-template-columns: 130px 1fr;
}

.detail-list dt {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-tertiary);
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
}

.detail-list dd {
  padding: 9px 0;
  color: var(--text-primary);
  font-size: 13.5px;
  border-bottom: 1px solid var(--border-soft);
}

/* ── Files grid ──────────────────────────────────────────────── */
.archivos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.archivo-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
}

.archivo-tipo {
  display: block;
  padding: 7px 10px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  background: var(--border-soft);
  border-bottom: 1px solid var(--border);
}

.archivo-item img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

/* ── Facturación actions ─────────────────────────────────────── */
.facturacion-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  color: var(--text-tertiary);
  text-align: center;
  padding: 40px 16px;
  font-size: 13px;
}

/* ── Login ───────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  height: 36px;
  width: auto;
  margin: 0 auto 20px;
  object-fit: contain;
  display: block;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -.025em;
  margin-bottom: 24px;
}

.login-card .form-group label { text-align: left; }
.login-card .btn { margin-top: 6px; }

/* ── Mobile header & sidebar close (hidden on desktop) ───────── */
.mobile-header  { display: none; }
.nav-overlay    { display: none; }
.sidebar-close  { display: none; }

/* ── Utilities ───────────────────────────────────────────────── */
code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  color: var(--text-primary);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ============================================================
   RESPONSIVE — Mobile (< 768 px)
   ============================================================ */
@media (max-width: 767px) {

  /* ── Mobile top bar ───────────────────────────────────────── */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    padding: 0 16px;
    background: var(--navy);
    z-index: 90;
    box-shadow: 0 1px 0 rgba(255,255,255,.06);
  }

  .mobile-logo {
    height: 34px;
    width: auto;
    object-fit: contain;
  }

  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background .12s;
  }

  .hamburger:hover { background: rgba(255,255,255,.08); }

  .hamburger span {
    display: block;
    height: 2px;
    background: rgba(255,255,255,.8);
    border-radius: 2px;
  }

  /* ── Overlay ──────────────────────────────────────────────── */
  .nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 150;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  body.nav-open .nav-overlay { display: block; }

  /* ── Sidebar como panel deslizable ───────────────────────── */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    z-index: 200;
  }

  body.nav-open .sidebar { transform: translateX(0); }

  .sidebar-logo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
  }

  .sidebar-logo img { height: 44px; }

  .sidebar-close {
    display: block;
    width: 32px;
    height: 32px;
    text-align: center;
    line-height: 32px;
    background: rgba(255,255,255,.08);
    border: none;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.7);
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background .12s, color .12s;
  }

  .sidebar-close:hover {
    background: rgba(255,255,255,.14);
    color: #fff;
  }

  /* ── Main content ─────────────────────────────────────────── */
  .main-content {
    margin-left: 0;
    padding: 72px 16px 48px;
  }

  /* ── Page header ──────────────────────────────────────────── */
  .page-header {
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
  }

  .page-actions { flex-wrap: wrap; }

  /* ── Formularios ──────────────────────────────────────────── */
  .form {
    max-width: 100%;
    padding: 20px 16px;
  }

  .form-group input[type="text"],
  .form-group input[type="email"],
  .form-group input[type="number"],
  .form-group input[type="date"],
  .form-group input[type="month"],
  .form-group input[type="password"],
  .form-group select {
    min-height: 48px;
    font-size: 16px;
    padding: 10px 12px;
  }

  .form-group textarea {
    min-height: 96px;
    font-size: 16px;
    padding: 10px 12px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn,
  .form-actions form,
  .form-actions form .btn { width: 100%; }

  /* ── Filtros ──────────────────────────────────────────────── */
  .filters {
    flex-direction: column;
    gap: 10px;
    padding: 14px 12px;
  }

  .filters select,
  .filters input[type="month"] {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  .filters .btn { width: 100%; }

  /* ── Acciones de facturación ──────────────────────────────── */
  .facturacion-actions {
    flex-direction: column;
  }

  .facturacion-actions > *,
  .facturacion-actions .btn { width: 100%; }

  /* ── Tablas → tarjetas apiladas ───────────────────────────── */
  .table {
    display: block;
    border: none;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
  }

  .table thead { display: none; }

  .table tbody { display: block; }

  .table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    box-shadow: var(--shadow-xs);
    overflow: hidden;
  }

  .table tbody tr:hover td { background: transparent; }

  .table tbody tr td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13.5px;
    border-left: none !important;
  }

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

  .table tbody tr td::before {
    content: attr(data-label);
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-tertiary);
    flex-shrink: 0;
    margin-right: 12px;
  }

  /* Celdas de acciones: sin etiqueta, alineadas a la izquierda */
  .table tbody tr td[data-label=""] {
    justify-content: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 14px;
  }

  .table tbody tr td[data-label=""]::before { content: none; }

  /* Acento de estatus → borde izquierdo en la tarjeta */
  .estatus-abierto   { border-left: 3px solid var(--green)  !important; }
  .estatus-cerrado   { border-left: 3px solid var(--orange) !important; }
  .estatus-facturado { border-left: 3px solid var(--blue)   !important; }

  /* tfoot: resumen en una sola fila */
  .table tfoot { display: block; }

  .table tfoot tr {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  .table tfoot td {
    display: inline;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0;
  }

  .table tfoot td::before { content: none; }

  /* ── Detail card ──────────────────────────────────────────── */
  .detail-card { padding: 20px 16px; }

  .detail-list { grid-template-columns: 1fr; }

  .detail-list dt {
    border-bottom: none;
    padding-bottom: 2px;
    padding-top: 14px;
  }

  .detail-list dt:first-of-type { padding-top: 0; }

  .detail-list dd { padding-top: 0; }

  /* ── Stats ────────────────────────────────────────────────── */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }

  /* ── Login ────────────────────────────────────────────────── */
  .login-card { padding: 28px 20px; margin: 16px; }
}
