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

/* ========= THEME TOKENS ========= */
:root{
  /* Dark Navy Palette */
  --bg:        #0b1221;
  --surface:   #111827;
  --surface-2: #1a2234;
  --surface-3: #1e293b;
  --border:    #1e2d42;
  --border-2:  #2d3f57;

  /* Text */
  --text-1: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #475569;

  /* Action blue */
  --blue:      #549c73;
  --blue-hover:#74c095;
  --blue-dim:  rgba(29, 245, 169, 0.14);

  /* Kubi brand */
  --kubi-blue:  #2d5698;
  --kubi-green: #74c095;

  /* Status */
  --green:      #22c55e;
  --green-dim:  rgba(34,197,94,.13);
  --red:        #ef4444;
  --red-dim:    rgba(239,68,68,.13);
  --orange:     #f97316;
  --orange-dim: rgba(249,115,22,.13);
  --yellow:     #eab308;
  --teal:       #14b8a6;

  /* Legacy aliases */
  --primary-color:   var(--kubi-blue);
  --secondary-color: #488c6e;
  --accent-color:    var(--kubi-green);
  --ink-color:       var(--bg);
  --danger-color:    var(--red);
  --success-color:   var(--green);
  --primary-600: #5aa784;
  --primary-700: #488c6e;
  --accent-600:  #5aa784;
  --accent-700:  #488c6e;
  --gray-50:  var(--surface-3);
  --gray-100: var(--surface-2);
  --gray-200: var(--border);
  --gray-300: var(--border-2);
  --gray-600: var(--text-2);

  /* Shapes */
  --radius:      8px;
  --radius-lg:   12px;
  --radius-pill: 9999px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.35);
  --shadow-md: 0 4px 16px rgba(0,0,0,.45);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.55);
  --ring:      0 0 0 3px rgba(29,106,245,.28);
}

/* ========= RESET & BASE ========= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 100vh;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container { max-width: 1300px; width: 100%; margin: 0 auto; padding: 0 20px; }

@media (max-width: 768px) { .container { padding: 0 14px; } }

/* ========= HEADER / NAV ========= */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--topbar-h);
  padding: 0;
  gap: 1rem;
}

.navbar_logo-content {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.navbar_logo-content > span {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -.4px;
}

.logo { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
.logo img { height: 36px; width: auto; }
.logo span { color: var(--text-1); font-weight: 800; font-size: 1rem; letter-spacing: -.3px; }

/* ========= LINKS EN NAV ========= */
.nav-links { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.nav-links a { text-decoration: none; }

/* ========= BUTTONS ========= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
  white-space: nowrap;
  min-height: 38px;
  line-height: 1;
  -webkit-user-select: none;
  user-select: none;
}
.btn:hover  { opacity: .88; transform: translateY(-1px); }
.btn:active { transform: translateY(0); opacity: 1; }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-confirm {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 10px rgba(29, 245, 155, 0.3);
}
.btn-confirm:hover { background: var(--blue-hover); border-color: var(--blue-hover); }

.btn-success {
  background: var(--kubi-green);
  color: #fff;
  border-color: var(--kubi-green);
}
.btn-success:hover { background: var(--accent-600); border-color: var(--accent-600); }

.btn-danger {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn-danger:hover { background: var(--red-dim); color: var(--red); border-color: var(--red); }

.btn-outline {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border-2);
}
.btn-outline:hover { background: var(--surface-2); color: var(--text-1); }

.btn-login-nav {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 10px rgba(29, 245, 155, 0.3);
  gap: .45rem;
}
.btn-login-nav:hover {
  background: var(--blue-hover);
  border-color: var(--blue-hover);
  box-shadow: 0 4px 18px rgba(29, 245, 155, 0.45);
}

#resend-pin-btn { padding: .55rem 1.1rem; }

@media (max-width: 768px) {
  .btn { font-size: .82rem; padding: .5rem .85rem; }
  .nav-links .btn { font-size: .8rem; }
}

/* ========= SIDEBAR ========= */
.sidebar-toggle-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  margin-right: 1rem;
}

.sidebar-toggle-btn span {
  display: block;
  width: 24px;
  height: 2.5px;
  background: var(--text-1);
  border-radius: 2px;
  transition: all .3s ease;
}

.sidebar-toggle-btn.active span:nth-child(1) {
  transform: rotate(45deg) translate(8px, 8px);
}

.sidebar-toggle-btn.active span:nth-child(2) {
  opacity: 0;
}

.sidebar-toggle-btn.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

:root {
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 56px;
}

.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1001;
  overflow: hidden auto;
  transition: width .25s ease, transform .25s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  flex-shrink: 0;
  padding: 0 .9rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
  white-space: nowrap;
}

.sidebar-collapse-btn,
.sidebar-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.sidebar-collapse-btn:hover,
.sidebar-close-btn:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.sidebar-collapse-btn svg {
  width: 20px;
  height: 20px;
  transition: transform .25s ease;
}

.sidebar-close-btn { display: none; }

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
  padding: .75rem;
}

.sidebar-menu li.sidebar-item-logout {
  margin-top: auto;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .85rem;
  height: 42px;
  padding: 0 .8rem;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, color .15s;
}

.sidebar-link .icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sidebar-link .icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-link .label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

.sidebar-link.active {
  background: var(--blue-dim);
  color: var(--kubi-green);
}

.sidebar-link.sidebar-logout:hover {
  background: var(--red-dim);
  color: var(--red);
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}

.sidebar-overlay.open {
  opacity: 1;
  pointer-events: all;
}

/* Mobile: off-canvas sidebar */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle-btn { display: flex; }
  .sidebar-close-btn { display: flex; }
  .sidebar-collapse-btn { display: none; }
}

/* Desktop: fixed sidebar that collapses to icons */
@media (min-width: 769px) {
  .sidebar-overlay { display: none; }

  body.has-sidebar {
    padding-left: var(--sidebar-w);
    transition: padding-left .25s ease;
  }

  body.has-sidebar.sidebar-collapsed { padding-left: var(--sidebar-w-collapsed); }

  .sidebar.collapsed { width: var(--sidebar-w-collapsed); }
  .sidebar.collapsed .sidebar-header { justify-content: center; padding: 0; }
  .sidebar.collapsed .sidebar-title,
  .sidebar.collapsed .sidebar-link .label { display: none; }
  .sidebar.collapsed .sidebar-link { justify-content: center; padding: 0; }
  .sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
}


/* ========= MAIN & FOOTER ========= */
main {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  flex-grow: 1;
}

footer {
  padding: 1.2rem 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-3);
  text-align: center;
  margin-top: auto;
  font-size: .82rem;
}

.footer > div > p { font-size: .82rem; }

main.hero-gradient {
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(29,106,245,.12) 0%, transparent 70%);
}

/* ========= CARDS ========= */
.card {
  background: var(--surface);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 1.25rem;
}

/* ========= FORMS ========= */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .35rem;
}

.form-control,
.filter-input,
.filter-select,
input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea,
#storeSelect,
#lpn-advanced-filter {
  width: 100%;
  padding: .6rem .9rem;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text-1);
  font-family: inherit;
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

input::placeholder,
textarea::placeholder { color: var(--text-3); }

.form-control:focus,
.filter-input:focus,
.filter-select:focus,
input:focus,
select:focus,
textarea:focus,
#storeSelect:focus,
#lpn-advanced-filter:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: var(--ring);
}

select option { background: var(--surface-2); color: var(--text-1); }

/* ========= UTILS ========= */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 18, 33, .55);
  backdrop-filter: blur(2px);
}
.loading-overlay img { width: 96px; height: 96px; }

.text-center { text-align: center; }
.text-muted  { color: var(--text-2); }
.mb-1 { margin-bottom: .4rem; }  .mb-2 { margin-bottom: .8rem; }
.mb-3 { margin-bottom: 1.2rem; } .mb-4 { margin-bottom: 1.8rem; }
.mt-1 { margin-top: .4rem; }     .mt-2 { margin-top: .8rem; }
.mt-3 { margin-top: 1.2rem; }   .mt-4 { margin-top: 1.8rem; }

/* ========= TOASTS / POPUPS ========= */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 13px 18px;
  background: var(--surface-2);
  color: var(--text-1);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transform: translateY(150%);
  transition: transform .3s ease;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  font-size: .875rem;
}
.toast.show    { transform: translateY(0); }
.toast-success { border-left-color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-info    { border-left-color: var(--blue); }

/* Mensaje lateral */
.message-popup {
  position: fixed;
  bottom: 20px;
  right: -400px;
  max-width: 340px;
  width: 90%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 1000;
  transition: right .5s ease-in-out;
}
.message-popup.show { right: 20px; }
.message-popup .header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.message-popup .close {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-3);
  padding: 0 4px;
  transition: color .15s;
}
.message-popup .close:hover { color: var(--text-1); }

/* ========= TABLES ========= */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.order-history-table,
.operators-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.order-history-table th,
.operators-table th {
  background: var(--surface-3);
  color: var(--text-2);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.order-history-table th, .order-history-table td,
.operators-table th, .operators-table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
}

.order-history-table td, .operators-table td { color: var(--text-1); }

.order-history-table tbody tr:last-child td,
.operators-table tbody tr:last-child td { border-bottom: none; }

.order-history-table tbody tr:hover,
.operators-table tbody tr:hover { background: var(--surface-2); }

/* Sort arrows */
th.sort-asc::after  { content: ' ↑'; color: var(--blue); }
th.sort-desc::after { content: ' ↓'; color: var(--blue); }

/* ========= CHIPS / STATUS ========= */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.status-active    { background: var(--green-dim);  color: var(--green); }
.status-waiting   { background: var(--blue-dim);   color: var(--blue);  }
.connection-error { background: var(--red-dim);    color: var(--red);   }

/* ========= LOCKER SIZES PROGRESS ========= */
.progress-bar-bg {
  background: var(--surface-3);
  width: 90%;
  height: 6px;
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--blue), var(--kubi-green));
}

/* ========= DOWNLOAD BUTTON ========= */
.download-button {
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text-2);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  padding: .5rem 1rem;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.download-button:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--blue);
}

/* ========= RESPONSIVE NAV ========= */
@media (max-width: 768px) {
  .navbar { flex-direction: column; align-items: flex-start; gap: .6rem; }
  .nav-links { align-self: flex-start; gap: .5rem; }
}
@media (max-width: 1050px) {
  .header-ubicaciones { flex-direction: column; align-items: start !important; }
}

/* ========= ANIMATIONS ========= */
@keyframes rowHighlight {
  from { background: rgba(29,106,245,.15); }
  to   { background: transparent; }
}
.row-updated { animation: rowHighlight 2s ease-out; }

@keyframes cellHighlight {
  0%   { background: rgba(29,106,245,.25); }
  50%  { background: rgba(29,106,245,.1); }
  100% { background: transparent; }
}
.cell-updated { animation: cellHighlight 2.5s ease-out; position: relative; overflow: visible; }
.cell-updated::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 2px solid var(--blue);
  border-radius: 2px;
  opacity: 1;
  animation: fadeOut 2.5s ease-out forwards;
  pointer-events: none;
}
@keyframes fadeOut { to { opacity: 0; } }

/* ========= SCROLLBAR ========= */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
* { scrollbar-color: var(--border-2) var(--surface); scrollbar-width: thin; }