/* ==========================================================================
   Ubay.shop — Core Design Tokens (Premium Blue, White, Light Gray, Dark Navy)
   ========================================================================== */

:root {
  /* Brand Palette: Premium Blue + White + Light Gray + Dark Navy */
  --ub-primary: #1D4ED8;          /* Premium Royal Blue */
  --ub-primary-hover: #1E40AF;
  --ub-primary-light: #3B82F6;
  --ub-primary-soft: #EFF6FF;
  --ub-primary-tint: #DBEAFE;

  --ub-navy: #0F172A;             /* Dark Navy Text */
  --ub-navy-2: #1E293B;
  --ub-slate: #475569;
  --ub-muted: #64748B;

  --ub-white: #FFFFFF;
  --ub-gray-50: #F8FAFC;          /* Light Gray Surface */
  --ub-gray-100: #F1F5F9;
  --ub-gray-200: #E2E8F0;
  --ub-gray-300: #CBD5E1;

  --ub-accent: #0EA5E9;           /* Crisp Sky Blue Accent */
  --ub-gold: #D97706;             /* Star / Offer Accent */

  /* Admin Shell */
  --adm-bg: #F1F5F9;
  --adm-sidebar: #0F172A;         /* Deep Navy Sidebar */
  --adm-sidebar-hover: #1E293B;
  --adm-sidebar-active: #2563EB;
  --adm-card: #FFFFFF;
  --adm-border: #E2E8F0;

  /* Status Colors */
  --st-pending-bg: #FEF3C7;
  --st-pending-fg: #B45309;
  --st-shifted-bg: #E0E7FF;
  --st-shifted-fg: #4338CA;
  --st-confirmed-bg: #DBEAFE;
  --st-confirmed-fg: #1D4ED8;
  --st-delivery-bg: #DCFCE7;
  --st-delivery-fg: #15803D;
  --st-cancelled-bg: #FEE2E2;
  --st-cancelled-fg: #B91C1C;

  /* Risk Colors */
  --risk-low-bg: #DCFCE7;
  --risk-low-fg: #15803D;
  --risk-medium-bg: #FEF3C7;
  --risk-medium-fg: #B45309;
  --risk-high-bg: #FEE2E2;
  --risk-high-fg: #B91C1C;

  /* Typography */
  --font-display: 'Hind Siliguri', 'Playfair Display', Georgia, serif;
  --font-sans: 'Hind Siliguri', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-bn: 'Hind Siliguri', 'Plus Jakarta Sans', sans-serif;

  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 26px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 48px rgba(15, 23, 42, 0.14);
  --shadow-blue: 0 8px 24px rgba(29, 78, 216, 0.28);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ub-navy);
  background: var(--ub-gray-50);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.ub-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* Shared Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--ub-primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.24);
}
.btn-primary:hover:not(:disabled) {
  background: var(--ub-primary-hover);
  transform: translateY(-1px);
}

.btn-navy {
  background: var(--ub-navy);
  color: #fff;
}
.btn-navy:hover:not(:disabled) { background: var(--ub-navy-2); }

.btn-outline {
  background: #fff;
  color: var(--ub-navy);
  border-color: var(--ub-gray-300);
}
.btn-outline:hover:not(:disabled) {
  background: var(--ub-gray-50);
  border-color: var(--ub-primary);
  color: var(--ub-primary);
}

.btn-soft {
  background: var(--ub-primary-soft);
  color: var(--ub-primary);
}
.btn-soft:hover:not(:disabled) { background: var(--ub-primary-tint); }

.btn-ghost {
  background: transparent;
  color: var(--ub-slate);
}
.btn-ghost:hover:not(:disabled) { background: var(--ub-gray-100); color: var(--ub-navy); }

.btn-success { background: #16A34A; color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803D; }

.btn-danger { background: #DC2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }

.btn-warning { background: #D97706; color: #fff; }
.btn-warning:hover:not(:disabled) { background: #B45309; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 0.74rem; border-radius: 6px; }
.btn-icon { padding: 7px; border-radius: 8px; }

/* Status & Risk Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-Pending { background: var(--st-pending-bg); color: var(--st-pending-fg); }
.status-Shifted { background: var(--st-shifted-bg); color: var(--st-shifted-fg); }
.status-Confirmed { background: var(--st-confirmed-bg); color: var(--st-confirmed-fg); }
.status-Delivery { background: var(--st-delivery-bg); color: var(--st-delivery-fg); }
.status-Cancelled { background: var(--st-cancelled-bg); color: var(--st-cancelled-fg); }

.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.risk-Low { background: var(--risk-low-bg); color: var(--risk-low-fg); }
.risk-Medium { background: var(--risk-medium-bg); color: var(--risk-medium-fg); }
.risk-High { background: var(--risk-high-bg); color: var(--risk-high-fg); }

.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  background: var(--ub-gray-100);
  color: var(--ub-navy-2);
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-blue { background: var(--ub-primary-tint); color: var(--ub-primary); }
.badge-green { background: #DCFCE7; color: #15803D; }
.badge-red { background: #FEE2E2; color: #B91C1C; }
.badge-amber { background: #FEF3C7; color: #B45309; }

/* Floating Admin Quick Bar on Storefront */
.ub-mode-bar {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  color: #fff;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.ub-mode-bar .mode-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #60A5FA;
  padding: 0 6px 0 8px;
}
.ub-mode-bar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  border: none;
  font-size: 0.78rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  transition: all 0.16s ease;
}
.ub-mode-bar button:hover { background: rgba(255, 255, 255, 0.22); }
.ub-mode-bar button.primary-pill { background: var(--ub-primary); }
.ub-mode-bar button.primary-pill:hover { background: #2563EB; }

/* Modal System */
.ub-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}
.ub-modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  animation: slideUp 0.2s ease;
}
.ub-modal.modal-lg { max-width: 960px; }
.ub-modal.modal-xl { max-width: 1140px; }
.ub-modal.modal-sm { max-width: 460px; }

.ub-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--ub-gray-200);
  background: #fff;
}
.ub-modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ub-navy);
  display: flex;
  align-items: center;
  gap: 9px;
}
.ub-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.ub-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--ub-gray-200);
  background: var(--ub-gray-50);
}

/* Toast Notifications */
.ub-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.ub-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--ub-navy);
  color: #fff;
  font-size: 0.86rem;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.26);
  animation: slideInRight 0.22s ease;
  border-left: 4px solid #3B82F6;
}
.ub-toast.toast-success { border-left-color: #22C55E; }
.ub-toast.toast-error { border-left-color: #EF4444; }
.ub-toast.toast-warning { border-left-color: #F59E0B; }

/* Form Inputs */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ub-navy-2);
}
.form-label .req { color: #DC2626; margin-left: 2px; }
.form-control {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--ub-gray-300);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--ub-navy);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
  outline: none;
  border-color: var(--ub-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}
.form-control.is-invalid { border-color: #DC2626; }
.form-error { font-size: 0.76rem; color: #DC2626; font-weight: 500; }
.form-hint { font-size: 0.75rem; color: var(--ub-muted); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

/* Toggle Switch */
.ub-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.ub-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.ub-switch-track {
  width: 40px;
  height: 22px;
  background: #CBD5E1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.ub-switch-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s;
}
.ub-switch input:checked + .ub-switch-track { background: var(--ub-primary); }
.ub-switch input:checked + .ub-switch-track::after { transform: translateX(18px); }

/* Loading Spinner */
.ub-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: translateX(0); } }

/* Invoice Print Sheet */
.invoice-sheet {
  background: #fff;
  color: var(--ub-navy);
  padding: 32px;
  border: 1px solid var(--ub-gray-200);
  border-radius: 12px;
  font-size: 0.88rem;
}
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--ub-navy);
  padding-bottom: 18px;
  margin-bottom: 22px;
}
.invoice-brand h2 {
  margin: 0 0 4px;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--ub-primary);
  letter-spacing: -0.02em;
}
.invoice-meta { text-align: right; }
.invoice-meta .inv-num { font-size: 1.1rem; font-weight: 800; color: var(--ub-navy); }
.invoice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
.invoice-box {
  background: var(--ub-gray-50);
  border: 1px solid var(--ub-gray-200);
  border-radius: 10px;
  padding: 14px 16px;
}
.invoice-box h4 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ub-muted);
}
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.invoice-table th {
  background: var(--ub-navy);
  color: #fff;
  text-align: left;
  padding: 10px 12px;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.invoice-table td { padding: 12px; border-bottom: 1px solid var(--ub-gray-200); }
.invoice-totals { margin-left: auto; width: 300px; }
.invoice-totals .row { display: flex; justify-content: space-between; padding: 6px 0; }
.invoice-totals .row.grand {
  border-top: 2px solid var(--ub-navy);
  margin-top: 8px;
  padding-top: 10px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ub-primary);
}
.invoice-footer {
  margin-top: 26px;
  padding-top: 14px;
  border-top: 1px dashed var(--ub-gray-300);
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--ub-muted);
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  body.ub-printing-portal > *:not(#ub-print-portal) {
    display: none !important;
  }
  body.ub-printing-portal #ub-print-portal {
    display: block !important;
    position: static !important;
    width: 100% !important;
    background: #fff !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body:not(.ub-printing-portal) * { visibility: hidden !important; }
  body:not(.ub-printing-portal) #ub-print-area,
  body:not(.ub-printing-portal) #ub-print-area * { visibility: visible !important; }
  body:not(.ub-printing-portal) #ub-print-area {
    position: fixed !important;
    inset: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    background: #fff !important;
  }
}
#ub-print-portal { display: none; }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .ub-mode-bar .mode-label { display: none; }
}
