/* ============================================================
   IRONLOG — Mobile / PWA CSS (FULL REPLACEMENT for mobile.css)
   ============================================================ */

/* ─── PWA Install Banner ─────────────────────────────────────────────────── */
#ironlog-install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: var(--surface, #2a2f35);
  border-top: 2px solid #c0392b;
  padding: 12px 16px;
  display: none;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
}
.pwa-banner-content {
  display: flex; align-items: center; gap: 12px;
  max-width: 600px; margin: 0 auto; width: 100%;
}
.pwa-banner-icon { width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0; }
.pwa-banner-text {
  flex: 1; display: flex; flex-direction: column; gap: 2px;
  font-family: Inter, sans-serif; color: var(--text-primary, #e8e0d5);
}
.pwa-banner-text strong { font-size: 14px; }
.pwa-banner-text span { font-size: 12px; color: var(--text-secondary, #a09880); }
.pwa-banner-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pwa-btn-install {
  background: #c0392b; color: #fff; border: none; border-radius: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
  white-space: nowrap; font-family: Inter, sans-serif;
}
.pwa-btn-dismiss {
  background: transparent; border: none;
  color: var(--text-secondary, #a09880); font-size: 18px; cursor: pointer; padding: 4px 8px;
}

/* ─── Safe Area ──────────────────────────────────────────────────────────── */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --mobile-topbar-h: 56px;
  --bottom-nav-h: 60px;
}

/* ─── Loading Overlay ────────────────────────────────────────────────────── */
#ironlog-loading {
  position: fixed; inset: 0; z-index: 99999;
  background: var(--surface-2, #1e2327);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
  transition: opacity 0.3s ease;
}
#ironlog-loading.hidden { opacity: 0; pointer-events: none; }
.ironlog-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(192,57,43,0.2);
  border-top-color: #c0392b;
  border-radius: 50%;
  animation: ironlog-spin 0.8s linear infinite;
}
@keyframes ironlog-spin { to { transform: rotate(360deg); } }
.ironlog-loading-text {
  font-family: Inter, sans-serif; font-size: 13px;
  color: var(--text-secondary, #a09880); letter-spacing: 0.04em;
}

/* ─── Brand logo (sidebar) ───────────────────────────────────────────────── */
.brand-with-logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex: 1;
}
.brand-logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: #2a2f35;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; border: 1px solid rgba(255,255,255,0.08);
}
.brand-logo-icon svg { width: 20px; height: 20px; }

/* ─── Mobile Top Bar (hamburger) — hidden on desktop ────────────────────── */
.mobile-topbar { display: none; }
.drawer-backdrop { display: none; }
.mobile-drawer { display: none; }
.mobile-bottom-nav { display: none; }

/* ─── MOBILE ONLY ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* Hide desktop sidebar */
  .sidebar { display: none !important; }

  /* Main content: account for top bar + bottom nav */
  .main-content, main, .content, #content {
    margin-left: 0 !important;
    padding-top: calc(var(--mobile-topbar-h) + 16px) !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px) !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* ── Mobile Top Bar ─────────────────────────────────────────────────── */
  .mobile-topbar {
    display: flex;
    align-items: center;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
    height: var(--mobile-topbar-h);
    background: var(--surface-2, #1e2327);
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
    padding: 0 16px;
    padding-top: var(--safe-top);
    gap: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  }

  .hamburger-btn {
    background: none; border: none;
    color: var(--text-primary, #e8e0d5); cursor: pointer;
    padding: 8px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
    min-width: 44px; min-height: 44px;
  }
  .hamburger-btn:active { background: var(--border, rgba(255,255,255,0.08)); }

  .mobile-topbar-brand {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none; flex: 1;
  }
  .mobile-brand-name {
    font-family: Inter, sans-serif; font-weight: 700;
    font-size: 17px; color: var(--text-primary, #e8e0d5); letter-spacing: 0.04em;
  }
  .mobile-topbar-spacer { width: 44px; }

  /* ── Backdrop ───────────────────────────────────────────────────────── */
  .drawer-backdrop {
    display: block;
    position: fixed; inset: 0;
    z-index: 1100;
    background: rgba(0,0,0,0.6);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
  .drawer-backdrop.open { opacity: 1; pointer-events: auto; }

  /* ── Slide-in Drawer ────────────────────────────────────────────────── */
  .mobile-drawer {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 1200;
    background: var(--surface-2, #1e2327);
    border-right: 1px solid var(--border, rgba(255,255,255,0.08));
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    padding-top: var(--safe-top);
    overflow-y: auto;
  }
  .mobile-drawer.open { transform: translateX(0); }

  /* Drawer Header */
  .drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
  }
  .drawer-brand { display: flex; align-items: center; gap: 10px; }
  .drawer-brand-text {
    display: flex; flex-direction: column; gap: 1px;
  }
  .drawer-brand-text strong {
    font-family: Inter, sans-serif; font-weight: 700;
    font-size: 16px; color: var(--text-primary, #e8e0d5); letter-spacing: 0.04em;
  }
  .drawer-brand-text span {
    font-family: Inter, sans-serif; font-size: 11px;
    color: var(--text-secondary, #a09880); text-transform: uppercase; letter-spacing: 0.08em;
  }

  .drawer-close-btn {
    background: none; border: none;
    color: var(--text-secondary, #a09880); cursor: pointer; padding: 8px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    min-width: 44px; min-height: 44px;
    -webkit-tap-highlight-color: transparent;
  }
  .drawer-close-btn:active { background: var(--border, rgba(255,255,255,0.08)); }

  /* Drawer Nav Links */
  .drawer-nav {
    flex: 1; padding: 12px 0;
    display: flex; flex-direction: column;
  }
  .drawer-link {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 20px;
    color: var(--text-secondary, #a09880); text-decoration: none;
    font-family: Inter, sans-serif; font-size: 15px; font-weight: 500;
    border-left: 3px solid transparent;
    transition: color 0.15s, background 0.15s;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .drawer-link svg { width: 20px; height: 20px; flex-shrink: 0; }
  .drawer-link:active { background: var(--border, rgba(255,255,255,0.05)); }
  .drawer-link.active {
    color: #c0392b;
    background: rgba(192,57,43,0.08);
    border-left-color: #c0392b;
  }

  /* Drawer Footer */
  .drawer-footer {
    border-top: 1px solid var(--border, rgba(255,255,255,0.07));
    padding: 12px 0;
    padding-bottom: calc(12px + var(--safe-bottom));
  }
  .drawer-link-logout { color: #e05a4a !important; }
  .drawer-link-logout:active { background: rgba(192,57,43,0.1) !important; }

  /* ── Bottom Navigation Bar ──────────────────────────────────────────── */
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1000;
    background: var(--surface-2, #1e2327);
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    padding-bottom: var(--safe-bottom);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  }
  .bottom-nav-link {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 8px 4px;
    color: var(--text-tertiary, #6b7280);
    text-decoration: none;
    font-size: 10px; font-family: Inter, sans-serif;
    gap: 3px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
    min-height: 44px;
  }
  .bottom-nav-link svg { width: 22px; height: 22px; }
  .bottom-nav-link.active { color: #c0392b; }
  .bottom-nav-link:active { color: #c0392b; }

  /* ── Page header adjustments ────────────────────────────────────────── */
  .page-header h1 { font-size: 22px !important; }

  /* ── Cards full width ───────────────────────────────────────────────── */
  .stats-grid, .grid, .cards-row, .dash-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  /* ── Charts ─────────────────────────────────────────────────────────── */
  canvas { max-height: 260px !important; }

  /* ── Forms ───────────────────────────────────────────────────────────── */
  input[type="text"], input[type="number"], input[type="email"],
  input[type="password"], input[type="date"], select, textarea {
    width: 100% !important;
    font-size: 16px !important;
    padding: 12px !important;
    box-sizing: border-box !important;
  }

  /* ── Tables ──────────────────────────────────────────────────────────── */
  .table-wrapper, table {
    overflow-x: auto; display: block;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Modals ──────────────────────────────────────────────────────────── */
  .modal, dialog {
    width: 100% !important; max-width: 100% !important;
    margin: 0 !important; border-radius: 16px 16px 0 0 !important;
    position: fixed !important; bottom: 0 !important; top: auto !important;
    max-height: 90vh; overflow-y: auto;
  }
}

/* ─── Standalone PWA (installed on phone) ────────────────────────────────── */
@media (display-mode: standalone) {
  body { padding-top: var(--safe-top); }
  #ironlog-install-banner, #ironlog-ios-hint { display: none !important; }
}

/* ─── Touch targets ─────────────────────────────────────────────────────── */
@media (pointer: coarse) {
  a, button, [role="button"], label, select,
  input[type="checkbox"], input[type="radio"] {
    min-height: 44px; min-width: 44px;
  }
}

/* ─── Offline / Update banners ───────────────────────────────────────────── */
#ironlog-offline-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10000;
  background: #e67e22; color: #fff; text-align: center;
  padding: 8px 16px; font-size: 14px; font-family: Inter, sans-serif;
  display: none;
}
