/* ═══════════════════════════════════════════════
   MOBILE RESPONSIVENESS — COMPREHENSIVE
   Luna's Mobile-First Overhaul · March 2026
   ═══════════════════════════════════════════════ */

/* ── Tablet (≤768px) ── */
@media (max-width: 768px) {

  /* Panels: reduced side padding */
  .admin-panel.active {
    padding: 16px;
    padding-top: 0;
  }

  #panel-dashboard.active {
    padding-top: 20px;
  }

  /* Panel header: stack title + button vertically */
  .panel-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 10px;
    height: auto !important;
    padding: 14px 16px !important;
    padding-left: 56px !important; /* ← room for sidebar toggle (Fitts's Law) */
    margin: 0 !important;
    margin-bottom: 16px !important;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
  }

  .panel-title {
    font-size: 16px;
  }

  .btn-create {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
  }

  /* ── Tables → Card-row style (replaces horizontal scroll) ── */
  .admin-table-wrap {
    overflow-x: visible;
    -webkit-overflow-scrolling: auto;
    border-radius: var(--radius-lg);
    background: none;
    border: none;
    box-shadow: none;
  }

  .admin-table {
    min-width: 0;
    display: block;
    border: none;
  }

  .admin-table thead {
    display: none; /* Hide the header row — labels come from ::before */
  }

  .admin-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .admin-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
  }

  .admin-table tbody tr:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
  }

  .admin-table td {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    border-bottom: none;
    font-size: 13px;
    white-space: normal;
    word-break: break-word;
    min-height: 28px;
  }

  /* Data-label: show column name above cell content */
  .admin-table td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    margin-bottom: 1px;
    flex-shrink: 0;
    min-width: 70px;
  }

  /* Hide label on thumbnail cell (first) and actions cell (last) */
  .admin-table td:first-child::before,
  .admin-table td:last-child::before {
    display: none;
  }

  /* First cell (usually thumbnail) – span full width */
  .admin-table td:first-child {
    grid-column: 1 / -1;
    padding-bottom: 6px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border);
  }

  /* Last cell (actions) – span full width, right-aligned */
  .admin-table td:last-child {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    gap: 6px;
    flex-wrap: wrap;
  }

  /* Action buttons – bigger touch targets on mobile (Fitts's Law) */
  .admin-table .btn-action {
    padding: 8px 14px;
    min-height: 40px;
    font-size: 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
  }

  .admin-table .btn-edit {
    background: var(--primary-soft);
    border-color: transparent;
    color: var(--primary);
  }

  .admin-table .btn-delete {
    background: var(--rose-soft);
    border-color: transparent;
    color: var(--rose);
  }

  /* Pagination (admin table) */
  .admin-table-wrap + div {
    flex-wrap: wrap;
  }

  /* Active trivia row – keep highlight on card */
  .admin-table tbody tr.row-active-edition {
    border-left: 3px solid var(--green);
    background: var(--green-soft);
  }

  /* Featured row highlight */
  .admin-table tbody tr.fp-row-featured {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(90deg, rgba(245, 158, 11, .12) 0%, rgba(251, 191, 36, .06) 40%, transparent 100%);
    box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .10);
  }

  /* Modal: more mobile-friendly → bottom sheet */
  .admin-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .admin-modal-content {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 20px 16px;
    animation: modalSlideUpMobile .25s ease;
  }

  @keyframes modalSlideUpMobile {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .modal-title {
    font-size: 16px;
  }

  /* Forms: single column on tablet */
  .admin-form .form-row {
    grid-template-columns: 1fr;
  }

  .admin-form .form-input {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Confirm dialog: more compact */
  .confirm-dialog {
    padding: 20px;
    max-width: calc(100vw - 32px);
  }

  .confirm-title {
    font-size: 15px;
  }

  .confirm-message {
    font-size: 12px;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .confirm-btn {
    width: 100%;
    justify-content: center;
  }

  /* Toasts: full width */
  .toast-container {
    left: 16px;
    right: 16px;
    top: 12px;
  }

  .toast {
    max-width: 100%;
  }

  /* Sidebar toggle: bigger touch target (Fitts's Law) */
  .sidebar-toggle {
    padding: 10px 12px;
    top: 10px;
    left: 10px;
  }

  .sidebar-toggle svg {
    width: 22px;
    height: 22px;
  }

  /* Crossing cards: stack */
  .crossing-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }

  /* Currency card: full width */
  .currency-card {
    max-width: 100%;
    padding: 18px;
  }

  /* Pagination: compact with proper touch targets */
  .pagination-bar {
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }

  .pagination-btn {
    min-height: 44px;
    padding: 10px 18px;
  }

  /* Announcement stats: scroll */
  .ann-stats-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .ann-stat-chip {
    flex-shrink: 0;
    min-width: 140px;
  }

  /* Content submissions detail modal */
  .cs-detail-modal {
    max-width: 100% !important;
  }

  /* Featured spot banner */
  .fsh-banner-content {
    padding: 20px;
    min-height: 160px;
  }

  .fsh-banner-name {
    font-size: 18px;
  }

  .fsh-empty,
  .fp-empty {
    flex-direction: column;
    text-align: center;
    padding: 20px 16px;
  }

  /* Featured promo cards */
  .fp-card {
    min-width: 180px;
    max-width: 180px;
  }

  .fp-card-img-wrap {
    height: 100px;
  }

  /* Featured spot picker grid in modal */
  .fsp-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  /* Users search bar: stack vertically */
  .users-search-bar {
    flex-direction: column;
    gap: 8px;
  }

  .users-search-input-wrap {
    max-width: 100%;
    width: 100%;
  }

  .users-search-btn,
  .users-search-clear {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  /* Groups subtabs: scrollable with fade */
  .groups-subtabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 6px;
    mask-image: linear-gradient(to right, transparent, black 8px, black calc(100% - 16px), transparent);
    -webkit-mask-image: linear-gradient(to right, transparent, black 8px, black calc(100% - 16px), transparent);
  }

  .groups-subtab {
    flex-shrink: 0;
    white-space: nowrap;
    min-height: 40px;
    display: flex;
    align-items: center;
  }

  /* Groups filter bar: scrollable */
  .groups-filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .groups-filter-btn {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Hero banner: stack vertically */
  .admin-panel [style*="display:flex"][style*="min-height:220px"] {
    flex-direction: column !important;
  }

  .admin-panel [style*="display:flex"][style*="min-height:220px"] > [style*="width:240px"] {
    width: 100% !important;
    min-width: 100% !important;
    height: 180px !important;
  }

  /* Poll hero banner: responsive */
  .poll-hero-banner,
  [class*="poll-hero-banner"],
  [style*="border-radius:var(--radius)"][style*="padding:24px"][style*="color:#fff"] {
    padding: 16px !important;
  }

  .poll-hero-header,
  [style*="display:flex"][style*="justify-content:space-between"][style*="align-items:start"][style*="margin-bottom:16px"] {
    flex-direction: column !important;
    gap: 12px !important;
  }

  .poll-hero-actions,
  [style*="display:flex"][style*="gap:6px"]:has(> .btn-action) {
    flex-wrap: wrap !important;
  }

  .poll-hero-options,
  [style*="display:grid"][style*="grid-template-columns:1fr 1fr"][style*="gap:16px"][style*="margin-bottom:16px"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* API docs toolbar */
  .apidocs-toolbar {
    flex-direction: column;
    gap: 6px;
  }

  .token-badge code {
    font-size: 10px;
    word-break: break-all;
  }

  /* Schedule picker: scroll hint */
  .sp-container {
    max-width: 100%;
  }

  /* Image mode tabs: scrollable */
  .img-mode-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .img-mode-tab {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

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

  /* Even tighter padding */
  .admin-panel.active {
    padding: 10px;
    padding-top: 0;
  }

  #panel-dashboard.active {
    padding-top: 14px;
  }

  .panel-header {
    padding: 12px 10px !important;
    padding-left: 52px !important; /* sidebar toggle clearance */
    margin: 0 !important;
    margin-bottom: 12px !important;
    overflow: hidden;
  }

  .panel-title {
    font-size: 14px;
    gap: 6px;
  }

  .panel-title .material-icons-outlined,
  .panel-title svg {
    font-size: 18px;
    width: 18px;
    height: 18px;
  }

  /* Tarjetas de stats: más compactas */
  .stat-card {
    padding: 14px;
  }

  .stat-card .stat-value {
    font-size: 22px;
  }

  .stat-card .stat-icon {
    width: 34px;
    height: 34px;
  }

  /* Table cards: single column on very small screens */
  .admin-table tbody tr {
    grid-template-columns: 1fr;
    padding: 12px 14px;
  }

  .admin-table td {
    font-size: 12px;
  }

  /* Login card: more compact */
  .admin-login-card {
    padding: 28px 20px;
  }

  .login-title {
    font-size: 20px;
  }

  /* Modal: tighter */
  .admin-modal-content {
    padding: 16px 12px;
  }

  .modal-header {
    margin-bottom: 14px;
  }

  /* Action buttons: bigger hit area for thumbs (Fitts's Law) */
  .btn-action {
    padding: 10px 14px;
    min-height: 44px;
    font-size: 12px;
  }

  /* News cards */
  .news-card-body {
    padding: 12px;
  }

  .news-card-footer {
    padding: 10px 12px;
  }

  /* Announcements cards */
  .ann-card-content {
    padding: 12px 14px 10px;
  }

  .ann-card-footer {
    padding: 8px 14px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Content submissions */
  .cs-card {
    padding: 14px;
  }

  .cs-card-header {
    flex-direction: column;
    gap: 8px;
  }

  .cs-detail-actions {
    flex-direction: column;
  }

  .cs-detail-actions .btn-approve,
  .cs-detail-actions .btn-reject,
  .cs-detail-actions .btn-delete-sub {
    width: 100%;
  }

  /* Confirm dialog full width → bottom sheet */
  .confirm-dialog {
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .confirm-overlay {
    align-items: flex-end;
    padding: 0;
  }

  /* Must Go strip cards */
  .mg-card {
    min-width: 100px;
    max-width: 100px;
  }

  /* Featured promo cards */
  .fp-card {
    min-width: 160px;
    max-width: 160px;
  }

  /* Featured spot banner */
  .fsh-banner-content {
    padding: 16px;
    min-height: 140px;
  }

  .fsh-banner-name {
    font-size: 16px;
  }

  /* Crossing cards: smaller */
  .crossing-card {
    padding: 12px 14px;
  }

  /* Pagination inline buttons: proper touch targets */
  .pagination-btn {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 13px;
  }
}

