/**
 * RKMovies Admin Dashboard — Reveal Mobile Responsiveness
 * Zero-leak layout containment, touch targets, frosted bottom dock, and responsive card collapses
 */

/* ========================================================================== */
/* 1. Global Containment & Mobile Reset                                       */
/* ========================================================================== */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
  width: 100%;
}

.app-wrapper {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}

/* ========================================================================== */
/* 2. Frosted Glass Bottom Dock (Visible on Mobile <= 768px)                  */
/* ========================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
  z-index: 90;
  background-color: rgba(10, 10, 14, 0.92);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.85);
  padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px)) 0.5rem;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.35rem 0.2rem;
  min-height: 44px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.mobile-nav-item svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  transition: transform var(--transition-fast);
}

.mobile-nav-item.active {
  color: #ffffff;
}

.mobile-nav-item.active svg {
  stroke: #ffffff;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.7));
  transform: translateY(-2px);
}

/* ========================================================================== */
/* 3. Breakpoint: Tablet Devices (<= 992px)                                   */
/* ========================================================================== */
@media (max-width: 992px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================================================== */
/* 4. Breakpoint: Mobile Viewports (<= 768px)                                 */
/* ========================================================================== */
@media (max-width: 768px) {
  /* Bottom dock display */
  .mobile-bottom-nav {
    display: flex;
  }

  /* Main container sizing & safe clearance above bottom dock */
  .main-content {
    padding-top: 1.25rem;
    padding-bottom: 6.5rem;
    padding-left: 1rem;
    padding-right: 1rem;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* Header adjustments: prevent any header overflowing */
  .app-header {
    padding: 0.65rem 1rem;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .header-container {
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }

  .brand-text h1 {
    font-size: 1.05rem;
  }

  .brand-text p {
    display: none;
  }

  /* Action icon buttons: Hide text labels on mobile for clean icon buttons */
  .header-actions {
    gap: 0.4rem;
  }

  .header-actions .btn {
    padding: 0.45rem 0.55rem;
    min-height: 38px;
    min-width: 38px;
    justify-content: center;
    border-radius: var(--radius-md);
  }

  .header-actions .btn span.btn-label {
    display: none;
  }

  /* Hide desktop tab buttons on mobile (bottom dock used instead) */
  .nav-tabs-bar {
    margin-bottom: 1.25rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    width: 100%;
  }

  .nav-tabs-bar .tabs-group {
    display: none;
  }

  /* Date Range Filter: full width 4-column equal grid */
  .filter-bar {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .filter-pills {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.25rem;
    padding: 0.25rem;
    box-sizing: border-box;
  }

  .pill-btn {
    width: 100%;
    text-align: center;
    padding: 0.5rem 0.2rem;
    font-size: 0.76rem;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .custom-range-inputs.show {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
  }

  .custom-range-inputs .date-input {
    flex: 1;
    min-width: 120px;
    min-height: 40px;
  }

  /* KPI Card Grids: 1 column clean cards */
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
    gap: 0.95rem;
    width: 100%;
    box-sizing: border-box;
  }

  .stat-card {
    padding: 1.2rem 1.25rem;
    width: 100%;
    box-sizing: border-box;
  }

  .stat-value {
    font-size: 1.85rem;
    line-height: 1.2;
    word-break: break-all;
  }

  .stat-title {
    font-size: 0.72rem;
  }

  /* Section headers */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
  }

  .section-title {
    font-size: 1.15rem;
  }

  .section-subtitle {
    font-size: 0.78rem;
  }

  /* Charts */
  .chart-card {
    padding: 1.25rem 1rem;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .chart-legend {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .chart-container {
    height: 220px;
    width: 100%;
    max-width: 100%;
  }

  /* Tables: Horizontal scroll inside the card, ZERO page overflow */
  .table-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    display: block;
    box-sizing: border-box;
  }

  .data-table {
    min-width: 520px;
    font-size: 0.82rem;
  }

  .data-table th, .data-table td {
    padding: 0.75rem 0.85rem;
    white-space: nowrap;
  }

  /* Security banner card on mobile */
  .security-banner-card {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    gap: 0.85rem;
    width: 100%;
    box-sizing: border-box;
  }

  .security-banner-card .btn {
    width: 100%;
    justify-content: center;
  }

  .security-banner-card code {
    word-break: break-all;
    font-size: 0.75rem;
  }

  /* Notice card on mobile */
  .config-notice-card {
    padding: 1rem;
  }

  /* Modals */
  .modal-card {
    padding: 1.25rem;
    width: 100%;
    max-width: 95vw;
    box-sizing: border-box;
  }
}

/* ========================================================================== */
/* 5. Extra Small Viewports (<= 380px)                                        */
/* ========================================================================== */
@media (max-width: 380px) {
  .pill-btn {
    font-size: 0.7rem;
    padding: 0.45rem 0.15rem;
  }

  .stat-value {
    font-size: 1.65rem;
  }

  .brand-text h1 {
    font-size: 0.95rem;
  }
}
