/* ============================================================
   responsive-shell.css — Mobile-first layout foundation
   Jade Properties Ops Portal
   Loaded AFTER styles.css on every page.
   ============================================================ */

/* ------------------------------------------------------------
   1. THEME TOKENS
   ------------------------------------------------------------ */

:root {
  /* Backgrounds */
  --bg-primary: #1A2530;
  --bg-surface: #1e2d3a;
  --bg-raised: #253545;
  --bg-hover: #2c3f50;

  /* Text */
  --text-primary: #e8e4df;
  --text-secondary: #8a9aab;
  --text-muted: #8595a5; /* WCAG AA 5.06:1 on bg-primary, 4.59:1 on bg-surface */

  /* Accent — brass */
  --accent: #C5A880;
  --accent-glow: rgba(197, 168, 128, 0.12);
  --accent-shadow: rgba(197, 168, 128, 0.25);

  /* Brand — jade */
  --brand: #2B4C3F;
  --brand-bright: #3a6e58;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.04);
  --border-medium: rgba(255, 255, 255, 0.08);

  /* Status */
  --status-success: #34d399;
  --status-warning: #fbbf24;
  --status-error: #f87171;
  --status-success-bg: rgba(52,211,153,0.12);
  --status-warning-bg: rgba(251,191,36,0.12);
  --status-error-bg: rgba(248,113,113,0.12);

  /* Shadows — namespaced to avoid conflict with styles.css */
  --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-dramatic: 0 8px 24px rgba(0, 0, 0, 0.5);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 24px;

  /* Layout */
  --tab-bar-height: 70px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* ── Legacy token overrides (styles.css components use these) ── */
  /* These map old variable names to dark theme values so every existing
     card, table, badge, and button auto-switches without editing each component. */
  --warm-white: #1A2530;
  --off-white: #1e2d3a;
  --cream: #1e2d3a;
  --cream-dark: #151d26;
  --slate: #e8e4df;
  --muted: #8595a5;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --gray-50: #1a2028;
  --gray-100: #1e2830;
  --gray-200: #253040;
  --gray-300: #354050;
  --gray-400: #8a9098;
  --gray-500: #a0a6ae;
  --gray-600: #b8bec4;
  --gray-700: #d0d4d8;
  --gray-800: #e0e4e8;
  --gray-900: #f0f2f4;
  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --info: #5b9bd5;
  --info-bg: rgba(91, 155, 213, 0.12);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-primary: #FAF8F5;
  --bg-surface: #ffffff;
  --bg-raised: #F3F0EB;
  --bg-hover: #ebe7e1;

  --text-primary: #1A2530;
  --text-secondary: #666666;
  --text-muted: #999999;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.10);

  --shadow-subtle: 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.10);
  --shadow-dramatic: 0 8px 24px rgba(0, 0, 0, 0.14);

  --status-success-bg: #E8F5EE;
  --status-warning-bg: #FFF8E6;
  --status-error-bg: #FDECEB;

  /* ── Legacy token restores for light mode ── */
  --warm-white: #FAF8F5;
  --off-white: #F3F0EB;
  --cream: #F5F5F2;
  --cream-dark: #EAEAE5;
  --slate: #1A2530;
  --muted: #6a6a62;
  --border: rgba(26, 60, 52, 0.10);
  --border-strong: rgba(26, 60, 52, 0.20);
  --gray-50: #FAFAF9;
  --gray-100: #F5F4F2;
  --gray-200: #E8E6E3;
  --gray-300: #D5D3CF;
  --gray-400: #A8A5A0;
  --gray-500: #7A7772;
  --gray-600: #5A5753;
  --gray-700: #3D3B38;
  --gray-800: #262523;
  --gray-900: #1A1918;
  --success: #256b45;
  --success-bg: #E8F5EE;
  --warning: #8a6500;
  --warning-bg: #FFF8E6;
  --danger: #C0392B;
  --danger-bg: #FDECEB;
  --info: #1a5c8a;
  --info-bg: #EBF5FB;
  --shadow-sm: 0 1px 3px rgba(26, 60, 52, 0.08);
  --shadow-md: 0 4px 12px rgba(26, 60, 52, 0.10);
  --shadow-lg: 0 8px 30px rgba(26, 60, 52, 0.12);
}


/* ------------------------------------------------------------
   2. GLOBAL TOUCH FIXES
   ------------------------------------------------------------ */

*,
*::before,
*::after {
  -webkit-tap-highlight-color: transparent;
}

button,
a,
[role="button"],
[role="tab"],
[onclick],
[data-action],
.tappable {
  cursor: pointer;
}


/* ------------------------------------------------------------
   3. BODY DEFAULTS
   ------------------------------------------------------------ */

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-bottom: calc(var(--tab-bar-height) + var(--safe-bottom));
}


/* ------------------------------------------------------------
   4. APP LAYOUT — flexbox column on mobile
   ------------------------------------------------------------ */

.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}


/* ------------------------------------------------------------
   5. SIDEBAR — hidden on mobile
   ------------------------------------------------------------ */

.sidebar {
  display: none;
}


/* ------------------------------------------------------------
   6. OLD MOBILE TOGGLE / OVERLAY — hidden everywhere
   ------------------------------------------------------------ */

.mobile-toggle,
.sidebar-overlay,
.mobile-menu-toggle,
.mobile-nav-overlay {
  display: none !important;
}


/* ------------------------------------------------------------
   7. MAIN CONTENT — full width on mobile
   ------------------------------------------------------------ */

.main-content {
  width: 100%;
  margin-left: 0;
  flex: 1;
  background: var(--bg-primary);
}


/* ------------------------------------------------------------
   8. MOBILE HEADER — sticky top bar
   ------------------------------------------------------------ */

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.page-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}


/* ------------------------------------------------------------
   9. BOTTOM TAB BAR
   ------------------------------------------------------------ */

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  height: calc(var(--tab-bar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

/* Brass gradient line across top */
.tab-bar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--accent) 30%,
    var(--accent) 70%,
    transparent 100%
  );
  opacity: 0.3;
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 4px;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--text-muted);
  text-decoration: none;
  position: relative;
  transition: color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar-item:hover,
.tab-bar-item:focus-visible {
  color: var(--text-secondary);
}

.tab-bar-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tab-bar-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
}

/* Active state */
.tab-bar-item.active {
  color: var(--accent);
}

.tab-bar-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--accent);
  box-shadow: 0 2px 8px var(--accent-shadow), 0 0 16px var(--accent-glow);
}


/* ------------------------------------------------------------
   10. MORE DRAWER — bottom sheet overlay
   ------------------------------------------------------------ */

/* Backdrop */
.more-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.3s;
}

.more-drawer-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0s;
}

/* Drawer panel */
.more-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 96;
  background: var(--bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  padding-bottom: var(--safe-bottom);
}

.more-drawer.open {
  transform: translateY(0);
}

/* Drag handle */
.more-drawer-handle {
  display: flex;
  justify-content: center;
  padding: 12px 0 8px;
}

.more-drawer-handle::before {
  content: "";
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--text-muted);
  opacity: 0.4;
}

/* Group labels */
.more-drawer-group-label {
  padding: 16px 20px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* Item grid */
.more-drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 20px 20px;
}

.more-drawer-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 4px;
  border: none;
  background: none;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background 0.15s ease;
}

.more-drawer-item:hover,
.more-drawer-item:focus-visible {
  background: var(--bg-hover);
}

.more-drawer-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-raised);
  border-radius: var(--radius-xs);
}
.more-drawer-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  color: var(--accent); /* brass for visibility */
}

.more-drawer-item span {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-primary); /* brighter for readability in drawer */
  text-align: center;
  line-height: 1.3;
}


/* ------------------------------------------------------------
   11. DETAIL PANEL — full-screen on mobile
   ------------------------------------------------------------ */

.detail-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  overflow: hidden;
}

.detail-panel.open {
  transform: translateX(0);
}

.detail-panel-header {
  flex-shrink: 0;
  padding: 16px 16px 12px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-bright) 100%);
}

.detail-panel-tabs {
  flex-shrink: 0;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.detail-panel-tabs::-webkit-scrollbar {
  display: none;
}

.detail-panel-tab {
  flex-shrink: 0;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.detail-panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.detail-panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.detail-panel-actions {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}


/* ------------------------------------------------------------
   12. FORM BOTTOM SHEET — full-screen on mobile
   ------------------------------------------------------------ */

.form-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0.3s;
}

.form-sheet-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s 0s;
}

.form-sheet {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
}

.form-sheet.open {
  transform: translateY(0);
}

.form-sheet-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.form-sheet-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-sheet-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 20px;
  border-radius: var(--radius-sm);
}

.form-sheet-close:hover {
  background: var(--bg-hover);
}

.form-sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.form-sheet-footer {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

/* Form inputs — prevent iOS zoom */
.form-sheet input,
.form-sheet select,
.form-sheet textarea {
  min-height: 48px;
  font-size: 16px;
}


/* ------------------------------------------------------------
   13a. MOBILE DASHBOARD
   ------------------------------------------------------------ */

/* On dashboard only, hide desktop page header on mobile (hero replaces it) */
body.page-dashboard .page-header { display: none; }

/* ── Mobile Dashboard ── */
.dash-mobile {
  margin: -20px -16px 16px; /* pull flush to edges, override page-body padding */
}

.dash-hero {
  padding: 16px 20px 20px;
  background: linear-gradient(165deg, var(--brand) 0%, var(--bg-primary) 100%);
  position: relative;
  overflow: hidden;
}
.dash-hero::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -40px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  border-radius: 50%;
}

.dash-hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.dash-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-logo-mark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 18px;
  color: var(--bg-primary);
}
.dash-logo-text {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}
.dash-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}
.dash-greeting {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  position: relative;
}
.dash-date {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Stat strip */
.dash-stat-strip {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  margin-top: -1px;
}
.stat-strip-item {
  flex: 1;
  background: var(--bg-surface);
  padding: 14px 10px;
  text-align: center;
  position: relative;
}
.stat-strip-item:first-child { border-radius: 0 0 0 var(--radius-sm); }
.stat-strip-item:last-child { border-radius: 0 0 var(--radius-sm) 0; }
.stat-strip-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  border-radius: 0 0 2px 2px;
}
.stat-strip-item.s-jade::before { background: var(--brand-bright); box-shadow: 0 0 12px rgba(58,110,88,0.4); }
.stat-strip-item.s-brass::before { background: var(--accent); box-shadow: 0 0 12px var(--accent-shadow); }
.stat-strip-item.s-warn::before { background: var(--status-warning); box-shadow: 0 0 12px rgba(251,191,36,0.3); }
.stat-strip-item.s-err::before { background: var(--status-error); box-shadow: 0 0 12px rgba(248,113,113,0.3); }
.stat-strip-num {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-strip-label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 600;
}

/* Search bar */
.dash-search {
  margin: 14px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.dash-search svg { color: var(--text-muted); flex-shrink: 0; }
.dash-search span { font-size: 14px; color: var(--text-muted); }

/* Quick action cards */
.dash-quick-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 20px;
  margin-bottom: 14px;
}
.dash-quick-card {
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-decoration: none;
  border: 1px solid var(--border-subtle);
  transition: border-color 0.2s;
}
.dash-quick-card:hover { border-color: var(--border-medium); }
.dash-qc-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}
.dash-qc-icon.qc-jade { background: rgba(58,110,88,0.15); color: var(--brand-bright); }
.dash-qc-icon.qc-brass { background: var(--accent-glow); color: var(--accent); }
.dash-qc-title { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.dash-qc-sub { font-size: 11px; color: var(--text-muted); }


/* ------------------------------------------------------------
   13. DESKTOP OVERRIDES — @media (min-width: 1024px)
   ------------------------------------------------------------ */

@media (min-width: 1024px) {
  /* Remove body bottom padding */
  body {
    padding-bottom: 0;
  }

  /* App layout goes horizontal */
  .app-layout {
    flex-direction: row;
  }

  /* Restore sidebar */
  .sidebar {
    display: flex;
  }

  /* Main content offset by sidebar */
  .main-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
  }

  /* Hide mobile-only elements */
  .dash-mobile { display: none; }
  body.page-dashboard .page-header { display: flex; }

  .mobile-header {
    display: none;
  }

  .tab-bar {
    display: none;
  }

  .more-drawer-backdrop,
  .more-drawer {
    display: none;
  }

  /* Detail panel — slide-out on desktop */
  .detail-panel {
    left: auto;
    right: 0;
    width: 56%;
    max-width: 700px;
    box-shadow: var(--shadow-dramatic);
    border-left: 1px solid var(--border-subtle);
  }

  .detail-panel-actions {
    padding-bottom: 12px;
  }

  /* Form sheet — centered modal on desktop */
  .form-sheet-backdrop.open {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .form-sheet {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: 560px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-dramatic);
    transform: translate(-50%, -50%) scale(0.95);
    opacity: 0;
    transition:
      transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
      opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .form-sheet.open {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }

  .form-sheet-footer {
    padding-bottom: 12px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
}
