/* Mobile layout fixes — landing auth + dashboard (no overlaps) */

@media (max-width: 768px) {
  .auth-overlay.landing-page.active {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: env(safe-area-inset-top) 0 40px;
  }

  .auth-overlay .scene {
    position: fixed;
    inset: 0;
    z-index: 0;
  }

  .auth-overlay .slide-dots {
    bottom: 20px;
    z-index: 5;
  }

  .auth-overlay .bg-caption {
    bottom: 45px;
    font-size: 0.7rem;
    z-index: 5;
  }

  .auth-overlay .sun-wrap { transform: scale(0.6); top: -20px; right: -20px; }
  .auth-overlay .wheat-row { bottom: -10px; height: 60px; }
  .auth-overlay .bird-flock { transform: scale(0.5); }
  
  .auth-overlay .fireflies {
    display: none !important; /* Keep fireflies off for mobile performance */
  }

  .auth-overlay .app-auth-container {
    position: relative;
    z-index: 10;
    opacity: 1;
    animation: none;
    padding: 20px 16px;
    min-height: auto;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .auth-overlay .brand-header {
    margin-bottom: 12px;
  }

  .auth-overlay .brand-name {
    font-size: 1.85rem;
  }

  .auth-overlay .brand-tagline {
    font-size: 0.72rem;
  }

  .auth-overlay #weatherWidget,
  .auth-overlay #langSelector {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    transform: none;
    margin: 0 auto 16px;
    width: calc(100% - 32px);
    max-width: 400px;
    z-index: 15;
    background: rgba(20, 32, 24, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .auth-overlay #weatherWidget.ready {
    transform: none;
  }

  .auth-overlay .auth-card {
    width: calc(100% - 16px);
    max-width: 420px;
    margin: 0 auto;
  }

  .auth-overlay .panels {
    min-height: 0;
    position: relative;
  }

  .auth-overlay .panel {
    position: relative;
    inset: auto;
    transform: none !important;
    opacity: 1;
    pointer-events: none;
    display: none;
    padding: 18px 16px 16px;
    max-height: none;
  }

  .auth-overlay .panel.active {
    display: block;
    pointer-events: auto;
  }

  .auth-overlay .stat-strip {
    display: none;
  }

  body.landing-visible {
    overflow-y: auto;
    overflow-x: hidden;
  }
}

@media (max-width: 480px) {
  .auth-overlay .form-row {
    grid-template-columns: 1fr;
  }

  .auth-overlay .tab-btn span {
    display: none;
  }

  .auth-overlay .auth-card {
    border-radius: 20px;
  }

  .auth-overlay .panel {
    padding: 14px 14px 14px !important;
  }

  .auth-overlay .tab-btn {
    padding: 14px 10px;
    font-size: 0.78rem;
  }

  .auth-overlay .auth-toggle-btn {
    padding: 8px;
    font-size: 0.75rem;
  }

  .auth-overlay .panel-title {
    font-size: 1.3rem;
  }

  .auth-overlay .panel-sub {
    font-size: 0.72rem;
    margin-bottom: 14px;
  }

  .auth-overlay .field {
    margin-bottom: 10px;
  }

  .auth-overlay .field label {
    font-size: 0.65rem;
  }

  .auth-overlay .field input,
  .auth-overlay .field select {
    padding: 10px 12px 10px 34px;
    font-size: 0.82rem;
    border-radius: 10px;
  }

  .auth-overlay .field-wrap svg.icon {
    left: 10px;
    width: 13px;
    height: 13px;
  }

  .auth-overlay .btn-submit {
    padding: 13px;
    font-size: 0.85rem;
    border-radius: 12px;
  }
}

/* Extra small devices */
@media (max-width: 380px) {
  .mobile-doc { padding: 4px; }
  .mobile-dock .dock-btn { min-width: 44px; padding: 4px 3px; font-size: 7px; }
  .mobile-dock .dock-icon { font-size: 11px; }
  .page { padding: 8px 8px; }
  .kpi-card { padding: 10px 12px; }
  .kpi-val { font-size: 1.4rem; }
  .card { padding: 10px; }
  th, td { padding: 6px 5px; font-size: 11px; }
  .topbar { padding: 8px 8px; }
  .topbar-title { font-size: 0.85rem; }

  .auth-overlay .auth-card {
    border-radius: 16px;
  }

  .auth-overlay .panel {
    padding: 12px 10px 12px !important;
  }

  .auth-overlay .brand-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 10px;
  }

  .auth-overlay .brand-icon svg {
    width: 26px;
    height: 26px;
  }

  .auth-overlay .brand-name {
    font-size: 1.4rem;
  }

  .auth-overlay .brand-tagline {
    font-size: 0.6rem;
  }

  .auth-overlay .panel-title {
    font-size: 1.1rem;
  }

  .auth-overlay .tab-btn {
    padding: 10px 8px;
    font-size: 0.72rem;
  }

  .auth-overlay .auth-toggle-btn {
    padding: 6px;
    font-size: 0.7rem;
  }

  .auth-overlay .field input,
  .auth-overlay .field select {
    padding: 8px 10px 8px 30px;
    font-size: 0.78rem;
  }

  .auth-overlay .btn-submit {
    padding: 11px;
    font-size: 0.8rem;
  }

  .auth-overlay .divider {
    margin: 10px 0;
  }
}

/* Dashboard mobile — spacing, topbar, dock */
@media (max-width: 768px) {
  body.dash-theme .main {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  body.dash-theme .topbar {
    height: auto;
    min-height: 56px;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 200;
    position: sticky;
    top: 0;
  }

  body.dash-theme .topbar-title {
    font-size: 1rem;
    flex: 1 1 100%;
    min-width: 0;
  }

  body.dash-theme .topbar-sub {
    font-size: 0.65rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.dash-theme .topbar-right {
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    max-width: 100%;
  }

  body.dash-theme .search-bar-wrap {
    order: 10;
    flex: 1 1 100%;
    max-width: 100%;
  }

  body.dash-theme .notif-wrapper {
    position: relative;
    z-index: 250;
  }

  body.dash-theme .notif-panel {
    position: fixed;
    top: auto;
    bottom: calc(72px + env(safe-area-inset-bottom));
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 50vh;
    z-index: 500;
  }

  body.dash-theme .mobile-dock {
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
  }

  #page-dashboard.dash-page {
    padding: 0 12px 12px;
  }

  body.dash-theme .kpi-grid {
    gap: 10px;
  }

  body.dash-theme .dash-card {
    overflow: hidden;
  }

  body.dash-theme .activity-list,
  body.dash-theme .worker-list-wrap {
    max-height: 220px;
    overflow-y: auto;
  }
}

/* Inline edit controls */
.click-badge {
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s;
}

.click-badge:hover {
  transform: scale(1.04);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.click-badge:active {
  transform: scale(0.98);
}

.inline-quick {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.inline-quick button {
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: var(--gray-50);
  cursor: pointer;
}

.inline-quick button.present {
  background: #e8f5e9;
  border-color: #a5d6a7;
  color: #2e7d32;
}

.inline-quick button.absent {
  background: #ffebee;
  border-color: #ef9a9a;
  color: #c62828;
}

body.dash-theme .inline-quick button {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream);
}

body.dash-theme .inline-quick button.present {
  background: rgba(46, 125, 50, 0.35);
  color: #9ae6a0;
}

body.dash-theme .inline-quick button.absent {
  background: rgba(198, 40, 40, 0.25);
  color: #ffb4a9;
}

tr.click-row {
  cursor: pointer;
}

tr.click-row:hover td {
  background: rgba(56, 158, 104, 0.06);
}

.role-pill {
  display: inline-block;
  font-size: 0.65rem;
  padding: 3px 8px;
  border-radius: 50px;
  background: rgba(232, 197, 71, 0.2);
  color: var(--harvest);
  border: 1px solid rgba(232, 197, 71, 0.35);
  margin-top: 6px;
}

/* ===== COMPREHENSIVE MOBILE FIXES ===== */

/* Prevent iOS zoom on input focus */
@media (max-width: 768px) {
  input, textarea, select, .form-control {
    font-size: 16px !important;
  }
}

/* Mobile modal sizing & padding */
@media (max-width: 600px) {
  .modal {
    max-width: 100vw;
    width: 100%;
    margin: 0 8px;
    max-height: 85vh;
    border-radius: 12px;
  }
  .modal-lg { width: 100%; }
  .modal-header { padding: 14px 16px 12px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal-title { font-size: 16px; }
  .close-btn { font-size: 24px; padding: 4px; }
  .form-grid { grid-template-columns: 1fr; gap: 8px; }

  /* Mobile-friendly table scrolling */
  .table-wrap {
    margin: 0 -4px;
    border-radius: 0;
  }
  .table-wrap table { font-size: 12px; }
  th, td { padding: 8px 8px; white-space: nowrap; }

  /* Page spacing */
  .page { padding: 12px 12px; }
  .section-title { font-size: 18px; }
  .section-desc { font-size: 12px; margin-bottom: 14px; }

  /* KPI cards compact */
  .kpi-grid { gap: 8px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-val { font-size: 1.8rem; }
  .kpi-label { font-size: 0.65rem; }

  /* Card padding */
  .card { padding: 14px; }
  .card-header { margin-bottom: 10px; }
  .card-title { font-size: 14px; }

  /* Buttons */
  .btn { padding: 10px 16px; font-size: 13px; min-height: var(--touch-min); }
  .btn-sm { padding: 8px 12px; font-size: 12px; min-height: 36px; }

  /* Modal form controls touch size */
  .form-control { min-height: var(--touch-min); padding: 10px 12px; }

  /* Page hero compact */
  .page-hero { min-height: 100px; }
  .page-hero-content { padding: 14px 16px; }
  .page-hero .section-title { font-size: 20px; }

  /* Import zone compact */
  .import-zone { padding: 24px 14px; }
  .import-zone .iz-icon { font-size: 2rem; }

  /* Export grid single column */
  .export-grid { grid-template-columns: 1fr; gap: 10px; }
  .export-card { padding: 14px; }
  .export-card .ex-icon { font-size: 28px; }

  /* Weather strip */
  .weather-strip { grid-template-columns: 1fr; }
  .weather-temp { font-size: 36px; }
  .forecast-days { grid-template-columns: repeat(3, 1fr); }

  /* AI chat panel */
  .ai-chat-panel { height: calc(100vh - 120px); min-height: 400px; }
  .msg-bubble { max-width: 88%; font-size: 13px; }
  .quick-prompts { gap: 4px; }
  .quick-prompt { font-size: 11px; padding: 5px 10px; }

  /* SMS page */
  .sms-grid { grid-template-columns: 1fr; }
  .sms-compose, .sms-log { padding: 14px; }

  /* Activity timeline */
  .activity-item { padding: 8px 0; }
  .ai-text { font-size: 0.78rem; }

  /* Worker rows */
  .worker-row { padding: 8px 14px; }
  .task-item { padding: 8px 14px; }

  /* Crop list */
  .crop-row { padding: 10px 14px; }

  /* Bottom row dash layout */
  .bottom-row { gap: 10px; }

  /* Notification panel mobile */
  .notif-panel { left: 8px; right: 8px; bottom: calc(68px + env(safe-area-inset-bottom)); }
  .notif-item { padding: 10px 12px; }

  /* Settings page */
  #page-settings .grid-2 { gap: 12px; }

  /* Reports page */
  .report-summary { grid-template-columns: 1fr; gap: 10px; }
  .report-card { padding: 14px; }
  .bar-label { width: 60px; font-size: 11px; }

  /* Inventory items */
  .health-ring-wrap { grid-template-columns: 1fr; }
  .plot-grid { gap: 10px; }
  .plot-card { padding: 14px; }

  /* Attendance page */
  .stats-grid { gap: 8px; }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 20px; }

  /* GPS map */
  .gps-landscape-container { height: 200px; }
  .gps-toolbar { gap: 4px; }
  .gps-toolbar .btn { font-size: 11px; padding: 6px 10px; }

  /* Chat input */
  .chat-input-row { gap: 6px; }
  .chat-input { font-size: 16px !important; min-height: var(--touch-min); }

  /* Topbar buttons */
  .topbar-right .btn { padding: 6px 10px; font-size: 11px; min-height: 32px; }
  .currency-toggle button { padding: 4px 6px !important; font-size: 11px !important; }

  /* Dashboard cards */
  .dash-card .card-header { padding: 14px 16px 12px; }

  /* Activity feed in dashboard */
  .activity-list { max-height: 200px; }
  .worker-list-wrap { max-height: 180px; }

  /* Season progress */
  .milestone { width: 60px; }
  .milestone-dot { width: 30px; height: 30px; font-size: 0.9rem; }
  .milestone-label { font-size: 0.65rem; }
  .milestone-date { font-size: 0.55rem; }

  /* Mid row layout */
  .mid-row { gap: 10px; }
  .chart-row { gap: 10px; }

  /* About page */
  .about-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Admin page */
  .admin-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Farm photo strip */
  .farm-photo-strip { grid-template-columns: 1fr 1fr; gap: 6px; }
  .farm-photo-card { height: 70px; }

  /* Collab modal */
  #modal-collab .modal { max-width: 100vw; }
}


