/*
  Minimal, consistent UI kit (Brand theme)
  - No build required; served from /public/css/app.css
  - Keep selectors general to style existing markup without refactors
*/

:root {
  /* Design tokens */
  --bg-soft: #F6EEEB;           /* page background */
  --surface: #ffffff;           /* cards, panels */
  --text: #1f2937;              /* body text */
  --muted: #6b7280;             /* muted text */
  --border: #e5e7eb;            /* subtle borders */
  --brand: #500200;             /* primary brand */
  --brand-600: #3f0100;         /* hover/active */
  --brand-800: #2e0100;         /* strong accents */
  --tint-weak: rgba(80,2,0,0.06);  /* subtle brand tint */
  --tint-medium: rgba(80,2,0,0.10);/* medium brand tint */
  --color-success: #059669;
  --color-danger: #dc2626;
  --radius: 8px;
}

/* CSS Reset (lightweight) */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-family: 'Poppins', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.65;
  /* Global font size reduced ~2px from browser default (16px -> 14px) */
  font-size: 14px;
}

/* Selection highlight */
::selection {
  background: var(--tint-medium);
}

/* Touch-friendly tap targets */
input[type="text"], input[type="number"], input[type="date"], select, button, .btn {
  min-height: 44px;
}

/* App shell */
.app-shell { display: grid; grid-template-columns: 64px 1fr; min-height: 100vh; }
@media (max-width: 640px) { .app-shell { grid-template-columns: 1fr; } }
@media (min-width: 1024px) { .app-shell { grid-template-columns: 220px 1fr; } }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px; position: sticky; top: 0; height: 100vh; transition: transform .2s ease; }
.sidebar.is-collapsed { transform: translateX(-100%); position: fixed; left: 0; z-index: 1000; }
.mobile-nav-toggle { position: fixed; left: 8px; top: 8px; z-index: 1100; display: inline-flex; align-items:center; justify-content:center; width:40px; height:40px; border-radius:8px; background: var(--brand); color:#fff; border:1px solid var(--brand); font-size: 26px; line-height: 1; }
.mobile-nav-toggle:hover { background: var(--brand-600); }
@media (min-width: 1024px) { .mobile-nav-toggle { display: none; } }
@media (max-width: 640px) {
  /* Sidebar overlays content on mobile and doesn't reserve layout space */
  .sidebar { position: fixed; left: 0; top: 0; height: 100vh; width: 80vw; max-width: 280px; transform: translateX(0); z-index: 1000; box-shadow: 2px 0 10px rgba(0,0,0,0.08); }
}
.sidebar .logo { margin: 8px; display:flex; justify-content:center; }
.sidebar .logo img { max-width: 56px; height: auto; display:block; }
@media (min-width: 1024px) { .sidebar .logo img { max-width: 180px; } }
@media (max-width: 640px) { .sidebar .logo img { max-width: 96px; } }
.nav-vertical { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.nav-vertical a { padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: 8px; }
.nav-vertical a:hover { background: var(--tint-weak); color: var(--brand-800); }
.nav-vertical .active { background: var(--tint-medium); color: var(--brand-800); font-weight: 700; }
.content { overflow-x: auto; overflow-y: visible; }
.toolbar { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 0; }
.toolbar .title { font-size: 1.25rem; font-weight: 700; }

/* Layout */
.container { max-width: 93%; margin: 0 auto; padding: 16px; }
@media (max-width: 640px) { .container { max-width: 90%; padding: 12px; } }
@media (max-width: 640px) { .content .container { padding-top: 56px; } }
/* Full-width option */
.container-fluid { width: 100%; margin: 0; padding: 16px; }

header, nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
nav { padding: 12px 16px; }
nav a { color: var(--brand); text-decoration: none; margin-right: 12px; font-weight: 600; }
nav a:hover { color: var(--brand-600); text-decoration: underline; }

hr { border: 0; border-top: 1px solid var(--color-border); margin: 0; }

/* Typography */
h1, h2, h3 { margin: 16px 0 8px; }
p { color: var(--color-text); }
small, .muted { color: var(--color-muted); }

/* Cards / panels */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
@media (max-width: 640px) { .card { padding: 12px; } }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 12px; }

/* Forms */
label { display: inline-block; margin: 8px 12px 8px 0; }
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: min(380px, 100%);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
@media (max-width: 640px) {
  label { width: 100%; }
  input[type="text"], input[type="password"], input[type="number"], input[type="date"], textarea, select { width: 100%; }
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Buttons */
button, .btn, .btn-secondary, .btn-danger {
  display: inline-block;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--brand);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
/* Large buttons for touch */
.btn-lg { padding: 14px 18px; font-size: 1.05rem; }
.actions-center { display:flex; justify-content:center; gap:12px; flex-wrap: wrap; }
button:hover, .btn:hover, .btn-secondary:hover, .btn-danger:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-secondary { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn-secondary:hover { background: var(--tint-weak); }
.btn-danger { background: var(--color-danger); border-color: var(--color-danger); }
.btn-danger:hover { filter: brightness(0.95); }

/* Alerts */
.alert { padding: 10px 12px; border-radius: 6px; margin: 10px 0; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.badge { display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px; background: var(--tint-medium); color: var(--brand-800); }
.chip { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border:1px solid var(--color-border); border-radius:999px; background:#fff; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border:1px solid var(--border); border-radius: 8px; overflow: hidden; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); text-align: left; }
thead th { background: #fff; color: var(--brand-800); position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: var(--tint-weak); }
tbody tr:last-child td { border-bottom: 0; }
.table-toolbar { display:flex; align-items:center; gap:12px; flex-wrap: wrap; }
/* Scrollable table wrapper for iPad */
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 720px; }
@media (max-width: 640px) {
  .table-scroll table { min-width: 560px; }
}

/* Simple list style (no outer borders, just row separators) */
.list { width: 100%; border: 0; background: transparent; border-collapse: collapse; border-radius: 0; }
.list td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list tr:last-child td { border-bottom: 0; }

/* Utilities */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.text-right { text-align: right; }
.sticky-actions { position: sticky; bottom: 0; background: var(--color-surface); padding: 10px; border-top: 1px solid var(--color-border); }

/* Responsive columns: 1-col narrow, 2-col wide */
.grid { display: grid; gap: 16px; }
.grid-1-2 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-1-2 { grid-template-columns: 1fr 1fr; } }
/* Three-column responsive grid */
.grid-1-3 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-1-3 { grid-template-columns: 1fr 1fr 1fr; } }
/* Four-column responsive grid */
.grid-1-4 { grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-1-4 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 640px) {
  .grid { gap: 12px; }
  /* Make any grid-1-2 strictly single column on small screens */
  .grid-1-2 { grid-template-columns: 1fr !important; }
  /* Prevent nested cards from forcing overflow */
  .card { overflow-x: auto; }
}

/* Grid item span helper */
.grid-span-full { grid-column: 1 / -1; }

/* Grid alignment helpers */
.grid.align-start { align-items: start; }
@media (min-width: 900px) {
  .grid.equal-rows { grid-auto-rows: 1fr; }
  .grid.equal-rows > .card { height: 100%; display: flex; flex-direction: column; }
}

/* Dashboard responsive */
.dashboard-grid { grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .dashboard-grid { grid-template-columns: 2fr 1fr; } }
.dashboard-cards { grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .dashboard-cards { grid-template-columns: 1fr 1fr; } }

/* Stepper / flow bar */
.flow { display:flex; gap:8px; align-items:center; flex-wrap: wrap; margin-bottom: 8px; }
.flow .step { display:flex; align-items:center; gap:8px; padding:6px 10px; border:1px solid var(--border); border-radius:999px; background:#fff; color:var(--muted); }
.flow .step.active { border-color: var(--brand); color: var(--brand-800); background: var(--tint-weak); font-weight:600; }
.flow .sep { color: var(--muted); }
/* Utility for keypad/buttons text color */
.key { color: black; }

/* Ticket preview */
.ticket { font-family: 'Poppins', system-ui, sans-serif; }
.ticket table { width:100%; border:0; border-collapse: collapse; }
.ticket th, .ticket td { padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.ticket tfoot td { font-weight:700; border-top: 1px solid var(--border); }

/* Simple icons (emoji) spacing */
.ico { width: 24px; display:inline-flex; justify-content:center; }

/* POS specifics */
#lineasTable tfoot td { font-weight: 700; }
#totalSpan { font-weight: 700; color: var(--brand-800); }

/* Calendar (rentas) */
.cal { user-select: none; }
.cal .header { display:flex; align-items:center; justify-content: space-between; margin-bottom: 8px; }
.cal .grid { display:grid; grid-template-columns: repeat(7,1fr); gap: 6px; }
.cal .dow { text-align:center; font-weight:600; color: var(--muted); }
.cal .day { text-align:center; padding: 10px 0; border:1px solid var(--border); border-radius: 6px; background:#fff; cursor:pointer; }
.cal .day.today { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal .day.occupied { color: #aaa; background: #f3f4f6; cursor:not-allowed; }
.cal .day.selected { background: var(--tint-medium); border-color: var(--brand); }
.cal .legend { display:flex; gap:12px; align-items:center; margin-top:8px; color: var(--muted); font-size: 14px; }

/* Print styles for ticket */
@media print {
  nav, .btn, button { display: none !important; }
  body { background: #fff; }
  table { page-break-inside: avoid; }
}
