:root {
  --pri: #4f46e5;
  --pri-dark: #4338ca;
  --text-pri: #ffffff;
  --bg: #f3f4f6;
  --surf: #ffffff;
  --txt: #1f2937;
  --txt-muted: #6b7280;
  --border: #e5e7eb;
  --red: #ef4444;
  --green: #10b981;
  --orange: #ffa500;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  outline: none;
  text-decoration: none;
  scrollbar-width: thin;
  scrollbar-color: var(--pri) transparent;
  accent-color: var(--pri);
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  height: 100vh;
  overflow: hidden;
}

body.dark-mode {
  --bg: #0f172a;
  --surf: #1e293b;
  --txt: #f8fafc;
  --txt-muted: #94a3b8;
  --border: #334155;
}

/* Owner/Super Admin Specific UI Mode */
body.owner-mode .app-nav {
  background: #1e293b; /* Darker distinct theme for owner */
}
body.owner-mode .nav-links a {
  color: #f8fafc;
}
body.owner-mode .owner-ui-hide {
  display: none; /* Hides standard shop branding */
}
 
body.owner-mode .app-nav {
  background: #0f172a;
}

/* Priority Badges */
.badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  color: white;
  text-transform: uppercase;
  font-weight: bold;
}

/* Small Buttons for table actions */
.btn.small {
  padding: 5px 10px;
  font-size: 0.8rem;
}

/* UTILS */
.hidden {
  display: none !important;
}
.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.btn-pri {
  background: var(--pri);
  color: var(--text-pri);
}
.btn-pri:hover {
  background: var(--pri-dark);
}
.btn-sec {
  background: #e5e7eb;
  color: var(--txt);
}
.block {
  width: 100%;
  justify-content: center;
}
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--txt-muted);
  font-size: 1.2rem;
}

/* AUTH */
.full-page {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 15px;
  gap: 15px;
}
.login-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 350px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.brand-logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--pri);
  margin-bottom: 1.5rem;
  text-align: center;
}
.input-group {
  background: var(--bg);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.input-group input {
  border: none;
  background: transparent;
  width: 100%;
  padding: 0.5rem 0;
}

.form-group {
  margin-bottom: 1rem;
}
input,
select,
textarea {
  width: 100%;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-top: 0.3rem;
}

/* Base reset */
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  padding: 0;
  height: 36.19px;
  background: none;
  cursor: pointer;
}

/* Chrome / Edge / Safari */
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

/* LAYOUT */
#layout-app {
  display: flex;
  height: 100vh;
}
.sidebar {
  width: 260px;
  background: white;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.brand {
  padding: 1.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--pri);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nav-link {
  padding: 0.8rem 1.5rem;
  text-decoration: none;
  color: var(--txt-muted);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: 0.2s;
}
.nav-link:hover,
.nav-link.active {
  background: #eef2ff;
  color: var(--pri);
  border-right: 3px solid var(--pri);
}
.user-profile {
  margin-top: auto;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  align-items: center;
}
.avatar {
  width: 40px;
  height: 40px;
  background: #e0e7ff;
  color: var(--pri);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logout-link {
  color: var(--red);
  cursor: pointer;
  font-size: 0.85rem;
}

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

/* DASHBOARD */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-card-list {
  flex-direction: column;
  justify-content: flex-start;
}
.stat-card-list * {
  width: 100%;
  text-align: left;
}

.icon-box {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.icon-box.blue {
  background: #eff6ff;
  color: #3b82f6;
}
.icon-box.red {
  background: #fef2f2;
  color: #ef4444;
}

/* TABLES */
.table-card {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  padding: 1rem;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-weight: 600;
  color: var(--txt-muted);
  font-size: 0.9rem;
}

/* POS SYSTEM */
.pos-wrapper {
  display: flex;
  gap: 1.5rem;
  height: calc(100vh - 4rem);
}
.pos-products {
  flex: 2;
  display: flex;
  flex-direction: column;
}

.old-price {
  text-decoration: line-through;
  color: var(--txt-muted);
  font-size: 0.85rem;
  margin-right: 5px;
}

.current-price {
  color: var(--red); /* Highlight discounted price */
  font-weight: bold;
}

.badge-sale {
  background: var(--red);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  position: absolute;
  top: 10px;
  right: 10px;
}

.search-bar {
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  border: 1px solid var(--border);
}
.search-bar input {
  border: none;
  width: 100%;
  font-size: 1rem;
}
.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  overflow-y: auto;
  padding-right: 5px;
}
.prod-item {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  border: 1px solid transparent;
  transition: 0.2s;
}
.prod-item:hover {
  border-color: var(--pri);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.pos-cart {
  flex: 1;
  background: white;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.cart-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}
.cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}
.cart-row {
  display: flex;
  justify-content: space-between;
  padding: 0.8rem 0;
  border-bottom: 1px solid #f3f4f6;
}
.cart-footer {
  padding: 1.5rem;
  background: #f9fafb;
  border-top: 1px solid var(--border);
}
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

/* Container styling */
details {
  background-color: var(--surf);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  transition: box-shadow 0.2s ease;
}

details:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Header styling */
summary {
  padding: 1rem;
  font-weight: 600;
  color: var(--txt);
  cursor: pointer;
  list-style: none; /* Removes default arrow in most browsers */
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Custom indicator (the arrow) */
summary::after {
  content: "→";
  color: var(--pri);
  transition: transform 0.3s ease;
}

/* Rotate arrow when open */
details[open] summary::after {
  transform: rotate(90deg);
}

/* Remove default marker for Safari */
summary::-webkit-details-marker {
  display: none;
}

/* Content styling */
details p {
  padding: 0 1rem 1rem 1rem;
  margin: 0;
  color: var(--txt-muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* MODALS & TOASTS */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-box {
  background: white;
  width: 90%;
  max-width: 500px;
  padding: 1.5rem;
  border-radius: 12px;
  animation: slideUp 0.3s ease;
}
.modal-box.small {
  max-width: 320px;
  text-align: center;
}
.modal-actions {
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}
.modal-box.small .modal-actions {
  justify-content: center;
}

.modal-header {
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
}
.modal-body,
.modal-content {
}

/* Style busy button */
form[data-busy="true"] button,
form[data-busy="true"] input[type="submit"] {
  opacity: 0.5;
  filter: grayscale(40%);
  cursor: not-allowed;
  pointer-events: none;
  display: inline-flex; /* allow spinner + text inline */
  align-items: center; /* vertically center spinner with text */
  justify-content: center;
}

/* Spinner next to text */
form[data-busy="true"] button::after,
form[data-busy="true"] input[type="submit"]::after {
  content: "";
  display: inline-block; /* inline with text */
  width: 16px;
  height: 16px;
  margin-left: 8px; /* spacing from text */
  border: 2px solid #fff; /* spinner color */
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Spinner animation */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

button:disabled,
input[type="submit"]:disabled {
  opacity: 0.5;
  filter: grayscale(40%);
  cursor: not-allowed;
}

.form-grid {
  display: grid;
  gap: 1rem;
}
.form-grid input,
.form-grid select {
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100%;
}

#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  border-left: 4px solid var(--pri);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease;
  min-width: 250px;
}
.toast.error {
  border-left-color: var(--red);
}
.toast.success {
  border-left-color: var(--green);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* MOBILE NAV STYLES */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  width: 100%;
  background: white;
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  padding: 0.5rem 0;
}

.mobile-nav .nav-link {
  flex-direction: column;
  padding: 0.5rem;
  font-size: 0.7rem;
  border: none;
  gap: 2px;
}

.mobile-nav .nav-link i {
  font-size: 1.2rem;
}

/* CARD DATA SYSTEM */
.data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.data-card {
  background: white;
  padding: 1.2rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}
.card-body-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-top: 0.4rem;
}
.badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
  background: #e0e7ff;
  color: var(--pri);
}

/* RESPONSIVE OVERRIDES */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .mobile-nav {
    display: flex;
  }
  .main-content {
    padding: 1rem 1rem 5rem 1rem;
  } /* Extra bottom padding for nav */
  .view-header h1 {
    font-size: 1.5rem;
  }

  /* Hide Table Headers on Mobile */
  thead {
    display: none;
  }

  .pos-wrapper {
    flex-direction: column;
    height: auto;
  }
  .pos-cart {
    position: fixed;
    bottom: 4rem;
    left: 0;
    width: 100%;
    height: 50vh;
    z-index: 90;
    display: none;
  }
  .pos-cart.active {
    display: flex;
  }
}

/* Floating Action Button */
.fab-cart {
  display: none;
  position: fixed;
  bottom: 5.5rem; /* Above the mobile bottom nav */
  right: 1.5rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--pri);
  color: var(--text-pri);
  border: none;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
  z-index: 95;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.fab-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--red);
  color: white;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 10px;
  border: 2px solid white;
}

@media (max-width: 768px) {
  .fab-cart {
    display: flex;
  }

  /* Transform cart into a bottom drawer */
  .pos-cart {
    position: fixed;
    bottom: -100%; /* Hidden by default */
    left: 0;
    width: 100%;
    height: 70vh;
    z-index: 110;
    transition: bottom 0.3s ease;
    border-radius: 20px 20px 0 0;
  }

  .pos-cart.active {
    bottom: 0;
  }

  /* Add a semi-transparent backdrop when cart is open */
  .cart-overlay-bg {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 105;
  }
  .cart-overlay-bg.active {
    display: block;
  }
}
@media print {
  /* Hide everything else */
  body * {
    visibility: hidden;
    height: 0;
    overflow: hidden;
  }
  #receipt-print,
  #receipt-print * {
    visibility: visible;
    height: auto;
  }

  #receipt-print {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%; /* Thermal printers will auto-scale */
    padding: 10px;
    color: black;
    font-family: "Courier New", Courier, monospace; /* Classic receipt font */
    font-size: 12pt;
    display: block !important;
  }
}
.print-only {
  display: none;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  margin: 5px 0;
}
.receipt-header {
  text-align: center;
  margin-bottom: 10px;
  border-bottom: 1px dashed #000;
  padding-bottom: 10px;
}
.receipt-footer {
  text-align: center;
  margin-top: 10px;
  border-top: 1px dashed #000;
  padding-top: 10px;
}

.mobile-more-menu {
  position: fixed;
  bottom: -100%;
  left: 0;
  width: 100%;
  background: var(--surf);
  z-index: 1000;
  transition: 0.3s;
  border-radius: 20px 20px 0 0;
  padding: 2rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
}

.mobile-more-menu.active {
  bottom: 4rem;
}

.tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  padding: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

.tabs-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.tab-link {
  flex: 0 0 auto;
  background: #e2e8f0;
  border: none;
  padding: 8px 15px;
  border-radius: 100px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--txt-muted);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.tab-link:hover {
  background: var(--pri-light, #e0e7ff);
  color: var(--pri);
}

.tab-link.active {
  background: var(--pri);
  color: var(--text-pri);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

#order-search-input:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  outline: none;
}

#order-search-input:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  outline: none;
}

#order-search-input:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
  outline: none;
}

/* Container for the apps */
.app-grid-container {
  display: flex;
  gap: 25px;
  padding: 20px;
  justify-content: flex-start;
}

/* Individual App Item */
.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  width: 80px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.app-item:active {
  transform: scale(0.9);
}

/* The Icon 'Squircle' */
.app-icon-wrapper {
  position: relative;
  width: 64px;
  height: 64px;
  background: white;
  border-radius: 10px; /* High-quality rounded look */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.app-icon-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Label Styling */
.app-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--txt);
  text-align: center;
  white-space: nowrap;
}

/* Delivery Badge to differentiate the two apps */
.app-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--pri);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  border: 2px solid white;
}


#reader {
  min-height: 300px;
}

#reader video {
  object-fit: cover !important;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--txt-muted);
}