/* ═══════════════════════════════════════════════════════════════════════════
   Granite Elite Security — Mobile Responsive Stylesheet
   ═══════════════════════════════════════════════════════════════════════════
   This file contains all responsive breakpoints for mobile/tablet devices.
   Loaded after main.css so rules override desktop defaults.

   Breakpoints:
     ≤1024px — Small desktops / landscape tablets
     ≤768px  — Tablets portrait
     ≤480px  — Mobile phones
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Hamburger Menu Button (hidden on desktop) ─────────── */
.ge-mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  color: #111;
  font-size: 22px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s;
  z-index: 210;
  position: relative;
}
.ge-mobile-toggle:hover,
.ge-mobile-toggle:active {
  background: rgba(0,0,0,.06);
}

/* Hamburger icon bars */
.ge-hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 22px;
}
.ge-hamburger span {
  display: block;
  width: 100%;
  height: 2.5px;
  background: #111;
  border-radius: 2px;
  transition: all .25s cubic-bezier(.4, 0, .2, 1);
}

/* Animated X when open */
.ge-mobile-toggle.ge-menu-open .ge-hamburger span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}
.ge-mobile-toggle.ge-menu-open .ge-hamburger span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.ge-mobile-toggle.ge-menu-open .ge-hamburger span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* Mobile nav overlay */
.ge-mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 149;
  opacity: 0;
  transition: opacity .25s;
}
.ge-mobile-overlay.ge-overlay-visible {
  display: block;
  opacity: 1;
}

/* ─────────────────────────────────────────────────────────────────────────
   BREAKPOINT: ≤1024px — Small desktops / landscape tablets
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .container,
  .ge-container {
    padding: 0 1.25rem;
  }

  .ge-pagehead h1 {
    font-size: 1.35em;
  }

  /* Admin dashboard analytics filter — wrap earlier */
  #chart-filters {
    flex-wrap: wrap;
    gap: .4rem;
  }
  #chart-filters .ge-input {
    width: 120px !important;
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   BREAKPOINT: ≤768px — Tablet portrait / large phones
   ───────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* ── Containers ── */
  .container,
  .ge-container {
    padding: 0 1rem;
  }

  .ge-main {
    padding: 14px 0 28px;
  }

  /* ── Show hamburger, collapse nav ── */
  .ge-mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .ge-topbar-inner {
    height: 54px;
  }

  .ge-brand-name {
    font-size: .92em;
  }

  .ge-nav {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: min(300px, 85vw);
    height: 100dvh;
    background: #fff;
    z-index: 150;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 70px 0 24px;
    box-shadow: -4px 0 24px rgba(0,0,0,.15);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1);
  }

  .ge-nav.ge-nav-open {
    display: flex;
    transform: translateX(0);
  }

  .ge-nav > a {
    padding: 14px 20px;
    font-size: 15px;
    border-radius: 0;
    border-bottom: 1px solid rgba(0,0,0,.06);
  }

  .ge-nav > a:hover,
  .ge-nav > a:active {
    background: rgba(181,26,26,.05);
  }

  /* Notification bell in mobile nav */
  .ge-nav-bell {
    padding: 14px 20px;
    font-size: 16px;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(0,0,0,.06);
  }
  .ge-nav-bell::after {
    content: 'Notifications';
    font-size: 15px;
    font-weight: 600;
    color: #111;
  }

  /* User menu in mobile sidebar */
  .ge-nav-user-menu {
    margin: 0;
    border-bottom: 1px solid rgba(0,0,0,.06);
  }

  .ge-nav-user {
    padding: 14px 20px;
    border-radius: 0;
    background: none;
    font-size: 15px;
    width: 100%;
    justify-content: space-between;
  }
  .ge-nav-user::after {
    content: '▾';
    font-size: 12px;
    margin-left: 6px;
  }

  .ge-nav-dropdown {
    position: static;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: rgba(0,0,0,.02);
    min-width: 100%;
    max-height: 45vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .ge-nav-dropdown a {
    padding: 12px 20px 12px 36px;
    font-size: 14px;
  }

  /* Portal switcher in mobile nav */
  .ge-portal-switcher {
    margin: 8px 20px;
  }
  .ge-switch-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: .85rem;
  }

  /* ── Page headings ── */
  .ge-pagehead {
    margin: 0 0 14px;
  }
  .ge-pagehead h1 {
    font-size: 1.25em;
    line-height: 1.3;
  }

  /* ── Grid layouts — 2 columns on tablet ── */
  .ge-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .ge-grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Cards ── */
  .ge-card {
    border-radius: 12px;
  }
  .ge-card-header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .ge-card-header h2 {
    font-size: .92em;
  }
  .ge-card-header-actions {
    width: 100%;
  }
  .ge-card-body {
    padding: 14px;
  }

  /* ── KPI cards ── */
  .ge-kpi-card {
    padding: 14px;
  }
  .ge-kpi-value {
    font-size: 1.6em;
  }

  /* ── Tables — horizontal scroll ── */
  .ge-card-body > table,
  .ge-card-body > .ge-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ge-table th,
  .ge-table td {
    padding: 8px 10px;
    font-size: 13px;
    white-space: nowrap;
  }
  .ge-table th {
    font-size: 11px;
  }

  /* ── Forms — full-width ── */
  .ge-form {
    max-width: 100%;
  }
  .ge-input,
  .ge-form-row select,
  .ge-form-row textarea,
  .ge-form-row input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Filter bars — stack vertically */
  .ge-filter-row {
    flex-direction: column;
    align-items: stretch;
  }
  .ge-filter-select,
  .ge-filter-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }
  .ge-filter-btns {
    margin-left: 0;
    width: 100%;
  }
  .ge-filter-btns .ge-btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* Inline forms (date selectors, etc.) — wrap */
  .ge-inline-form {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .ge-inline-form .ge-input {
    width: 100% !important;
    min-width: 0 !important;
  }

  /* ── Buttons — larger touch targets ── */
  .ge-btn {
    padding: 11px 18px;
    font-size: 14px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .ge-btn-small {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Quick actions — wrap to fill width */
  .ge-actions {
    gap: 8px;
  }
  .ge-actions .ge-btn {
    flex: 1 1 calc(50% - 4px);
    min-width: 140px;
    text-align: center;
    justify-content: center;
  }

  /* ── Charts ── */
  .ge-grid canvas {
    min-height: 180px;
  }

  /* ── Footer ── */
  .ge-footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 6px;
  }

  /* ── Admin dashboard chart filters ── */
  #chart-filters {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  #chart-filters .ge-input,
  #chart-filters select {
    width: 100% !important;
  }

  /* ── Admin dashboard recent activity — override inline 3-col ── */
  .ge-grid-3[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ── Cookie banner ── */
  #ge-cookie-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
  }
  .ge-cookie-actions {
    flex-direction: column;
  }
  .ge-cookie-btn {
    width: 100%;
    text-align: center;
    padding: 10px 18px;
  }
}


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

  /* ── Container ── */
  .container,
  .ge-container {
    padding: 0 .75rem;
  }

  .ge-main {
    padding: 10px 0 20px;
  }

  /* ── Topbar compact ── */
  .ge-topbar-inner {
    height: 50px;
  }
  .ge-logo-img {
    height: 32px;
    width: 32px;
  }
  .ge-brand-name {
    font-size: .82em;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ── Headings ── */
  .ge-pagehead h1 {
    font-size: 1.1em;
  }
  .ge-pagehead .muted {
    font-size: .8em;
  }

  /* ── All grids single column ── */
  .ge-grid-2,
  .ge-grid-3,
  .ge-grid-4 {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  /* ── Cards — tighter padding ── */
  .ge-card {
    border-radius: 10px;
  }
  .ge-card-header {
    padding: 10px 12px;
  }
  .ge-card-body {
    padding: 12px;
  }

  /* ── KPI cards — compact ── */
  .ge-kpi-card {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }
  .ge-kpi-value {
    font-size: 1.5em;
    margin: 0;
  }
  .ge-kpi-label {
    font-size: 11px;
  }
  .ge-kpi-sub {
    font-size: 11px;
    width: 100%;
  }

  /* ── Tables — card-style on very small ── */
  .ge-table th,
  .ge-table td {
    padding: 7px 8px;
    font-size: 12px;
  }

  /* ── Buttons full-width ── */
  .ge-actions {
    flex-direction: column;
  }
  .ge-actions .ge-btn {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
  }

  /* ── Site cards ── */
  .ge-site-card {
    padding: 12px !important;
  }

  /* ── Assignment blocks ── */
  .ge-assignment-title {
    flex-wrap: wrap;
    font-size: 14px;
    gap: 6px;
  }

  /* ── Radio/checkbox groups — full width ── */
  .ge-radio-group,
  .ge-checkbox-group {
    flex-direction: column;
    gap: 8px;
  }
  .ge-radio-label,
  .ge-checkbox-label {
    padding: 10px 14px;
    font-size: 14px;
  }

  /* ── Rating groups ── */
  .ge-rating-group {
    flex-wrap: wrap;
    gap: 8px;
  }
  .ge-rating-label {
    flex: 1 1 calc(33% - 6px);
    min-width: 60px;
    padding: 6px 10px;
  }

  /* ── Profile avatar ── */
  .ge-profile-avatar {
    width: 56px;
    height: 56px;
    font-size: 1.4em;
  }

  /* ── Notification items ── */
  .ge-notification-item {
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }
  .ge-notification-action {
    align-self: flex-end;
  }

  /* ── Pagination ── */
  .ge-pagination {
    gap: 8px;
    flex-wrap: wrap;
  }
  .ge-pagination .ge-btn {
    min-width: 0;
    padding: 8px 12px;
    font-size: 13px;
  }

  /* ── Field mode banner ── */
  .ge-field-mode-banner {
    font-size: .82rem;
    padding: 10px 14px;
    flex-wrap: wrap;
  }

  /* ── Advert section ── */
  .ge-advert-image {
    max-height: 180px;
  }
  .ge-advert-text {
    padding: 14px 14px 8px;
    font-size: 14px;
  }

  /* ── Inactivity toast ── */
  #ge-inactivity-toast {
    bottom: 12px !important;
    left: 12px !important;
    right: 12px !important;
    transform: none !important;
    max-width: none !important;
    font-size: 13px !important;
    flex-wrap: wrap;
  }

  /* ── 2FA QR code ── */
  .ge-qr-img {
    max-width: 180px;
  }
}


/* ─────────────────────────────────────────────────────────────────────────
   UTILITIES — Responsive helpers
   ───────────────────────────────────────────────────────────────────────── */

/* Hide on mobile */
@media (max-width: 768px) {
  .ge-hide-mobile {
    display: none !important;
  }
}

/* Hide on desktop */
@media (min-width: 769px) {
  .ge-hide-desktop {
    display: none !important;
  }
}

/* Scrollable table container helper */
.ge-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -2px;
  padding: 0 2px;
}

/* Touch-friendly select styling */
@media (max-width: 768px) {
  select.ge-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8.5L1 3.5h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
  }
}

/* Smooth scroll for the whole page */
@media (max-width: 768px) {
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }
}

/* Body scroll lock when mobile menu open */
body.ge-menu-lock {
  overflow: hidden;
  position: fixed;
  width: 100%;
}
