/* Hub Design System — Shared across all MJS2012 Hub pages
   Extends AirHub aesthetic (warm cream, forest green, sage, gold)
   Mobile-first, optimized for iPhone 15+ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-alt: #f5f1eb;
  --primary: #1a3c34;
  --primary-light: #264e44;
  --accent: #7a9e8e;
  --accent-hover: #6b8f7f;
  --gold: #c4a46c;
  --gold-light: #d4b87c;
  --error: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --info: #2563eb;
  --text: #333333;
  --text-secondary: #555555;
  --text-muted: #888888;
  --border: #e5e0d8;
  --border-light: #f0ebe4;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Cormorant Garamond', Georgia, serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* ── Reset ─────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
::selection { background: var(--accent); color: #fff; }
input, select, textarea, button { font-family: inherit; }

/* Prevent iOS zoom on input focus */
input, select, textarea {
  font-size: 16px;
}

/* ── Typography ────────────────────────────────────── */
h1, h2, h3 { font-family: var(--font-heading); color: var(--primary); }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -.3px; }
h2 { font-size: 22px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Topbar ────────────────────────────────────────── */
.hub-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 56px;
  padding-left: max(24px, var(--safe-left));
  padding-right: max(24px, var(--safe-right));
}
.hub-topbar h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}
.hub-topbar .nav-links {
  display: flex;
  gap: 4px;
  align-items: center;
}
.hub-topbar .nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: all .15s;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.hub-topbar .nav-link:hover {
  color: var(--text);
  background: var(--surface-alt);
  text-decoration: none;
}
.hub-topbar .nav-link.active {
  color: var(--primary);
  background: var(--surface-alt);
  font-weight: 600;
}
.hub-topbar .back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.hub-topbar .back-link:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

/* ── Container ─────────────────────────────────────── */
.hub-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
  padding-left: max(24px, var(--safe-left));
  padding-right: max(24px, var(--safe-right));
}

/* ── Cards ─────────────────────────────────────────── */
.hub-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.hub-card h2 {
  font-size: 18px;
  margin-bottom: 16px;
}
.hub-card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 12px;
  font-family: var(--font);
}

/* ── Stat Cards ────────────────────────────────────── */
.hub-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.hub-stat {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.hub-stat .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
  margin-bottom: 4px;
}
.hub-stat .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.hub-stat .value.gold { color: var(--gold); }
.hub-stat .value.success { color: var(--success); }
.hub-stat .value.alert { color: var(--error); }
.hub-stat .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  white-space: nowrap;
  text-decoration: none;
  min-height: 44px;
  min-width: 44px;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--accent); border: 1.5px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-alt); text-decoration: none; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.btn-sm { padding: 6px 14px; font-size: 13px; min-height: 36px; }

/* ── Forms ─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s;
  min-height: 44px;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122,158,142,.12);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ── Tables ────────────────────────────────────────── */
.hub-table {
  width: 100%;
  border-collapse: collapse;
}
.hub-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
  background: var(--surface-alt);
  white-space: nowrap;
}
.hub-table tbody td {
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.hub-table tbody tr:hover { background: var(--surface-alt); }

/* ── Badges ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: #e8f5e9; color: var(--success); }
.badge-red { background: #fef2f2; color: var(--error); }
.badge-yellow { background: #fff8e1; color: var(--warning); }
.badge-blue { background: #e3f2fd; color: var(--info); }
.badge-gray { background: #f3f4f6; color: var(--text-muted); }
.badge-gold { background: #fef3c7; color: var(--gold); }

/* ── Toast ─────────────────────────────────────────── */
.hub-toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  right: 24px;
  padding: 14px 22px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  z-index: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}
.hub-toast.show { opacity: 1; }
.hub-toast.success { background: var(--success); }
.hub-toast.error { background: var(--error); }

/* ── Modal ─────────────────────────────────────────── */
.hub-modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.hub-modal-bg.show { display: flex; }
.hub-modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px;
}
.hub-modal h2 {
  font-size: 20px;
  margin-bottom: 16px;
}

/* ── Tabs ──────────────────────────────────────────── */
.hub-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.hub-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
  white-space: nowrap;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.hub-tab:hover { color: var(--text); }
.hub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ── Empty state ───────────────────────────────────── */
.hub-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.hub-empty h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.hub-empty p { font-size: 14px; }

/* ── Toolbar / Filter bar ──────────────────────────── */
.hub-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.hub-search {
  position: relative;
  flex: 1;
  min-width: 180px;
  max-width: 360px;
}
.hub-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  outline: none;
  background: #fff;
  transition: .15s;
  min-height: 44px;
  color: var(--text);
}
.hub-search input:focus { border-color: var(--accent); }
.hub-search input::placeholder { color: var(--text-muted); }
.hub-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ── User info / Logout ────────────────────────────── */
.user-badge {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logout-btn {
  padding: 8px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  text-decoration: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.logout-btn:hover { background: var(--border-light); color: var(--text); text-decoration: none; }

/* ── Responsive — Mobile (iPhone 15: 393px) ────────── */
@media (max-width: 768px) {
  body { font-size: 14px; }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }

  .hub-topbar {
    padding: 12px 16px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .hub-topbar h1 { font-size: 16px; }
  .hub-topbar .nav-links {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 2px;
  }
  .hub-topbar .nav-link {
    font-size: 12px;
    padding: 8px 10px;
  }

  .hub-container {
    padding: 20px 16px;
  }

  .hub-card { padding: 18px 16px; }
  .hub-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hub-stat { padding: 14px 16px; }
  .hub-stat .value { font-size: 22px; }

  .hub-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .hub-search { max-width: 100%; }

  .hub-table { font-size: 13px; }
  .hub-table thead th { padding: 10px 10px; font-size: 10px; }
  .hub-table tbody td { padding: 10px 10px; }

  .hub-tabs { gap: 0; }
  .hub-tab { padding: 10px 14px; font-size: 13px; }

  .hub-modal { padding: 20px; margin: 12px; }
}

@media (max-width: 480px) {
  .hub-stats { grid-template-columns: 1fr 1fr; }
  .hub-topbar .nav-links { width: 100%; order: 3; }
}
