/* ============================================================
   Crea Tus Ideas - Sistema de Ventas
   ============================================================ */

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

:root {
  --navy:       #1a237e;
  --navy-dark:  #0d1457;
  --navy-light: #283593;
  --orange:     #ff6f00;
  --orange-light: #ff8f00;
  --bg:         #f0f2f8;
  --white:      #ffffff;
  --text:       #1e293b;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     10px;
  --shadow:     0 2px 8px rgba(0,0,0,.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,.12);
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── SCROLLBAR ─────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── SIDEBAR ───────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-brand .brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-icon {
  width: 38px; height: 38px;
  background: var(--orange);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 15px; font-weight: 700;
  color: #fff; line-height: 1.2;
}
.brand-text span { font-size: 11px; color: rgba(255,255,255,.5); }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 12px 20px 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s ease;
  border-left: 3px solid transparent;
  position: relative;
}

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

.sidebar-link.active {
  color: #fff;
  background: rgba(255,255,255,.1);
  border-left-color: var(--orange);
}

.sidebar-link .nav-icon {
  width: 18px; text-align: center; flex-shrink: 0;
  opacity: .8;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: rgba(255,255,255,.06);
  border-radius: 8px;
}

.user-avatar {
  width: 32px; height: 32px;
  background: var(--orange);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(255,255,255,.45); }

.sidebar-logout {
  color: rgba(255,255,255,.5);
  text-decoration: none;
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
}
.sidebar-logout:hover { color: #ff5252; }

/* ── MAIN CONTENT ──────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.topbar-date {
  font-size: 12.5px;
  color: var(--muted);
}

.btn-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
}
.btn-sidebar-toggle:hover { background: var(--bg); }

.page-content { flex: 1; padding: 28px; }

/* ── CARDS ─────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

/* ── STAT CARDS ────────────────────────────────────── */
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.orange { background: #fff3e0; color: var(--orange); }
.stat-icon.navy   { background: #e8eaf6; color: var(--navy); }
.stat-icon.green  { background: #e8f5e9; color: #2e7d32; }
.stat-icon.blue   { background: #e3f2fd; color: #1565c0; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* ── BUTTONS ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
  font-family: inherit;
}

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

.btn-orange {
  background: var(--orange);
  color: #fff;
  border-color: var(--orange);
}
.btn-orange:hover { background: var(--orange-light); border-color: var(--orange-light); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}
.btn-outline:hover { background: var(--navy); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger { background: #c62828; color: #fff; border-color: #c62828; }
.btn-danger:hover { background: #b71c1c; }

.btn-success { background: #2e7d32; color: #fff; border-color: #2e7d32; }
.btn-success:hover { background: #1b5e20; }

.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── TABLES ────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

.data-table td {
  padding: 12px 16px;
  vertical-align: middle;
}

/* ── FORMS ─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

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

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,35,126,.1);
}

.form-control::placeholder { color: #a0aec0; }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  gap: 16px;
}
.form-row-2 { grid-template-columns: repeat(2, 1fr); }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }
.form-row-4 { grid-template-columns: repeat(4, 1fr); }

/* ── ALERTS ────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}
.alert-success { background: #e8f5e9; color: #1b5e20; border-color: #a5d6a7; }
.alert-danger   { background: #ffebee; color: #b71c1c; border-color: #ef9a9a; }
.alert-warning  { background: #fffde7; color: #f57f17; border-color: #fff176; }
.alert-info     { background: #e3f2fd; color: #0d47a1; border-color: #90caf9; }

/* ── BADGES ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-orange   { background: #fff3e0; color: var(--orange); }
.badge-navy     { background: #e8eaf6; color: var(--navy); }
.badge-green    { background: #e8f5e9; color: #2e7d32; }
.badge-red      { background: #ffebee; color: #c62828; }
.badge-gray     { background: #f1f5f9; color: var(--muted); }
.badge-blue     { background: #e3f2fd; color: #1565c0; }

/* ── SEARCH BAR ────────────────────────────────────── */
.search-wrapper {
  position: relative;
}
.search-wrapper .search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px; pointer-events: none;
}
.search-wrapper .form-control { padding-left: 34px; }

/* ── AUTOCOMPLETE ──────────────────────────────────── */
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 280px;
  overflow-y: auto;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg); }
.autocomplete-item .item-name { font-weight: 600; font-size: 13px; }
.autocomplete-item .item-meta { font-size: 12px; color: var(--muted); }

/* ── QUOTE ITEMS TABLE ─────────────────────────────── */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
}
.items-table td { padding: 8px 6px; vertical-align: middle; }
.items-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }

.item-search-wrapper { position: relative; min-width: 220px; }

/* ── TOTALS BOX ────────────────────────────────────── */
.totals-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}
.totals-row.total {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  border-top: 2px solid var(--border);
  margin-top: 8px;
  padding-top: 12px;
}

/* ── POS LAYOUT ────────────────────────────────────── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - var(--topbar-h) - 56px);
}

.pos-products {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pos-products-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}

.pos-products-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  align-content: start;
}

.pos-product-btn {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.pos-product-btn:hover {
  border-color: var(--navy);
  background: #f0f2f8;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.pos-product-btn .prod-name { font-weight: 600; font-size: 12.5px; color: var(--text); }
.pos-product-btn .prod-price { font-size: 14px; font-weight: 700; color: var(--orange); }
.pos-product-btn .prod-sku { font-size: 11px; color: var(--muted); }

.pos-cart {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.pos-cart-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  display: flex; justify-content: space-between; align-items: center;
}

.pos-cart-items { flex: 1; overflow-y: auto; }

.cart-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.cart-item-info { flex: 1; }
.cart-item-name { font-weight: 600; font-size: 13px; }
.cart-item-price { font-size: 12px; color: var(--muted); }
.cart-item-qty {
  display: flex; align-items: center; gap: 6px;
}
.qty-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  transition: all .1s;
}
.qty-btn:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.qty-display { width: 28px; text-align: center; font-weight: 600; }

.pos-cart-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.pos-total {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  margin-bottom: 12px;
}

/* ── LOGIN PAGE ────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, #3949ab 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--white);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px; justify-content: center;
}

.login-logo-icon {
  width: 48px; height: 48px;
  background: var(--orange);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff;
}

.login-logo-text h1 { font-size: 20px; font-weight: 700; color: var(--navy); }
.login-logo-text p  { font-size: 12px; color: var(--muted); }

/* ── MODAL ─────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1050;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 700;
}
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

.btn-close-modal {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 20px; padding: 2px;
}
.btn-close-modal:hover { color: var(--text); }

/* ── PRINT STYLES – TICKET TÉRMICO ────────────────── */
@media print {
  .no-print { display: none !important; }
  body { background: white; }
}

/* ── RESPONSIVE ────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .btn-sidebar-toggle {
    display: flex;
  }
  .pos-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .form-row-3, .form-row-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
  .stat-card { flex-direction: column; gap: 10px; }
}

/* ── UTILITIES ─────────────────────────────────────── */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-navy { color: var(--navy); }
.text-orange { color: var(--orange); }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: 12.5px; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; }
