/* Prime Gold Tea - Core styles */
:root {
  --pg-primary: #1b6e4c;
  --pg-primary-dark: #124b34;
  --pg-gold: #c9971f;
}

body { font-family: 'Segoe UI', Inter, system-ui, sans-serif; }

.sidebar-link.active {
  background-color: rgba(201, 151, 31, 0.15);
  border-left: 3px solid var(--pg-gold);
  color: var(--pg-gold);
}

.dark .sidebar-link.active {
  background-color: rgba(201, 151, 31, 0.2);
}

.kpi-card { transition: transform 0.15s ease, box-shadow 0.15s ease; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.08); }

.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.dark .badge-green { background: #14532d; color: #bbf7d0; }
.dark .badge-yellow { background: #713f12; color: #fef08a; }
.dark .badge-red { background: #7f1d1d; color: #fecaca; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.dark ::-webkit-scrollbar-thumb { background: #475569; }

/* Report tab strip (see reports.js's initReportTabsScroll for the full fix): the strip now has
   its own chevron buttons + edge fades as the primary "there's more here" affordance, so its
   native scrollbar is kept slim and low-contrast to avoid competing visually, while remaining
   fully usable for trackpad/scrollbar-drag users. Firefox uses scrollbar-width/color directly;
   WebKit/Chromium uses the ::-webkit-scrollbar pseudo-elements below. */
.pg-tabs-scroll { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
.dark .pg-tabs-scroll { scrollbar-color: #475569 transparent; }
.pg-tabs-scroll::-webkit-scrollbar { height: 5px; }
.pg-tabs-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.dark .pg-tabs-scroll::-webkit-scrollbar-thumb { background: #475569; }

table.data-table th { position: sticky; top: 0; background: inherit; }

.fade-in { animation: fadeIn 0.2s ease-in; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.spinner {
  border: 3px solid rgba(0,0,0,0.1);
  border-top-color: var(--pg-primary);
  border-radius: 50%;
  width: 28px; height: 28px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.role-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ============================================================
   Multi-Window Desktop System
   ============================================================ */
#pg-desktop {
  position: relative;
  overflow: hidden;
  background: #eef2f6;
}
.dark #pg-desktop { background: #0b1220; }

.pg-window {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.06);
  overflow: hidden;
  min-width: 340px;
  min-height: 220px;
}
.dark .pg-window {
  background: #1e293b;
  box-shadow: 0 10px 40px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.08);
}
.pg-window.pg-window-focused {
  box-shadow: 0 14px 48px rgba(0,0,0,0.28), 0 0 0 2px var(--pg-gold);
}
.pg-window.pg-window-hidden { display: none; }
.pg-window.pg-window-maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}

.pg-window-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--pg-primary-dark);
  color: #fff;
  padding: 8px 10px 8px 14px;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}
.pg-window-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.pg-window-controls { display: flex; gap: 6px; flex-shrink: 0; }
.pg-win-btn {
  width: 26px; height: 24px;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.pg-win-btn:hover { background: rgba(255,255,255,0.28); }
.pg-win-close:hover { background: #dc2626; }

.pg-window-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  background: #f8fafc;
}
.dark .pg-window-body { background: #0f172a; }

.pg-window-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
}
.pg-window.pg-window-maximized .pg-window-resize { display: none; }

#pg-taskbar {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  background: #e2e8f0;
  border-top: 1px solid #cbd5e1;
  overflow-x: auto;
  flex-shrink: 0;
}
.dark #pg-taskbar { background: #1e293b; border-top-color: #334155; }
.pg-taskbar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  color: inherit;
}
.dark .pg-taskbar-item { background: #334155; border-color: #475569; color: #e2e8f0; }
.pg-taskbar-item-minimized { opacity: 0.6; }
.pg-taskbar-item-focused { border-color: var(--pg-gold); box-shadow: inset 0 -2px 0 var(--pg-gold); }

/* ============================================================
   Modal Window Chrome: Minimize / Maximize / Close
   Adds window-manager-style controls to the large transactional entry
   modals (Purchase Order, Quotation, Sales Order, Tax Invoice). Minimize
   drops a small restore pill into a fixed bottom-right tray without
   discarding the form's in-progress data (the modal root is only hidden,
   never cleared); Maximize expands the modal box to fill the viewport;
   Close behaves like the existing plain "X" (clears the modal root).
   ============================================================ */
.pg-modal-ctrl-btn {
  width: 26px; height: 24px;
  border: none;
  background: #f1f5f9;
  color: #64748b;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pg-modal-ctrl-btn:hover { background: #e2e8f0; color: #1f2937; }
.dark .pg-modal-ctrl-btn { background: #334155; color: #cbd5e1; }
.dark .pg-modal-ctrl-btn:hover { background: #475569; color: #fff; }
.pg-modal-ctrl-close:hover { background: #dc2626 !important; color: #fff !important; }

.pg-modal-box { transition: max-width 0.15s ease, height 0.15s ease; }
.pg-modal-box.pg-modal-fullscreen {
  max-width: 100% !important;
  width: 100% !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
}
.pg-modal-overlay-full { padding: 0 !important; align-items: stretch !important; }

.pg-modal-tray {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 70;
}
.pg-modal-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--pg-primary-dark);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  font-size: 13px;
  font-weight: 600;
}
.pg-modal-pill span { cursor: pointer; display: flex; align-items: center; white-space: nowrap; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.pg-modal-pill button { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 20px; height: 20px; border-radius: 4px; cursor: pointer; flex-shrink: 0; }
.pg-modal-pill button:hover { background: #dc2626; }

/* ============================================================
   Flexible Sidebar: collapsible icon rail (desktop) + off-canvas
   drawer (mobile/tablet). See PG.sidebar in app.js for the JS logic.
   ============================================================ */
#sidebar { overflow: hidden; }

/* Desktop collapsed ("icon rail") mode: hide every text label/badge so only
   the icon column remains, and centre each nav icon in the narrow rail. */
.pg-sidebar-collapsed .pg-sidebar-text { display: none; }
.pg-sidebar-collapsed .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; }
.pg-sidebar-collapsed .sidebar-link.active { border-left: none; box-shadow: inset 3px 0 0 var(--pg-gold); }
.pg-sidebar-collapsed #sidebar-collapse-btn { margin-left: 0; }
.pg-sidebar-collapsed .flex.items-center.gap-2.px-4 { justify-content: center; }

/* Mobile/tablet off-canvas drawer: hidden off the left edge by default,
   slides in as a fixed-position overlay above the workspace when opened. */
@media (max-width: 767px) {
  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  #sidebar.pg-sidebar-mobile-open { transform: translateX(0); }
}

/* ============================================================
   "Enter manually..." free-text inputs (Grade/Garden/Origin escape
   hatches in Purchase Order/GRN/Invoice/Return forms). These used to sit
   directly below their <select> inside a narrow multi-column grid cell
   (~180px), which both clipped/scrolled long typed text AND (an earlier,
   now-reverted "float wider on focus" attempt) overlapped neighbouring
   columns. Fixed properly in purchase.js by moving every manual-entry
   input out of the narrow grid column into its own dedicated full-width
   row underneath the whole grid -- see the `[data-manual-wrap]` blocks
   built by poItemRow()/grnItemRow()/invItemRow()/openPRetModal() and
   toggled by togglePOManualField()/togglePRetGardenManual().
   ============================================================ */
