:root {
  --bg: #f4f6f8;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e2e8f0;
  /* Single source of truth for the brand color — change this one value to
     re-theme every important element (Pagar, active menu item, filters,
     links) at once. */
  --primary: #0e7490;
  --primary-dark: #0b5b71;
  --primary-soft: #e3f2f5;
  --danger: #dc2626;
  --success: #16a34a;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;
  --radius: 10px;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/inter-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/fonts/inter-700.woff2') format('woff2');
}

* { box-sizing: border-box; }

/* This must win over every other display rule in this file. Several classes
   below (.btn, .pos-tile, .modal-overlay, etc.) set their own `display`, and
   a plain class selector has the same specificity as the `hidden` attribute
   selector the browser uses internally — so without !important here, an
   element that is BOTH e.g. `class="btn"` and `hidden` stays visibly on
   screen: the JS correctly toggles the attribute, but the class's `display`
   silently wins the cascade and nothing appears to happen. This was the
   actual cause of the payment modal never closing/staying stuck open. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  min-height: 100vh;
}

/* Every internal screen: flat, professional, no distracting imagery behind
   the working area. */
.app-body { background-color: var(--bg); }

/* Only the login screen keeps the decorative eye-chart illustration. */
.auth-body {
  background-color: #f6f8fc;
  background-image: url("/images/wallpaper-eyechart.png");
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
}

a { color: var(--primary); text-decoration: none; }
a:not(.btn):hover { color: var(--primary-dark); }

.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px; }

.navbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--card-bg); border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  position: sticky; top: 0; z-index: 50;
}
.navbar-left { display: flex; align-items: center; gap: 12px; }
.navbar-title { font-weight: 700; font-size: 21px; color: var(--text); }
.navbar-user { display: flex; align-items: center; gap: 14px; font-size: 15px; color: var(--muted); }
.navbar-user form { display: inline-flex; }
.navbar-user .link-button { display: inline-flex; align-items: center; gap: 6px; }

.sidebar-toggle {
  display: none; background: none; border: none; padding: 4px; cursor: pointer; color: var(--text);
}

/* ---- Menu lateral ---- */
.app-shell { display: flex; align-items: stretch; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-shell .container { flex: 1; min-width: 0; max-width: none; margin: 0; }

.sidebar {
  width: 218px; flex-shrink: 0; background: var(--card-bg); border-right: 1px solid var(--border);
  padding: 16px 10px; position: sticky; top: 0; align-self: flex-start;
  height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 20px;
  margin-bottom: 8px; border-bottom: 1px solid var(--border);
}
.sidebar-brand-icon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 36px; height: 36px; border-radius: var(--radius); background: var(--primary); color: #fff;
}
.sidebar-brand-icon .icon { width: 20px; height: 20px; }
.sidebar-brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sidebar-brand-text strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-brand-text span { font-size: 12px; color: var(--muted); }

.sidebar-grid { display: flex; flex-direction: column; gap: 4px; }
.sidebar-item {
  display: flex; flex-direction: row; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius); text-decoration: none; color: var(--text);
  font-size: 14px; text-align: left; line-height: 1.25;
}
.sidebar-item .icon { color: var(--muted); }
.sidebar-item:hover { background: var(--bg); }
.sidebar-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.sidebar-item.active .icon { color: var(--primary); }

.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 210; height: 100vh; width: 240px;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: 4px 0 20px rgba(15, 23, 42, 0.2);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
    z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
  }
  .sidebar-backdrop.visible { opacity: 1; pointer-events: auto; }
}

.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px;
}

h1 { display: flex; align-items: center; gap: 10px; font-size: 25px; margin-top: 0; }
h2 { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.muted { color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
tr:hover td { background: #fafafa; }

label { display: block; margin-bottom: 12px; font-size: 15px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; margin-top: 4px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 15px; font-family: inherit; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}

/* An email field split into a free-typed local part and a fixed domain
   suffix the person can't edit (e.g. "alejandro" + "@visionplus.com"). */
.input-with-suffix { display: flex; align-items: stretch; margin-top: 4px; }
.input-with-suffix input { margin-top: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-with-suffix .input-suffix {
  display: flex; align-items: center; padding: 9px 11px; border: 1px solid var(--border); border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0; background: #f5f7fa; color: var(--muted); font-size: 15px; white-space: nowrap;
}

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius); border: none;
  font-size: 15px; cursor: pointer; text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 14px; }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.btn:active { transform: translateY(1px); }

.link-button { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 15px; padding: 0; }

.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 15px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-success { background: #dcfce7; color: #166534; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; }
.flash-success { background: #dcfce7; color: #166534; }
.flash-error { background: #fee2e2; color: #991b1b; }

.auth-page { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.auth-card { width: 100%; max-width: 380px; text-align: center; }
.auth-card .icon-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 16px; margin-bottom: 12px;
  background: var(--primary-soft); color: var(--primary);
}
.auth-card .icon-badge .icon { width: 30px; height: 30px; }
.auth-card form { text-align: left; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.chart-box { position: relative; height: 240px; }
.chart-box-short { height: 200px; }

.stat-tiles { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-tile {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; min-width: 160px;
}
.stat-tile .value { font-size: 26px; font-weight: 700; }
.stat-tile .label { font-size: 13.5px; color: var(--muted); }

.actions-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; }
.badge-open { background: #dcfce7; color: #166534; }
.badge-closed { background: #e5e7eb; color: #374151; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

.scan-box { position: relative; margin-bottom: 16px; }

.receipt { max-width: 380px; margin: 0 auto; font-family: "Courier New", monospace; }
.receipt table { font-size: 13.5px; }

/* Icons: inherit the surrounding text color and sit on the text baseline */
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
h1 .icon, h2 .icon { color: var(--primary); }

/* ---- Venta: catalogo + carrito ---- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; height: calc(100vh - 130px); min-height: 520px; }
.pos-catalog { display: flex; flex-direction: column; min-height: 0; }
@media (max-width: 900px) {
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart { position: static; }
}

.pos-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0; flex-shrink: 0; }
.pos-tab {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.pos-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.pos-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px;
  flex: 1; overflow-y: auto; align-content: start; padding-bottom: 4px;
}
.pos-tile {
  display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: #fff; cursor: pointer; padding: 0; text-align: left; font-family: inherit;
  transition: border-color 0.15s ease, transform 0.05s ease;
}
.pos-tile:hover { border-color: var(--primary); }
.pos-tile:active { transform: translateY(1px); }
.pos-tile-thumb {
  display: flex; align-items: center; justify-content: center;
  height: 76px; background: var(--bg); color: #9aa7b6;
}
.pos-tile-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pos-tile-thumb .icon { width: 30px; height: 30px; }
.pos-tile-name { padding: 10px 10px 0; font-size: 14px; font-weight: 600; line-height: 1.3; min-height: 2.6em; text-transform: capitalize; }
.pos-tile-category { display: block; padding: 2px 10px 0; font-size: 12px; color: var(--muted); }
.pos-tile-price { display: block; padding: 4px 10px 10px; font-size: 16px; font-weight: 700; }

.pos-cart { position: sticky; top: 16px; display: flex; flex-direction: column; }
.pos-client { margin-bottom: 4px; }
.pos-cart-rows { min-height: 60px; margin: 8px 0; flex: 1; overflow-y: auto; }
.pos-cart-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 32px 16px; color: var(--muted); text-align: center;
}
.pos-cart-empty .icon { width: 40px; height: 40px; color: #cbd5e1; }
.pos-cart-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.pos-cart-row-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.pos-cart-row-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-cart-row-price { font-size: 13px; color: var(--muted); }

.qty-stepper { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.qty-btn {
  width: 26px; height: 26px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-family: inherit;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-value { min-width: 18px; text-align: center; font-weight: 600; font-size: 14px; }

.cart-row-remove {
  background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; padding: 4px; flex-shrink: 0;
}
.cart-row-remove:hover { color: var(--danger); }

.pos-cart-footer { border-top: 1px solid var(--border); padding-top: 14px; margin-top: auto; }
.pos-total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 20px; font-weight: 700; margin-bottom: 12px; }
.pos-total-row span:last-child { font-size: 28px; }

.btn-pay {
  width: 100%; justify-content: center; background: var(--primary); color: #fff;
  font-size: 18px; font-weight: 700; padding: 16px;
}
.btn-pay:hover { background: var(--primary-dark); }
.btn-pay:disabled { background: var(--primary); opacity: 0.4; cursor: not-allowed; }
.btn-pay:disabled:hover { background: var(--primary); }

/* ---- Modal de pago ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal-box {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; position: relative;
  box-shadow: 0 12px 28px -8px rgba(15,23,42,0.18);
}
.modal-close {
  position: absolute; top: 10px; right: 10px; z-index: 1; background: none; border: none;
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; border-radius: 999px;
}
.modal-close:hover { color: var(--text); background: #f1f1ef; }

.modal-box h2 { padding-right: 40px; }

.pay-total { color: var(--primary); font-size: 24px; }

.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.pay-box-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.pay-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; font-size: 20px; font-weight: 700; }
.pay-box.negative { color: var(--danger); }

.pay-popular-label { margin: 4px 0 8px; font-size: 13px; }
.popular-amounts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.popular-amount-btn {
  padding: 7px 12px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff;
  font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.popular-amount-btn:hover { border-color: var(--primary); color: var(--primary-dark); }

.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.key {
  padding: 16px 0; border-radius: var(--radius); border: 1px solid var(--border); background: #fff;
  font-size: 18px; font-weight: 600; cursor: pointer; color: var(--text); font-family: inherit;
}
.key:hover { background: var(--bg); }
.key-muted { color: var(--muted); font-size: 14px; font-weight: 500; }
.key-pay { background: var(--primary); border-color: var(--primary); color: #fff; font-size: 16px; font-weight: 700; }
.key-pay:hover { background: var(--primary-dark); }

/* ---- Resultados de busqueda (tickets / precios) ---- */
.search-results-list { max-height: 340px; overflow-y: auto; margin-top: 12px; }
.search-result-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.search-result-title { font-size: 14px; font-weight: 600; }
.search-result-sub { font-size: 12.5px; color: var(--muted); }
.search-result-value { font-size: 15px; font-weight: 700; white-space: nowrap; }
.search-empty { color: var(--muted); font-size: 14px; padding: 12px 4px; }

.app-footer {
  text-align: center; font-size: 11px; color: var(--muted);
  padding: 10px 16px 16px; opacity: 0.8;
}

@media print {
  .navbar, .no-print, .app-footer, .sidebar, .sidebar-backdrop { display: none !important; }
  .app-shell { display: block; }
  .container { max-width: 100%; padding: 0; }
  body, .app-body, .auth-body { background: #fff !important; }
}
