/* ═══════════════════════════════════════════════════════════════════
   PMO Portal — Responsive Stylesheet
   Scope  : Login + Dashboard only (Phase 1 & 2)
   Desktop: 1024px+  → untouched (no overrides at ≥1024px)
   Tablet : 768–1023px
   Mobile : ≤767px
   Small  : ≤374px (iPhone SE, Galaxy Fold outer)
   
   Strategy:
   • All rules are additive — desktop CSS is never removed.
   • Uses CSS custom properties already declared in login.html / main.css.
   • Zero inline styles. Zero !important unless unavoidable.
   • Flexbox / Grid layout only — no float / position hacks.
═══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   SHARED LAYOUT (applies to all pages)
───────────────────────────────────────────────────────────────── */

/* Topbar title truncation on small screens */
@media (max-width: 600px) {
  .topbar-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
  }
  .topbar { padding: 0 14px; }
  .content { padding: 14px; }
}

/* ─────────────────────────────────────────────────────────────────
   PHASE 1 — LOGIN PAGE
   File: login.html (inline <style> overridden via responsive.css
         which is injected via <link> AFTER the inline block)
───────────────────────────────────────────────────────────────── */

/* Tablet: 768–1023px */
@media (max-width: 1023px) and (min-width: 768px) {
  .login-box {
    padding: 32px 36px;
    max-width: 420px;
  }
}

/* Mobile: ≤767px */
@media (max-width: 767px) {
  /* Allow scroll when soft keyboard pushes content */
  .login-container {
    align-items: flex-start;
    padding: 32px 16px 24px;
    overflow-y: auto;
    /* Prevent horizontal scroll */
    overflow-x: hidden;
  }

  .login-box {
    padding: 28px 22px;
    width: 100%;
    max-width: 100%;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,.25);
  }

  .login-box h1 { font-size: 22px; }
  .login-box p  { font-size: 13px; margin-bottom: 20px; }

  .login-form {
    gap: 14px;
  }

  .login-form input {
    padding: 13px 12px;
    font-size: 16px; /* prevents iOS auto-zoom */
    border-radius: 10px;
    /* Touch-friendly tap target ≥44px */
    min-height: 48px;
  }

  .login-form button {
    min-height: 48px;
    font-size: 15px;
    border-radius: 10px;
    /* Touch-friendly */
    touch-action: manipulation;
  }

  .login-logo-area {
    margin-bottom: 20px;
  }
}

/* Small phones: ≤374px (iPhone SE 320px, Galaxy Fold outer ~280px) */
@media (max-width: 374px) {
  .login-container {
    padding: 20px 12px 20px;
  }

  .login-box {
    padding: 24px 16px;
    border-radius: 12px;
  }

  .login-box h1 { font-size: 20px; }

  .login-form input {
    padding: 11px 10px;
  }
}

/* ─────────────────────────────────────────────────────────────────
   PHASE 2 — DASHBOARD
───────────────────────────────────────────────────────────────── */

/* ── Tablet (768–1023px) ─────────────────────────────────────── */
@media (max-width: 1023px) and (min-width: 768px) {

  /* Row 1: hero card takes full width, KPIs drop to 3-col grid */
  .dash-row1 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dash-hero-card {
    flex-direction: row;
    align-items: center;
  }

  /* KPI cards: 3 per row on tablet */
  .dash-kpi6 {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  /* Row 2: stack PvA full-width, Health+Week side by side */
  .dash-row2 {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* PvA takes full row */
  .dash-pva-card {
    grid-column: 1 / -1;
  }

  /* Charts row: 2 cols */
  .dash-charts-row,
  .dash-second-row {
    grid-template-columns: 1fr 1fr;
  }

  /* Projects table: allow horizontal scroll */
  .dash-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Gantt height reduced */
  .dash-gantt-container { height: 180px; }
  .dash-gantt-empty     { height: 180px; }
}

/* ── Mobile (≤767px) ─────────────────────────────────────────── */
@media (max-width: 767px) {

  /* ── Row 1 ── */
  .dash-row1 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Hero card: row layout stays, ring shrinks */
  .dash-hero-card {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 14px;
  }

  .dash-ring { width: 70px; height: 70px; }

  /* KPI cards: 2 per row on mobile */
  .dash-kpi6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .dash-kpi-card {
    padding: 12px 10px;
  }

  .dash-kpi-val  { font-size: 18px; }
  .dash-kpi-lbl  { font-size: 10px; }
  .dash-kpi-icon { width: 28px; height: 28px; font-size: 14px; margin-bottom: 7px; }

  /* ── Alert pills: nowrap scroll ── */
  .dash-alerts {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    /* Hide scrollbar but keep scroll */
    scrollbar-width: none;
  }
  .dash-alerts::-webkit-scrollbar { display: none; }

  /* ── Row 2: all cards stack vertically ── */
  .dash-row2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* PvA chart: limit rows shown on mobile */
  .dash-pva-row:nth-child(n+4) { display: none; }

  /* This Week: 3 cols compact */
  .dash-week-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .dash-week-value { font-size: 16px; }
  .dash-week-label { font-size: 8.5px; }
  .dash-week-item  { padding: 9px 4px; }

  /* ── Row 3: Gantt ── */
  .dash-gantt-container { height: 160px; }
  .dash-gantt-empty     { height: 160px; }

  /* Gantt header wrap */
  .dash-gantt-header {
    flex-wrap: wrap;
    gap: 6px;
  }

  /* ── Charts row (Status + Progress Trend) ── */
  .dash-charts-row,
  .dash-second-row {
    grid-template-columns: 1fr;
  }

  /* Chart containers: fixed height on mobile */
  .chart-container {
    height: 200px;
  }

  /* ── Projects table ── */
  /* Wrap in scrollable container */
  #dashProjectsSection .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* "Projects Requiring Attention" section header */
  .dash-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .dash-section-header h3 { font-size: 13px; }

  /* ── Toolbar ── */
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .toolbar h1 { font-size: 18px; }

  .toolbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar-actions .btn {
    font-size: 12px;
    padding: 7px 12px;
  }

  /* ── Dashboard title area ── */
  .dash-page-sub { font-size: 11px; }
}

/* ── Small phones (≤374px) ───────────────────────────────────── */
@media (max-width: 374px) {

  .dash-kpi6 {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .dash-kpi-card { padding: 10px 8px; }
  .dash-kpi-val  { font-size: 16px; }

  .dash-hero-card { padding: 12px; gap: 10px; }
  .dash-ring { width: 60px; height: 60px; }

  .chart-container { height: 180px; }

  .dash-week-grid { gap: 6px; }
  .dash-week-value { font-size: 15px; }

  /* Alerts: smaller pills */
  .dash-alert-pill { font-size: 10px; padding: 5px 9px; }
}

/* ─────────────────────────────────────────────────────────────────
   CHART CARD — shared responsive wrapper
───────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  .chart-card {
    padding: 14px;
  }
}

/* ─────────────────────────────────────────────────────────────────
   TOUCH IMPROVEMENTS (all mobile)
───────────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
  /* All interactive elements: minimum touch target */
  .btn, button, .nav-item, .avatar,
  .dash-gantt-arrow, .row-action-btn {
    min-height: 40px;
    touch-action: manipulation;
  }

  .btn-sm {
    min-height: 34px;
    padding: 6px 10px;
  }

  /* Inputs: prevent iOS zoom */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Smooth scroll on all overflow containers */
  .table-wrap, .dash-alerts, .content {
    -webkit-overflow-scrolling: touch;
  }
}
