/* ==========================================================================
   BS FIXED ASSETS ERP - SHADCN / TAILWIND REPLICA DESIGN SYSTEM
   Mirrors legacy AppShell, AppSidebar, AppSidebarHeader & shadcn/ui components
   ========================================================================== */

/* Root tokens mapped to shadcn/ui */
:root {
  --fa-bg: #ffffff;
  --fa-fg: #09090b;
  --fa-card: #ffffff;
  --fa-card-fg: #09090b;
  --fa-popover: #ffffff;
  --fa-popover-fg: #09090b;
  --fa-primary: #18181b;
  --fa-primary-fg: #fafafa;
  --fa-secondary: #f4f4f5;
  --fa-secondary-fg: #18181b;
  --fa-muted: #f4f4f5;
  --fa-muted-fg: #71717a;
  --fa-accent: #f4f4f5;
  --fa-accent-fg: #18181b;
  --fa-destructive: #ef4444;
  --fa-destructive-fg: #fafafa;
  --fa-border: #e4e4e7;
  --fa-input: #e4e4e7;
  --fa-ring: #18181b;
  --fa-sidebar: #fafafa;
  --fa-sidebar-fg: #18181b;
  --fa-sidebar-border: #e4e4e7;
  --fa-sidebar-accent: #f4f4f5;
  --fa-sidebar-accent-fg: #18181b;
}

.dark,
[data-theme="dark"],
body.dark-mode {
  --fa-bg: #09090b;
  --fa-fg: #fafafa;
  --fa-card: #09090b;
  --fa-card-fg: #fafafa;
  --fa-popover: #09090b;
  --fa-popover-fg: #fafafa;
  --fa-primary: #fafafa;
  --fa-primary-fg: #18181b;
  --fa-secondary: #27272a;
  --fa-secondary-fg: #fafafa;
  --fa-muted: #27272a;
  --fa-muted-fg: #a1a1aa;
  --fa-accent: #27272a;
  --fa-accent-fg: #fafafa;
  --fa-destructive: #7f1d1d;
  --fa-destructive-fg: #fca5a5;
  --fa-border: #27272a;
  --fa-input: #27272a;
  --fa-ring: #d4d4d8;
  --fa-sidebar: #09090b;
  --fa-sidebar-fg: #fafafa;
  --fa-sidebar-border: #27272a;
  --fa-sidebar-accent: #27272a;
  --fa-sidebar-accent-fg: #fafafa;
}

/* Fullscreen Workspace Shell */
#fixasset-workspace-wrapper {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999;
  background: var(--fa-bg);
  color: var(--fa-fg);
  font-family: 'Inter', 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  display: flex;
  flex-direction: row;
}

/* Master Layout: Sidebar (left) + Content Area (right) */
.fa-shell {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

/* ==========================================================================
   ENTERPRISE SIDEBAR (Matching legacy app-sidebar.tsx)
   ========================================================================== */
.fa-sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  height: 100vh;
  background: var(--fa-sidebar);
  border-right: 1px solid var(--fa-sidebar-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 40;
  user-select: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sidebar Header: AppLogo */
.fa-sidebar-header {
  height: 60px;
  min-height: 60px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--fa-sidebar-border);
}

.fa-sidebar-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.fa-sidebar-brand {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fa-sidebar-brand-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--fa-fg);
  line-height: 1.2;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.fa-sidebar-brand-sub {
  font-size: 0.72rem;
  color: var(--fa-muted-fg);
  font-weight: 500;
}

/* Sidebar Navigation Groups */
.fa-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.fa-sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.fa-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(161, 161, 170, 0.2);
  border-radius: 4px;
}

.fa-nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fa-nav-group-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fa-muted-fg);
  padding: 6px 10px 4px;
}

.fa-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--fa-muted-fg);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fa-nav-item:hover {
  background: var(--fa-sidebar-accent);
  color: var(--fa-sidebar-accent-fg);
}

.fa-nav-item.active {
  background: var(--fa-sidebar-accent);
  color: var(--fa-fg);
  font-weight: 600;
}

.fa-nav-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.8;
  flex-shrink: 0;
  opacity: 0.85;
}

.fa-nav-item.active .fa-nav-icon {
  opacity: 1;
}

.fa-nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fa-nav-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  background: var(--fa-muted);
  color: var(--fa-muted-fg);
  border: 1px solid var(--fa-border);
}

.fa-nav-item.active .fa-nav-badge {
  background: var(--fa-primary);
  color: var(--fa-primary-fg);
  border-color: transparent;
}

/* Sidebar Footer: NavUser */
.fa-sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--fa-sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fa-nav-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}

.fa-nav-user-card:hover {
  background: var(--fa-sidebar-accent);
}

.fa-nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.fa-nav-user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.fa-nav-user-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--fa-fg);
  line-height: 1.2;
}

.fa-nav-user-role {
  font-size: 0.72rem;
  color: var(--fa-muted-fg);
}

/* Switch Back to Daily Report / Portal Button */
.fa-switch-sys-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  border-radius: 6px;
  background: var(--fa-muted);
  color: var(--fa-fg);
  border: 1px solid var(--fa-border);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  width: 100%;
}

.fa-switch-sys-btn:hover {
  background: var(--fa-sidebar-accent);
  border-color: #3b82f6;
  color: #3b82f6;
}

/* ==========================================================================
   CONTENT AREA & APPSIDEBARHEADER (Right side)
   ========================================================================== */
.fa-main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--fa-bg);
}

/* AppSidebarHeader (Height 56px, border-b) */
.fa-app-header {
  height: 56px;
  min-height: 56px;
  border-bottom: 1px solid var(--fa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--fa-bg);
  z-index: 20;
}

.fa-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.fa-sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--fa-border);
  background: transparent;
  color: var(--fa-fg);
  cursor: pointer;
}

/* Breadcrumbs */
.fa-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
}

.fa-crumb-parent {
  color: var(--fa-muted-fg);
  font-weight: 500;
}

.fa-crumb-sep {
  color: var(--fa-muted-fg);
  opacity: 0.6;
}

.fa-crumb-active {
  color: var(--fa-fg);
  font-weight: 600;
}

/* Header Right Actions */
.fa-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fa-edge-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 4px 10px;
  border-radius: 9999px;
  margin-right: 4px;
}

.fa-edge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

.fa-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--fa-border);
  color: var(--fa-fg);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fa-header-btn:hover {
  background: var(--fa-muted);
}

.fa-header-btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
}

/* ==========================================================================
   PAGE CONTAINER & SHADCN COMPONENTS
   ========================================================================== */
.fa-page-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Panel management */
.fa-panel {
  display: none;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.fa-panel.active {
  display: flex;
}

/* Page Header (Title + Subtitle + Action Button) */
.fa-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.fa-page-header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fa-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--fa-fg);
  margin: 0;
  line-height: 1.25;
}

.fa-page-subtitle {
  font-size: 0.875rem;
  color: var(--fa-muted-fg);
  margin: 0;
}

/* Action Buttons (shadcn) */
.fa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 36px;
  padding: 0 14px;
  text-decoration: none;
  border: 1px solid transparent;
}

.fa-btn-primary {
  background: #2563eb;
  color: #ffffff;
}
.fa-btn-primary:hover {
  background: #1d4ed8;
}

.fa-btn-outline {
  background: transparent;
  border-color: var(--fa-border);
  color: var(--fa-fg);
}
.fa-btn-outline:hover {
  background: var(--fa-muted);
}

.fa-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fa-fg);
  height: 28px;
  padding: 0 8px;
  font-size: 0.78rem;
  border-radius: 4px;
}
.fa-btn-ghost:hover {
  background: var(--fa-muted);
}

.fa-btn-destructive {
  color: #ef4444;
}
.fa-btn-destructive:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* Filter & Search Bar */
.fa-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.fa-search-wrapper {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.fa-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  stroke: var(--fa-muted-fg);
  stroke-width: 2;
  pointer-events: none;
}

.fa-search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  font-size: 0.84rem;
  border-radius: 6px;
  border: 1px solid var(--fa-input);
  background: transparent;
  color: var(--fa-fg);
  outline: none;
  transition: border-color 0.15s ease;
}

.fa-search-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}

.fa-select {
  height: 36px;
  padding: 0 28px 0 10px;
  font-size: 0.84rem;
  border-radius: 6px;
  border: 1px solid var(--fa-input);
  background: var(--fa-card);
  color: var(--fa-fg);
  outline: none;
  cursor: pointer;
}

/* ==========================================================================
   SHADCN CARD & TABLE
   ========================================================================== */
.fa-card {
  border: 1px solid var(--fa-border);
  background: var(--fa-card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.fa-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.fa-table {
  width: 100%;
  caption-side: bottom;
  font-size: 0.84rem;
  border-collapse: collapse;
}

.fa-table thead tr {
  border-bottom: 1px solid var(--fa-border);
  background: var(--fa-muted);
}

.fa-table th {
  height: 40px;
  padding: 0 14px;
  text-align: left;
  vertical-align: middle;
  font-weight: 600;
  color: var(--fa-muted-fg);
  white-space: nowrap;
  font-size: 0.78rem;
}

.fa-table tbody tr {
  border-bottom: 1px solid var(--fa-border);
  transition: background 0.15s ease;
}

.fa-table tbody tr:last-child {
  border-bottom: none;
}

.fa-table tbody tr:hover {
  background: rgba(161, 161, 170, 0.05);
}

.fa-table td {
  padding: 10px 14px;
  vertical-align: middle;
  color: var(--fa-fg);
}

.fa-table td.font-medium {
  font-weight: 600;
}

/* Badges (shadcn variant="outline") */
.fa-badge-outline {
  display: inline-flex;
  align-items: center;
  border-radius: 4px;
  border: 1px solid var(--fa-border);
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1;
  color: var(--fa-fg);
  background: transparent;
  white-space: nowrap;
}

.fa-badge-in-stock {
  border-color: rgba(16, 185, 129, 0.3);
  color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.fa-badge-assigned {
  border-color: rgba(59, 130, 246, 0.3);
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

/* Pagination Bar */
.fa-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--fa-border);
  font-size: 0.8rem;
  color: var(--fa-muted-fg);
  background: var(--fa-card);
}

.fa-page-btns {
  display: flex;
  gap: 6px;
}

/* ==========================================================================
   DASHBOARD STAT CARDS & RECENT ACTIVITY
   ========================================================================== */
.fa-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.fa-stat-card {
  border: 1px solid var(--fa-border);
  background: var(--fa-card);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fa-stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fa-stat-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fa-muted-fg);
}

.fa-stat-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fa-stat-val {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--fa-fg);
  line-height: 1;
}

.fa-stat-sub {
  font-size: 0.75rem;
  color: var(--fa-muted-fg);
}

.fa-stat-blue { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.fa-stat-green { background: rgba(16, 185, 129, 0.1); color: #10b981; }
.fa-stat-purple { background: rgba(168, 85, 247, 0.1); color: #a855f7; }
.fa-stat-orange { background: rgba(249, 115, 22, 0.1); color: #f97316; }

/* Device Grid */
.fa-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.fa-device-card {
  border: 1px solid var(--fa-border);
  background: var(--fa-card);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ==========================================================================
   SHADCN DIALOG / MODAL SYSTEM
   ========================================================================== */
.fa-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.fa-modal-overlay.active {
  display: flex;
}

.fa-modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--fa-card);
  border: 1px solid var(--fa-border);
  border-radius: 10px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
}

.fa-modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--fa-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fa-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fa-fg);
}

.fa-modal-close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--fa-muted-fg);
  padding: 4px 8px;
  border-radius: 4px;
}
.fa-modal-close:hover {
  background: var(--fa-muted);
  color: var(--fa-fg);
}

.fa-modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fa-modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--fa-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--fa-muted);
}

.fa-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.fa-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fa-form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--fa-fg);
}

.fa-form-input,
.fa-form-select {
  height: 36px;
  padding: 0 10px;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--fa-input);
  background: transparent;
  color: var(--fa-fg);
  outline: none;
}

.fa-form-input:focus,
.fa-form-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb;
}

/* ==========================================================================
   MOBILE RESPONSIVENESS
   ========================================================================== */
@media (max-width: 900px) {
  .fa-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  }

  .fa-sidebar.mobile-open {
    transform: translateX(0);
  }

  .fa-sidebar-toggle-btn {
    display: flex;
  }

  .fa-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 38;
    display: none;
  }
  .fa-sidebar-backdrop.active {
    display: block;
  }
}

/* ==========================================================================
   PRINT LAYOUT (A4 Handover Sheet & Barcode Stickers)
   ========================================================================== */
@media print {
  body * {
    visibility: hidden !important;
  }

  #fa-printable-area,
  #fa-printable-area * {
    visibility: visible !important;
  }

  #fa-printable-area {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    background: #ffffff !important;
    color: #000000 !important;
    z-index: 9999999 !important;
    padding: 20mm !important;
  }
}
