/* =====================================================
   Portal-specific overrides + Mobile responsive styles
   ===================================================== */

.brand-mark {
  background-image: url('/assets/cogswell-mark.png') !important;
}
.cog-auth-brand .brand-mark-lg {
  background-image: url('/assets/cogswell-mark.png') !important;
}

[data-theme="dark"] .hero-sub { color: var(--text-muted); }

/* iOS — prevent input zoom on focus */
@media (max-width: 900px) {
  input, select, textarea { font-size: 16px !important; }
}

/* Hamburger menu button for mobile sidebar */
.mobile-menu-btn {
  display: none;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--hairline);
  color: var(--text);
  cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--surface); }
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.sidebar-overlay.show { display: block; }

/* ============== Tablet ============== */
@media (max-width: 1100px) {
  .topbar { padding: 12px 18px; }
  .content { padding: 20px 18px 60px !important; }
  .hero { padding: 24px 22px; border-radius: 22px; }
  .hero h1 { font-size: 32px !important; }
  .hero-sub { font-size: 15px; }
  .hero-grid { grid-template-columns: 1fr !important; gap: 24px !important; }
  .hero-kpi { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .row-2, .row-3, .row-4, .proj-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .form-grid { grid-template-columns: 1fr !important; }
  .colspan-2 { grid-column: 1 !important; }
  .page-title { font-size: 28px !important; }
  .kpi-value { font-size: 24px !important; }
}

/* ============== Mobile (Phone) ============== */
@media (max-width: 700px) {
  /* Hide sidebar by default — show via hamburger */
  .app { grid-template-columns: 1fr !important; }
  .sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: 80vw; max-width: 320px;
    height: 100vh !important;
    z-index: 101;
    transform: translateX(-100%);
    transition: transform 280ms cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--bg) !important;
    box-shadow: 0 0 30px rgba(0,0,0,0.4);
    overflow-y: auto;
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar .nav-item span:not(.badge),
  .sidebar .brand-name, .sidebar .brand-sub,
  .sidebar .user-name, .sidebar .user-role { display: inline !important; }
  .sidebar .nav-item { justify-content: flex-start !important; }
  .sidebar .nav-item .badge { display: inline-flex !important; }
  .sidebar .nav-item.active::before { display: block !important; }

  .mobile-menu-btn { display: inline-flex !important; }

  /* Topbar — compact */
  .topbar { padding: 10px 14px !important; gap: 10px; flex-wrap: wrap; }
  .crumb { font-size: 12px; min-width: 0; flex: 1; }
  .crumb b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .search { max-width: none !important; flex-basis: 100%; order: 99; margin-left: 0 !important; }
  .topbar .icon-btn { width: 38px; height: 38px; }
  .topbar .avatar { width: 36px; height: 36px; font-size: 13px; }
  .topbar .theme-toggle { width: 56px; }

  /* Content padding */
  .content { padding: 14px 12px 60px !important; max-width: none !important; }

  /* Hero — phone-sized */
  .hero { padding: 22px 18px; border-radius: 18px; margin-bottom: 18px; }
  .hero h1 { font-size: 26px !important; line-height: 1.1; }
  .hero-sub { font-size: 14px; }
  .hero-actions { flex-wrap: wrap; }
  .hero-actions .btn { font-size: 13px; padding: 9px 14px; }
  .hero-kpi { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .kpi-tile { padding: 14px 14px 12px; border-radius: 14px; }
  .kpi-value { font-size: 20px !important; }
  .kpi-label { font-size: 10px; }
  .kpi-meta { font-size: 11px; }
  .spark { display: none; }

  /* Cards / lists */
  .card { padding: 16px 18px; border-radius: 16px; }
  .pcard { padding: 18px 16px; }
  .tbl { font-size: 13px; }
  .tbl th, .tbl td { padding: 10px 12px !important; }
  .tbl th { font-size: 10px; }
  .tbl td.num, .tbl .row-id { font-size: 12px; }

  .page-title { font-size: 22px !important; }
  .page-sub { font-size: 13px; }
  .page-head { gap: 10px; }
  .card-title { font-size: 14px !important; }
  .list-item { padding: 12px 0 !important; gap: 10px !important; }
  .list-title { font-size: 13px; }
  .list-meta { font-size: 11px; flex-wrap: wrap; }
  .list-aside { font-size: 10px; }
  .list-icon { width: 30px; height: 30px; }

  /* Tabs (filter bars) — let them wrap */
  .tabs { flex-wrap: wrap; gap: 4px !important; }
  .tab { font-size: 12px; padding: 6px 10px; }
  .tab .count { font-size: 10px; padding: 0 5px; }

  /* Buttons */
  .btn { font-size: 13px; padding: 9px 14px; }

  /* Pills */
  .pill { font-size: 9px; padding: 2px 7px; }

  /* Modal */
  .cog-modal-card { width: calc(100vw - 16px); max-width: none; max-height: 92vh; border-radius: 16px; }
  .cog-modal-head { padding: 16px 18px 14px; }
  .cog-modal-body { padding: 16px 18px; }
  .cog-modal-foot { padding: 12px 18px; flex-wrap: wrap; }
  .cog-modal-foot .btn { flex: 1; min-width: 110px; }

  /* Pay method tiles */
  .pay-method { padding: 12px; gap: 10px; }
  .pay-method-icon { width: 32px; height: 32px; border-radius: 8px; }

  /* Detail-page actions — wrap */
  .page-head > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }

  /* Calendar — smaller */
  .cal { gap: 4px; }
  .cal .d { font-size: 11px; border-radius: 6px; }
  .cal .h { font-size: 9px; }

  /* Sidebar floating cards on login */
  .cog-auth-shell { grid-template-columns: 1fr !important; }
  .cog-auth-right { display: none !important; }
  .cog-auth-left { padding: 32px 18px !important; }
  .cog-auth-form-card { max-width: none !important; }
  .cog-auth-title { font-size: 26px !important; }
  .cog-auth-subtitle { font-size: 14px; }

  /* Notifications + search panels — full width */
  .notif-panel { width: calc(100vw - 16px) !important; right: 8px !important; left: 8px !important; }
  .search-results { width: calc(100vw - 16px) !important; left: 8px !important; }

  /* Intro animation — smaller */
  .intro-stage { width: 180px; height: 180px; }
  .intro-logo { width: 120px !important; }
  .intro-wordmark { font-size: 20px !important; gap: 8px; bottom: 28%; }
  .intro-tag { font-size: 10px; bottom: 22%; }

  /* Tables that hold scrolling content */
  .card[style*="padding:0"] { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* Very small phones */
@media (max-width: 380px) {
  .hero h1 { font-size: 22px !important; }
  .hero-kpi { grid-template-columns: 1fr !important; }
  .topbar .crumb { display: none; }
  .page-title { font-size: 20px !important; }
}

/* Touch — bigger tap targets, no hover artifacts on tap */
@media (hover: none) and (pointer: coarse) {
  .nav-item, .btn, .icon-btn, .tab, .pay-method { min-height: 44px; }
  .card.hoverable:hover { transform: none; }
  .kpi-tile:hover { transform: none; }
}

/* Reduce-motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
