/* ==========================================================================
   INVENTEX — MAIN APPLICATION STYLESHEET
   File: public/css/app.css
   Mobile-First • High Contrast • Dynamic Viewport Support (100dvh)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. APP HEADER & TOP NAVIGATION
   -------------------------------------------------------------------------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 800;
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  box-shadow: var(--shadow-sm);
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-icon {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.header-business-info {
  display: flex;
  flex-direction: column;
}

.business-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 180px;
}

.business-role-badge {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --------------------------------------------------------------------------
   2. OFFLINE & SYNC BANNER
   -------------------------------------------------------------------------- */
.offline-banner {
  background-color: var(--warning);
  color: #FFFFFF;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 850;
  animation: slideDown 0.3s ease-out;
}

.offline-banner.banner-syncing {
  background-color: var(--info);
}

.offline-banner.banner-online {
  background-color: var(--success);
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   3. TAB CONTENT VIEWS (ROUTER)
   -------------------------------------------------------------------------- */
.tab-view {
  display: none;
  animation: fadeIn 0.15s ease-out;
}

.tab-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   4. HOME DASHBOARD METRICS & ALERT CARDS
   -------------------------------------------------------------------------- */
.valuation-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.valuation-card {
  padding: 0.875rem;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.valuation-card.highlight {
  background: linear-gradient(135deg, var(--primary-light), var(--bg-surface));
  border-color: var(--primary);
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 0.25rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  min-height: 70px;
}

.quick-action-btn:hover {
  background-color: var(--bg-subtle);
}

.quick-action-btn svg {
  width: 24px;
  height: 24px;
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   5. SELL / POINT OF SALE (POS) VIEW (100dvh Layout)
   -------------------------------------------------------------------------- */
.sell-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: calc(100dvh - var(--header-height) - var(--nav-height) - 40px);
}

.pos-search-bar {
  position: relative;
  display: flex;
  gap: 0.5rem;
}

.pos-cart-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.cart-header {
  padding: 0.75rem 1rem;
  background-color: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-items-list {
  flex: 1;
  max-height: 320px;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  background-color: var(--bg-app);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  gap: 0.5rem;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cart-item-price {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.cart-stepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.cart-step-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-weight: bold;
  font-size: 1rem;
}

.cart-qty-input {
  width: 44px;
  height: 36px;
  text-align: center;
  font-weight: 700;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
}

.cart-remove-btn {
  color: var(--danger);
  padding: 0.5rem;
  min-width: 36px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-footer-bar {
  padding: 1rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.cart-total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.cart-total-amount {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   6. STOCK INVENTORY LIST & CARDS
   -------------------------------------------------------------------------- */
.stock-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stock-card {
  padding: 1rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: border-color var(--transition-fast);
}

.stock-card:hover {
  border-color: var(--border-color);
}

.stock-card-main {
  flex: 1;
  min-width: 0;
}

.stock-card-title {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stock-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.stock-card-qty {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.qty-number {
  font-size: 1.125rem;
  font-weight: 800;
}

/* --------------------------------------------------------------------------
   7. BARCODE SCANNER OVERLAY (Html5Qrcode)
   -------------------------------------------------------------------------- */
.scanner-container {
  width: 100%;
  max-height: 320px;
  background-color: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.scanner-video-box {
  width: 100% !important;
  min-height: 250px;
}

.scanner-target-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 120px;
  border: 2px dashed #14B8A6;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

/* --------------------------------------------------------------------------
   8. PRINTABLE SALES RECEIPT
   -------------------------------------------------------------------------- */
.receipt-paper {
  background-color: #FFFFFF;
  color: #000000;
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  border: 1px dashed #CBD5E1;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.receipt-divider {
  border-top: 1px dashed #64748B;
  margin: 0.25rem 0;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
}

@media print {
  body * {
    visibility: hidden;
  }
  .receipt-paper, .receipt-paper * {
    visibility: visible;
  }
  .receipt-paper {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    border: none;
  }
}