/* ============================================================
   Right-Arm Global Responsive Design
   Centralized media queries for mobile and tablet views.
   ============================================================ */

/* Hamburger Button Base Styles */
.menu-toggle {
  display: none;
}

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  cursor: pointer;
  z-index: 1001;
  position: relative;
}

.hamburger span {
  display: block;
  height: 2px;
  width: 100%;
  background-color: #fff;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

/* Mobile Devices (Max-width: 768px) */
@media (max-width: 768px) {
  /* Global Layout */
  .container {
    width: 95% !important;
    padding: 10px !important;
  }

  body {
    padding: 0 !important; /* Remove body padding to allow full-width headers */
  }

  main {
    padding: 40px 20px !important; /* Reduce large paddings */
  }

  /* Header & Navigation */
  header {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px 20px !important;
    gap: 0 !important;
    text-align: left !important;
  }

  .hamburger {
    display: flex !important;
  }

  .user-status {
    position: fixed !important;
    top: 0 !important;
    right: -100% !important; /* Start hidden */
    width: 280px !important;
    height: 100vh !important;
    background: rgba(2, 4, 10, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding: 100px 30px 40px !important;
    gap: 20px !important;
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 1000 !important;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5) !important;
    border-left: 1px solid var(--card-border) !important;
    display: flex !important;
  }

  /* Checkbox Hack Toggle */
  .menu-toggle:checked ~ .user-status {
    right: 0 !important;
  }

  .menu-toggle:checked ~ .menu-overlay {
    display: block !important;
  }

  /* Hamburger Animation */
  .menu-toggle:checked ~ .hamburger span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  .menu-toggle:checked ~ .hamburger span:nth-child(2) {
    opacity: 0;
  }
  .menu-toggle:checked ~ .hamburger span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  .user-status .btn, .user-status .badge {
    width: 100% !important;
    text-align: left !important;
    margin: 0 !important;
    padding: 15px 20px !important;
    display: flex !important;
    align-items: center !important;
  }

  .user-status #user-rank-display {
    border: none !important;
    background: transparent !important;
    padding: 0 0 10px 0 !important;
    font-size: 0.8rem !important;
    color: var(--accent-cyan) !important;
    letter-spacing: 2px !important;
  }

  /* Grid & Cards */
  .grid, .card-container, .category-grid, .doc-grid {
    grid-template-columns: 1fr !important; /* Force single column */
    gap: 20px !important;
  }

  /* Specific fix for minmax(380px, 1fr) style grids */
  [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }

  .card, .category-card {
    padding: 25px !important;
    min-width: 0 !important; /* Prevent overflow */
  }

  /* Typography */
  h1, .page-title { font-size: 1.8rem !important; margin-bottom: 30px !important; }
  h2 { font-size: 1.5rem !important; margin: 40px 0 20px !important; }
  h3 { font-size: 1.2rem !important; }
  
  .hero-section h1 {
    font-size: 2.2rem !important;
  }

  /* Forms & Inputs */
  input, select, textarea {
    font-size: 16px !important; /* Prevents iOS auto-zoom */
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .search-container {
    flex-direction: column !important;
    gap: 10px !important;
  }

  label {
    font-size: 0.95rem !important;
    letter-spacing: 1px !important;
  }

  button, .btn {
    width: auto !important;
    min-width: 120px !important;
    padding: 12px 20px !important;
    font-size: 1rem !important;
  }

  /* Modals */
  .modal-content, .profile-modal {
    width: 95% !important;
    margin: 5% auto !important;
    padding: 20px !important;
  }

  /* Tables & Scrolling */
  .table-container {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin: 20px 0 !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-radius: 12px !important;
    border: 1px solid var(--card-border) !important;
  }

  table, .custom-table {
    min-width: 600px !important; /* Ensure content doesn't squash */
    width: 100% !important;
  }

  /* Board Specific */
  .post-card {
    padding: 15px !important;
  }

  .comment-section {
    padding-left: 10px !important;
  }

  .tabs-container {
    padding-bottom: 10px !important;
  }

  /* PDF Viewer */
  iframe {
    height: 400px !important;
  }

  /* Login / Profile */
  .login-card, .profile-card, .login-box {
    width: 95% !important;
    padding: 30px 20px !important;
    margin: 20px auto !important;
  }
}

/* Tablet Devices (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  .grid, .card-container, .category-grid, .doc-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .container {
    width: 90% !important;
  }

  main {
    padding: 60px 30px !important;
  }
}
