/*
 * ╔══════════════════════════════════════════════════════════╗
 * ║           ERPgas — Sistema de Diseño Base v1.1          ║
 * ║           Desarrollado por eweb 2.0                     ║
 * ╚══════════════════════════════════════════════════════════╝
 *
 * v1.1 — .r-card: overflow:visible para soporte de collapse
 *
 * USO: Incluir este archivo en cada pantalla del sistema:
 *   <link rel="stylesheet" href="erpgas-base.css" />
 *
 * Google Fonts requeridas (incluir en <head>):
 *   <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Syne:wght@700&display=swap" rel="stylesheet" />
 */

/* ══════════════════════════════════════════════════════════
   RESET & VARIABLES
══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Marca */
  --brand:        #4f46e5;
  --brand-dark:   #4338ca;
  --brand-light:  #eef2ff;

  /* Superficies */
  --surface:      #ffffff;
  --surface2:     #f7f8f6;
  --bg:           #f1f0ec;

  /* Bordes */
  --border:       rgba(0,0,0,0.09);
  --border2:      rgba(0,0,0,0.16);

  /* Texto */
  --text:         #1a1a18;
  --text2:        #5f5e5a;

  /* Tipografía */
  --font-display: 'Syne', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  /* Radios */
  --radius:       12px;
  --radius-sm:    8px;

  /* Layout */
  --header-h:     72px;
}

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

/* ══════════════════════════════════════════════════════════
   HEADER
══════════════════════════════════════════════════════════ */
.erp-header {
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
  position: sticky;
  top: 0;
  z-index: 200;
}

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

/* Botón hamburguesa */
.hamburger-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  border: 0.5px solid var(--border2);
  background: var(--surface2);
  cursor: pointer;
  /* Oculto en escritorio; visible en tablet/celular (ver media query abajo) */
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; transition: background 0.15s; flex-shrink: 0;
}
@media (max-width: 820px) { .hamburger-btn { display: flex; } }
.hamburger-btn:hover { background: #eaebe8; }
.hamburger-btn span {
  display: block; width: 18px; height: 2px;
  background: var(--text2); border-radius: 2px;
  transition: transform 0.25s, opacity 0.25s, width 0.25s;
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; width: 0; }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Logo */
.erp-logo { display: flex; align-items: center; gap: 8px; text-decoration: none; }
.erp-logo-mark {
  width: 32px; height: 32px; background: var(--brand);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.erp-logo-text {
  font-family: var(--font-display); font-size: 20px;
  color: var(--brand); letter-spacing: -0.5px;
}

/* Botones de acción del header */
.erp-header-actions { display: flex; align-items: stretch; height: 100%; gap: 0; }

.erp-action-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 0 12px; border: none; background: transparent; cursor: pointer;
  color: #8a9099; font-family: var(--font-body); font-size: 10.5px; font-weight: 500;
  transition: background 0.15s, color 0.15s; text-decoration: none; white-space: nowrap; height: 100%;
}
.erp-action-btn .btn-icon {
  width: 34px; height: 34px; border-radius: 10px; background: #f4f5f7;
  display: flex; align-items: center; justify-content: center; transition: background 0.15s;
}
.erp-action-btn svg { width: 18px; height: 18px; }
.erp-action-btn:hover { background: #fafbfc; color: #3a4048; }
.erp-action-btn:hover .btn-icon { background: #e8eaed; }
.erp-action-btn.danger .btn-icon { background: #fff0ee; }
.erp-action-btn.danger svg { stroke: #e05444; }
.erp-action-btn.danger { color: #e05444; }
.erp-action-btn.danger:hover { background: #fff7f6; color: #c0392b; }
.erp-action-btn.danger:hover .btn-icon { background: #ffddd9; }

/* ══════════════════════════════════════════════════════════
   SUBHEADER (barra verde)
══════════════════════════════════════════════════════════ */
.erp-subheader {
  background: var(--brand);
  padding: 9px 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.erp-section-title {
  font-family: var(--font-display); font-size: 12px;
  color: rgba(255,255,255,0.88); letter-spacing: 0.5px; text-transform: uppercase;
}
.subheader-right { display: flex; align-items: center; gap: 8px; }
.erp-branch-badge {
  background: rgba(255,255,255,0.28); color: #fff;
  font-size: 12px; padding: 4px 12px; border-radius: 20px; font-weight: 600;
}
.erp-user-badge {
  background: rgba(255,255,255,0.20); color: #fff;
  font-size: 12px; padding: 4px 12px; border-radius: 20px; font-weight: 600;
}

/* ══════════════════════════════════════════════════════════
   DRAWER (menú hamburguesa)
══════════════════════════════════════════════════════════ */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 300; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px;
  background: var(--surface); z-index: 400;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  background: var(--brand); padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: 10px;
  min-height: var(--header-h); flex-shrink: 0;
}
.drawer-header .erp-logo-mark { width: 36px; height: 36px; background: rgba(255,255,255,0.2); }
.drawer-title { font-family: var(--font-display); font-size: 18px; color: #fff; letter-spacing: -0.3px; }
.drawer-subtitle { font-size: 11px; color: rgba(255,255,255,0.65); margin-top: 1px; }

.drawer-body { flex: 1; overflow-y: auto; padding: 0.5rem 0 1rem; }
.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Ítems del menú */
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 1.25rem; text-decoration: none; color: var(--text);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.12s; user-select: none;
  border: none; background: transparent; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface2); }
.nav-item.active { background: var(--brand-light); color: var(--brand); }
.nav-item.active .nav-icon { background: var(--brand); }
.nav-item.active .nav-icon svg { stroke: #fff; }

.nav-icon {
  width: 26px; height: 26px; border-radius: 7px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.12s;
}
.nav-icon svg {
  width: 16px; height: 16px; fill: none; stroke: var(--text2);
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nav-label { flex: 1; }
.nav-chevron {
  width: 16px; height: 16px; flex-shrink: 0; transition: transform 0.2s;
  fill: none; stroke: var(--text2); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-item.expanded .nav-chevron { transform: rotate(90deg); }

.nav-submenu {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1);
  background: #fafaf8; border-left: 2px solid var(--brand-light);
  margin-left: 1.25rem;
}
.nav-submenu.open { max-height: 400px; }

.nav-sub-section {
  padding: 3px 1rem 1px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px; color: var(--brand); margin-top: 2px;
}
.nav-subitem {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 1rem 7px 1.25rem; text-decoration: none;
  color: var(--text2); font-size: 12.5px; transition: background 0.1s, color 0.1s;
}
.nav-subitem::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--border2); flex-shrink: 0;
}
.nav-subitem:hover { background: var(--brand-light); color: var(--brand); }
.nav-subitem:hover::before { background: var(--brand); }
.nav-divider { height: 0.5px; background: var(--border); margin: 4px 1.25rem; }

/* ══════════════════════════════════════════════════════════
   MAIN / LAYOUT
══════════════════════════════════════════════════════════ */
.erp-main { padding: 1.25rem; max-width: none; margin: 0 auto; }

/* ══════════════════════════════════════════════════════════
   TABS
══════════════════════════════════════════════════════════ */
.tabs-bar {
  display: flex; background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; overflow: hidden;
}
.tab {
  padding: 11px 28px; font-weight: 600; cursor: pointer; color: var(--text2);
  border: none; background: transparent; transition: background 0.15s, color 0.15s;
  border-bottom: 2px solid transparent; text-transform: uppercase;
  font-size: 11.5px; letter-spacing: 0.5px; font-family: var(--font-body);
}
.tab.active { background: var(--brand-light); color: var(--brand); border-bottom-color: var(--brand); }
.tab:hover:not(.active) { background: var(--surface2); }

.tab-stats { margin-left: auto; display: flex; align-items: center; gap: 6px; padding: 0 1rem; flex-wrap: wrap; }
.stat-pill {
  background: var(--surface2); border: 0.5px solid var(--border);
  border-radius: 20px; padding: 2px 8px; font-size: 11px; color: var(--text2); white-space: nowrap;
}
.stat-pill strong { color: var(--text); }

/* ══════════════════════════════════════════════════════════
   CARDS DE CONTENIDO (formularios, tablas)
══════════════════════════════════════════════════════════ */
.form-card, .table-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
}
.form-card { padding: 1.25rem; }

/* r-card: card de sección con título coloreado.
   overflow:visible es necesario para que el collapse
   de cada sección funcione de forma independiente.   */
.r-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
}

/* ══════════════════════════════════════════════════════════
   CAMPOS DE FORMULARIO
══════════════════════════════════════════════════════════ */
label.field-lbl {
  font-size: 11.5px; font-weight: 600; color: var(--text2);
  white-space: nowrap; text-transform: uppercase; letter-spacing: 0.3px;
}
.field-group { display: flex; align-items: center; gap: 6px; }
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.section-divider { height: 0.5px; background: var(--border); margin: 1.25rem 0; }

input[type="text"], select {
  height: 34px; border: 0.5px solid var(--border2); border-radius: var(--radius-sm);
  padding: 0 10px; font-family: var(--font-body); font-size: 12.5px;
  color: var(--text); background: var(--surface); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(26,122,60,0.1);
}
input[type="radio"], input[type="checkbox"] {
  accent-color: var(--brand); width: 14px; height: 14px;
}

/* ══════════════════════════════════════════════════════════
   BOTONES
══════════════════════════════════════════════════════════ */
.btn {
  height: 34px; padding: 0 16px; border-radius: var(--radius-sm); border: none;
  font-family: var(--font-body); font-size: 12.5px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, transform 0.1s; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 0.5px solid var(--border2); }
.btn-secondary:hover { background: #eaebe8; }
.btn-ghost     { background: transparent; color: var(--text2); border: 0.5px solid var(--border2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-lg { height: 40px; padding: 0 28px; font-size: 13px; }

/* ══════════════════════════════════════════════════════════
   TABLA
══════════════════════════════════════════════════════════ */
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

.thead-sub th {
  background: #e8f0ea; color: var(--text2); font-weight: 600;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px;
  padding: 7px 10px; text-align: left;
  border-bottom: 0.5px solid var(--border); border-right: 0.5px solid var(--border);
  white-space: nowrap;
}
.thead-sub th:last-child { border-right: none; }
.thead-sub th.center { text-align: center; }

tbody tr { border-bottom: 0.5px solid var(--border); transition: background 0.1s; }
tbody tr:hover { background: #f8f9f7; }
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: #fafaf8; }
tbody tr:nth-child(even):hover { background: #f2f4f1; }

td {
  padding: 8px 10px; vertical-align: top;
  border-right: 0.5px solid var(--border); line-height: 1.4;
}
td:last-child { border-right: none; }
td.center { text-align: center; }
td.nowrap  { white-space: nowrap; }

/* Filas por estado */
tbody tr.row-cancelled { background: #fff1f1; }
tbody tr.row-cancelled:hover { background: #ffe4e4; }

/* ══════════════════════════════════════════════════════════
   BADGES DE ESTADO
══════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-dispatched { background: #eff6ff; color: #1d4ed8; border: 0.5px solid #bfdbfe; }
.badge-delivered  { background: #e8f5ee; color: #1a7a3c; border: 0.5px solid #a7f3c2; }
.badge-new        { background: #fefce8; color: #854d0e; border: 0.5px solid #fde68a; }
.badge-cancelled  { background: #fef2f2; color: #b91c1c; border: 0.5px solid #fecaca; }

/* ══════════════════════════════════════════════════════════
   BOTONES DE ACCIÓN EN TABLA
══════════════════════════════════════════════════════════ */
.action-cell { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.btn-action {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 6px; border: none;
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, transform 0.1s; white-space: nowrap;
}
.btn-action:active { transform: scale(0.96); }
.btn-reclamar { background: #eff6ff; color: #1d4ed8; border: 0.5px solid #bfdbfe; }
.btn-reclamar:hover { background: #dbeafe; }
.btn-anular   { background: #fef2f2; color: #b91c1c; border: 0.5px solid #fecaca; }
.btn-anular:hover { background: #fee2e2; }
.btn-cierre   { background: #f3f4f6; color: #374151; border: 0.5px solid #d1d5db; }
.btn-cierre:hover { background: #e5e7eb; }

/* ══════════════════════════════════════════════════════════
   TOTALES CON DESCUENTO
══════════════════════════════════════════════════════════ */
.total-wrap  { display: flex; flex-direction: column; gap: 2px; }
.total-main  { font-weight: 700; color: var(--text); }
.total-desc  { font-size: 11px; color: #dc2626; font-weight: 600; }
.total-label { font-size: 10px; color: var(--text2); }

/* ══════════════════════════════════════════════════════════
   CELDAS DE DIRECCIÓN Y CILINDROS
══════════════════════════════════════════════════════════ */
.dir-main  { font-weight: 500; color: var(--text); }
.dir-ref   { font-size: 11.5px; color: var(--text2); margin-top: 2px; }
.cyl-main  { font-weight: 600; color: var(--text); }
.cyl-obs   { font-size: 11.5px; color: var(--text2); margin-top: 2px; line-height: 1.3; }

/* ══════════════════════════════════════════════════════════
   PANEL LATERAL (lista precios, tipo cliente, pago)
══════════════════════════════════════════════════════════ */
.right-panel {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  position: sticky; top: calc(var(--header-h) + 8px);
}
.panel-section { padding: 0.75rem 1rem 0.5rem; }
.panel-section + .panel-section { border-top: 0.5px solid var(--border); }
.panel-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--brand); margin-bottom: 6px;
}
.radio-list label {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 0; font-size: 12px; color: var(--text); cursor: pointer;
}
.radio-list label:hover { color: var(--brand); }

/* ══════════════════════════════════════════════════════════
   GRUPOS DE CILINDROS POR MARCA
══════════════════════════════════════════════════════════ */
.brand-group { margin-bottom: 14px; }
.brand-group-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  letter-spacing: 0.8px; text-transform: uppercase;
  padding: 3px 12px 3px 8px; border-radius: 6px; margin-bottom: 8px;
}
.brand-group-title.gasco     { background: #e8f5ee; color: #1a7a3c; border-left: 3px solid #1a7a3c; }
.brand-group-title.lipigas   { background: #fefce8; color: #854d0e; border-left: 3px solid #eab308; }
.brand-group-title.abastible { background: #fff4ee; color: #9a3412; border-left: 3px solid #f97316; }
.brand-group-title.enap      { background: #f5f0ff; color: #5b21b6; border-left: 3px solid #7c3aed; }

.cylinders-scroll { overflow-x: auto; padding-bottom: 4px; }
.cylinders-grid   { display: flex; gap: 8px; min-width: max-content; }

.cylinder-card {
  background: var(--surface2); border: 0.5px solid var(--border);
  border-radius: var(--radius); padding: 10px 8px 8px; width: 88px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}
.cylinder-card:hover { border-color: var(--brand); }
.cylinder-price  { font-size: 11px; font-weight: 700; color: var(--text); text-align: center; }
.cylinder-label  { font-size: 12px; font-weight: 700; color: var(--text); text-align: center; line-height: 1.2; }
.cylinder-sub    { font-size: 10px; color: var(--text2); text-align: center; }
.cylinder-qty    { width: 60px; height: 28px; text-align: center; font-size: 12px; border-radius: 6px; }
.cyl-svg         { display: block; }

/* ══════════════════════════════════════════════════════════
   FILTER BAR (barra de filtros sobre tablas)
══════════════════════════════════════════════════════════ */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 1rem; border-bottom: 0.5px solid var(--border);
  background: var(--surface2); flex-wrap: wrap;
}
.filter-bar label {
  font-size: 11.5px; font-weight: 600; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap;
}
.filter-bar input[type="text"],
.filter-bar select { height: 32px; }

.btn-sectorizar {
  background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 5px 14px;
  font-family: var(--font-body); font-size: 11.5px; font-weight: 700;
  cursor: pointer; letter-spacing: 0.3px; transition: background 0.15s; text-transform: uppercase;
}
.btn-sectorizar:hover { background: var(--brand-dark); }

/* ══════════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════════ */
.erp-footer {
  text-align: center; padding: 1.5rem;
  font-size: 11px; color: var(--text2);
}
.erp-footer a { color: inherit; text-decoration: none; }
.erp-footer a:hover { text-decoration: none; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  .tab-stats { display: none; }
  .content-wrapper { grid-template-columns: 1fr !important; }
  .right-panel { position: static; }
}

@media (max-width: 600px) {
  .erp-header { padding: 0 1rem; }
  .erp-action-btn { padding: 0 8px; }
  .erp-action-btn .lbl { display: none; }
  .erp-action-btn .btn-icon { width: 30px; height: 30px; }
  .tab { padding: 10px 14px; }
  .erp-main { padding: 1rem; }
}
