/* NextLock — custom styles layered on top of Tailwind via CDN */

:root {
  --nl-primary: #6366F1;
  --nl-primary-700: #4338CA;
  --nl-accent: #10B981;
  --nl-bg: #F8FAFC;
  --nl-card: #FFFFFF;
  --nl-text: #0F172A;
  --nl-muted: #64748B;
  --nl-border: #E2E8F0;
  --nl-danger: #F43F5E;
  --nl-warn: #F59E0B;
  --nl-sidebar: #0B1220;
  --nl-sidebar-active: rgba(99, 102, 241, 0.18);
  --nl-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 16px rgba(15, 23, 42, 0.06);
}

html, body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--nl-bg);
  color: var(--nl-text);
  -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.nl-sidebar {
  background: var(--nl-sidebar);
  background-image: linear-gradient(180deg, #0B1220 0%, #0a1428 100%);
}
.nl-sidebar a {
  color: rgba(255, 255, 255, 0.78);
  border-radius: 14px;
  padding: 0.7rem 1rem;
  display: flex; gap: 0.85rem; align-items: center;
  font-weight: 500;
  transition: background 120ms, color 120ms, transform 120ms;
}
.nl-sidebar a:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.nl-sidebar a.active {
  background: var(--nl-sidebar-active);
  color: white;
  box-shadow: inset 3px 0 0 var(--nl-primary);
}
.nl-sidebar svg { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; }

/* Cards */
.nl-card {
  background: var(--nl-card);
  border: 1px solid var(--nl-border);
  border-radius: 18px;
  box-shadow: var(--nl-shadow);
}

/* Tabs */
.nl-tab { color: var(--nl-muted); padding: 1rem 1.25rem; font-weight: 600; border-bottom: 2px solid transparent; }
.nl-tab.active { color: var(--nl-text); border-bottom-color: var(--nl-primary); }
.nl-tab:hover { color: var(--nl-text); }

/* Buttons */
.nl-btn { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.65rem 1rem; border-radius: 12px; font-weight: 600; transition: transform 80ms, background 120ms, box-shadow 120ms; }
.nl-btn-primary { background: var(--nl-text); color: white; }
.nl-btn-primary:hover { background: #1E293B; }
.nl-btn-accent { background: linear-gradient(135deg, var(--nl-primary), var(--nl-accent)); color: white; }
.nl-btn-accent:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 8px 18px rgba(99,102,241,0.25); }
.nl-btn-ghost { background: white; color: var(--nl-text); border: 1px solid var(--nl-border); }
.nl-btn-ghost:hover { background: var(--nl-bg); }
.nl-btn-danger { background: var(--nl-danger); color: white; }
.nl-btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Inputs */
.nl-input, .nl-select {
  width: 100%; padding: 0.65rem 0.85rem; border: 1px solid var(--nl-border);
  border-radius: 12px; background: white; color: var(--nl-text); font-size: 0.95rem;
  transition: border-color 120ms, box-shadow 120ms;
}
.nl-input:focus, .nl-select:focus {
  outline: none; border-color: var(--nl-primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}
.nl-input[disabled] { background: #F1F5F9; color: #94A3B8; }
.nl-label { font-size: 0.85rem; color: var(--nl-muted); font-weight: 500; margin-bottom: 0.35rem; display: block; }

/* Tables */
.nl-table { width: 100%; border-collapse: collapse; }
.nl-table th { font-size: 0.78rem; font-weight: 700; color: var(--nl-primary); text-transform: none; padding: 0.85rem 0.75rem; text-align: left; border-bottom: 1px solid var(--nl-border); white-space: nowrap; }
.nl-table th .nl-funnel { opacity: 0.55; cursor: pointer; }
.nl-table th .nl-funnel:hover { opacity: 1; }
.nl-table td { padding: 0.95rem 0.75rem; border-bottom: 1px solid #F1F5F9; font-size: 0.93rem; }
.nl-table tr.row-link { cursor: pointer; }
.nl-table tr.row-link:hover { background: #F8FAFC; }

/* Status pill */
.nl-status { display: inline-flex; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.nl-status.s-Available { background: #ECFDF5; color: #047857; }
.nl-status.s-AssignedVacant { background: #EFF6FF; color: #1D4ED8; }
.nl-status.s-TenantUsingLock { background: #FEFCE8; color: #A16207; }
.nl-status.s-AssignedOverlock { background: #FFFBEB; color: #B45309; }
.nl-status.s-Lost, .nl-status.s-Damaged, .nl-status.s-Sold { background: #FEF2F2; color: #B91C1C; }
.nl-status.s-default { background: #F1F5F9; color: #475569; }

/* Color dot */
.nl-color-dot { display: inline-block; width: 1rem; height: 1rem; border-radius: 999px; vertical-align: middle; margin-right: 0.5rem; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.10), 0 1px 2px rgba(0,0,0,0.08); }
.nl-color-dot.c-Yellow { background: #FACC15; }
.nl-color-dot.c-Red { background: #EF4444; }
.nl-color-dot.c-Gray { background: #94A3B8; }
.nl-color-dot.c-Silver { background: #CBD5E1; }
.nl-color-dot.c-Blue { background: #3B82F6; }
.nl-color-dot.c-Green { background: #22C55E; }
.nl-color-dot.c-Black { background: #0F172A; }
.nl-color-dot.c-Orange { background: #F97316; }

/* Toast */
.nl-toast {
  position: fixed; top: 1.25rem; left: 50%; transform: translateX(-50%);
  padding: 0.7rem 1.1rem; border-radius: 12px; box-shadow: 0 8px 25px rgba(0,0,0,0.15);
  font-weight: 600; color: white; z-index: 60;
}
.nl-toast.success { background: var(--nl-accent); }
.nl-toast.error { background: var(--nl-danger); }
.nl-toast.info { background: var(--nl-primary); }

/* Pagination */
.nl-pagination { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.nl-pagination button { width: 2.1rem; height: 2.1rem; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid transparent; color: var(--nl-muted); }
.nl-pagination button.active { background: var(--nl-primary); color: white; }
.nl-pagination button:not([disabled]):hover { background: #F1F5F9; }

/* Stepper */
.nl-stepper { position: relative; height: 30px; }
.nl-stepper .step-line { position: absolute; left: 0; right: 0; top: 14px; height: 2px; background: var(--nl-border); }
.nl-stepper .step-fill { position: absolute; left: 0; top: 14px; height: 2px; background: var(--nl-primary); transition: width 200ms; }
.nl-stepper .step { position: relative; width: 14px; height: 14px; border-radius: 999px; background: var(--nl-border); }
.nl-stepper .step.active { background: var(--nl-primary); }

/* Toggle */
.nl-toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.nl-toggle input { opacity: 0; width: 0; height: 0; }
.nl-toggle .slider { position: absolute; cursor: pointer; inset: 0; background: #CBD5E1; border-radius: 999px; transition: 200ms; }
.nl-toggle .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: white; border-radius: 999px; transition: 200ms; box-shadow: 0 1px 3px rgba(0,0,0,0.18); }
.nl-toggle input:checked + .slider { background: var(--nl-primary); }
.nl-toggle input:checked + .slider::before { transform: translateX(20px); }

/* Stat tile */
.nl-stat-tile { display: flex; align-items: center; gap: 0.85rem; padding: 1rem 1.25rem; border-radius: 14px; background: linear-gradient(135deg, #F1F5F9, #E2E8F0); }
.nl-stat-tile .icon { background: white; border-radius: 12px; padding: 0.5rem; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

/* Help pill */
.nl-help-pill { position: fixed; bottom: 1.25rem; left: 1.25rem; background: white; border: 1px solid var(--nl-border); border-radius: 999px; padding: 0.55rem 1.1rem; box-shadow: var(--nl-shadow); display: inline-flex; align-items: center; gap: 0.5rem; cursor: pointer; z-index: 50; }

/* Touch-friendly: meet Apple HIG 44px minimum on touch devices */
@media (hover: none) and (pointer: coarse) {
  .nl-btn { min-height: 44px; padding-top: 0.7rem; padding-bottom: 0.7rem; }
  .nl-input, .nl-select { min-height: 44px; font-size: 16px; /* prevents iOS zoom on focus */ }
  .nl-tab { padding: 1rem 1.1rem; }
  .nl-toggle { width: 50px; height: 28px; }
  .nl-toggle .slider::before { height: 22px; width: 22px; }
  .nl-toggle input:checked + .slider::before { transform: translateX(22px); }
  .nl-table td, .nl-table th { padding: 1rem 0.75rem; }
  .row-link { -webkit-tap-highlight-color: rgba(99, 102, 241, 0.1); }
}

/* Top bar — dark indigo, fixed on every viewport */
.nl-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  background: #1E1B4B; /* indigo-950 */
  background-image: linear-gradient(180deg, #312E81 0%, #1E1B4B 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #E0E7FF;
  box-shadow: 0 4px 18px rgba(30, 27, 75, 0.18);
  backdrop-filter: blur(8px);
}
.nl-topbar .text-slate-900 { color: white !important; }
.nl-topbar .text-slate-600 { color: rgba(199, 210, 254, 0.85) !important; }
.nl-topbar .text-indigo-600 { color: #A5B4FC !important; }
/* User-menu dropdown sits inside the topbar but renders on a white card.
   Reset the inherited light-indigo color so menu items read as dark slate. */
.nl-topbar .nl-card { color: #1E293B; }
.nl-topbar .nl-card .text-slate-900 { color: #0F172A !important; }
.nl-topbar .nl-card .text-slate-600 { color: #475569 !important; }
.nl-topbar .nl-card .text-slate-500 { color: #64748B !important; }

/* Main: always pad past the fixed 4rem topbar */
.nl-main { padding-top: 5rem !important; }

/* Sidebar — always fixed (it already starts at top-16/4rem to clear the topbar) */
.nl-sidebar { position: fixed; top: 4rem; bottom: 0; left: 0; width: 16rem; overflow-y: auto; z-index: 25; }

/* Tablet + Mobile: sidebar slides out as drawer */
@media (max-width: 1023px) {
  .nl-sidebar { top: 0; transform: translateX(-100%); transition: transform 200ms; z-index: 40; width: 280px; box-shadow: 4px 0 24px rgba(0,0,0,0.15); }
  .nl-sidebar.open { transform: translateX(0); }
  .nl-main { margin-left: 0 !important; }
  .nl-mobile-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 35; }
}

/* Phone: tighten paddings, stack things, optimize Locks list */
@media (max-width: 767px) {
  .nl-main { padding: 1rem 0.75rem 5rem !important; }
  .nl-card { border-radius: 14px; padding: 1rem !important; }
  /* Tables that ARE shown on mobile (rare) become scrollable */
  .nl-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .nl-table thead, .nl-table tbody, .nl-table tr { display: table; width: 100%; table-layout: auto; }
  /* Help pill hidden on phone — feature is desktop-only */
  .nl-help-pill { display: none !important; }
  /* Stepper smaller */
  .nl-stepper { font-size: 0.85rem; }
  /* Topbar tightening: hide the company-id block on phones (facility name stays) */
  .nl-topbar .company-block { display: none !important; }
  /* Auth card */
  .nl-card.max-w-md { padding: 1.5rem !important; }
  /* Sub-tabs scroll horizontally so all 4 are reachable */
  .nl-tab { padding: 0.85rem 0.85rem; font-size: 0.9rem; flex: 0 0 auto; }
}

/* Tablet (640-1023): show condensed table headers + 2-col grids stay */
@media (min-width: 640px) and (max-width: 1023px) {
  .nl-main { padding: 1.5rem 1.25rem !important; }
  .nl-card { padding: 1.25rem !important; }
  .nl-table { font-size: 0.9rem; }
  .nl-table td, .nl-table th { padding: 0.7rem 0.55rem; }
}

/* Print: hide chrome, show only content */
@media print {
  .nl-sidebar, .nl-topbar, .nl-help-pill, .no-print { display: none !important; }
  .nl-card { border: none; box-shadow: none; }
  body { background: white; }
}

/* Animations */
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.nl-fadein { animation: fadein 200ms ease-out; }

/* Sticky search bar on mobile Locks pages */
.nl-sticky-search {
  position: sticky;
  top: 4rem; /* below the 64px fixed topbar */
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 20;
  margin: 0 -0.75rem;
  padding: 0.75rem 0.75rem;
  border-bottom: 1px solid var(--nl-border);
  box-shadow: 0 4px 12px -8px rgba(15, 23, 42, 0.08);
}
.nl-sticky-search .nl-input {
  border: 1.5px solid var(--nl-border);
  background: white;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
@media (min-width: 1024px) {
  .nl-sticky-search { position: static; background: transparent; margin: 0; padding: 0; border-bottom: 0; box-shadow: none; backdrop-filter: none; }
}

/* Mobile bottom tab bar (Locks sub-nav) — dark indigo bar */
.nl-bottom-tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #1E1B4B; /* indigo-950 */
  background-image: linear-gradient(180deg, #312E81 0%, #1E1B4B 100%);
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  z-index: 45;
  padding: 0.4rem 0 max(0.4rem, env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(30, 27, 75, 0.35);
}
.nl-bottom-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem;
  padding: 0.4rem 0.25rem;
  font-size: 0.7rem; font-weight: 600;
  color: rgba(199, 210, 254, 0.65); /* indigo-200 dimmed */
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: color 120ms;
}
.nl-bottom-tab:hover { color: rgba(199, 210, 254, 0.95); }
.nl-bottom-tab.active { color: #A5B4FC; /* indigo-300 */ }
.nl-bottom-tab.active svg { stroke-width: 2.5; filter: drop-shadow(0 0 6px rgba(165, 180, 252, 0.5)); }
.nl-bottom-tab:active { transform: scale(0.96); }

/* Make room for the bottom tab bar so the help pill + content don't sit underneath */
@media (max-width: 1023px) {
  body:has(.nl-bottom-tabs) .nl-main { padding-bottom: 5.5rem !important; }
  body:has(.nl-bottom-tabs) .nl-help-pill { bottom: 4.5rem; }
}
