/**
 * MapNexus Fieldbook Operations Suite — Unified Design System (Option A)
 * Common Tokens, Layout Standards, Button Hierarchies, Table Wrappers & Mobile Navigation
 */

:root {
  /* Brand Palette */
  --navy: #102c50;
  --navy-deep: #0b1f38;
  --navy2: #193d67;
  --blue: #315ff4;
  --blue-hover: #224ecc;
  --blue-soft: #eaf0ff;
  --ink: #172f4d;
  --muted: #64758a;
  --line: #dfe6ef;
  --line-strong: #cbd5e1;
  --bg: #f3f6fa;
  --card: #ffffff;

  /* State & Category Accents */
  --green: #15803d;
  --green-soft: #eef7ee;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --purple: #4338ca;
  --purple-soft: #e0e7ff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;

  /* Typography & Sizing */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 12px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(16, 44, 80, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 44, 80, 0.08);
}

/* Base Numerics for tabular financial/survey data */
.tabular-nums, table, .stat, .fb-stat-val, .hub-stat strong {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   1. TOPBAR & WORKSPACE NAVIGATION
   ========================================================================== */
.fb-topbar {
  height: 58px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.fb-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.fb-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 750;
  color: var(--navy);
  letter-spacing: -0.3px;
  text-decoration: none;
}

.fb-brand-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--blue);
  color: #ffffff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.fb-brand-icon svg {
  width: 17px;
  height: 17px;
}

.header-workspace-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--navy);
  border: 1px solid var(--line);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.header-workspace-btn:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.header-workspace-btn svg {
  width: 14px;
  height: 14px;
}

/* Minimalist Double-Arrowed Module Switcher */
.module-dropdown-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.module-select {
  appearance: none;
  -webkit-appearance: none;
  background: #ffffff;
  border: 1px solid var(--line, #ccd7e4);
  border-radius: var(--radius-sm, 8px);
  padding: 6px 28px 6px 11px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy, #0b2f5b);
  cursor: pointer;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(16, 44, 80, 0.04);
  transition: border-color .15s, box-shadow .15s;
}

.module-select:hover {
  border-color: var(--line-strong, #9cb3ce);
  box-shadow: 0 2px 6px rgba(16, 44, 80, 0.08);
}

.module-select:focus-visible {
  outline: 2px solid var(--blue, #2877c7);
  outline-offset: 1px;
}

.dropdown-double-arrow {
  position: absolute;
  right: 8px;
  pointer-events: none;
  color: #64758a;
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   2. BUTTON HIERARCHY
   ========================================================================== */
.btn {
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--blue);
  color: #ffffff;
  padding: 8px 14px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn:hover {
  background: var(--blue-hover);
}

.btn.secondary {
  background: #ffffff;
  color: var(--navy);
  border: 1px solid var(--line);
}

.btn.secondary:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn.ghost:hover {
  background: var(--bg);
  color: var(--navy);
}

.btn.soft {
  background: var(--blue-soft);
  color: var(--blue);
}

.btn.soft:hover {
  background: #dbe6fe;
}

.btn.small {
  font-size: 11.5px;
  padding: 6px 10px;
}

/* ==========================================================================
   3. STATUS BADGES & INDICATORS
   ========================================================================== */
.badge, .smart-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  line-height: 1.2;
  white-space: nowrap;
}

.badge.good, .smart-badge.good {
  background: var(--green-soft);
  color: var(--green);
}

.badge.warn, .smart-badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.danger, .smart-badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.info, .smart-badge.info {
  background: var(--blue-soft);
  color: var(--blue);
}

/* ==========================================================================
   4. STAT CARDS & KPI BLOCKS
   ========================================================================== */
.fb-stat-card {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fb-stat-label {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.fb-stat-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.15;
}

/* ==========================================================================
   5. UNIFIED DATA TABLES
   ========================================================================== */
.fb-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.fb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.fb-table th {
  background: #f8fafc;
  color: var(--navy);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.fb-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.fb-table tr:last-child td {
  border-bottom: 0;
}

.fb-table tr:hover td {
  background: #f8fafc;
}

/* ==========================================================================
   6. RESPONSIVE MOBILE STANDARDS & BOTTOM NAVIGATION
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  /* Hide desktop header workspace button and dropdown on mobile */
  .header-workspace-btn,
  .module-dropdown-wrap {
    display: none !important;
  }

  /* Fixed bottom navigation for all modules with blur and safe-area inset */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px)) !important;
    background: rgba(255, 255, 255, 0.94) !important;
    backdrop-filter: blur(14px) !important;
    -webkit-backdrop-filter: blur(14px) !important;
    border-top: 1px solid rgba(16, 44, 80, 0.09) !important;
    box-shadow: 0 -3px 16px rgba(16, 44, 80, 0.07) !important;
    z-index: 1000;
    align-items: center;
    justify-content: space-around;
    padding: 2px 4px calc(env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 100%;
    min-height: 48px;
    background: none;
    border: none;
    color: #64758a;
    text-decoration: none;
    font-size: 10px;
    font-weight: 650;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 2px;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
  }

  .mobile-nav-item.active,
  .mobile-nav-item:active {
    color: var(--blue) !important;
    font-weight: 750 !important;
  }

  .mobile-nav-item.active svg {
    transform: scale(1.08);
  }

  /* Universal bottom clearance so page content is never obscured */
  body, .wrap, .page, .main-wrap, .container, .app, .shell {
    padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Touch scrolling utilities */
  .fb-table-wrap, .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }
}
