/* =============================================================================
   MOBILE-FIRST RESPONSIVE DESIGN SYSTEM
   Digital Media Fix - Premium Mobile Experience
   ============================================================================= */

/* ========== MOBILE LAYOUT GRID OVERRIDES ========== */

@media (max-width: 768px) {
  :root {
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
  }

  body {
    font-size: 16px; /* Prevent zoom on iOS */
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
  }

  /* ===== HEADER & NAVIGATION ===== */
  header {
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(10px);
  }

  .header-wrapper {
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
  }

  .logo {
    height: 40px;
    width: auto;
  }

  /* Mobile-optimized dropdown */
  .nav-dropdown {
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    max-width: none !important;
    background: linear-gradient(135deg, rgba(10, 10, 15, 0.98), rgba(10, 10, 25, 0.98));
    backdrop-filter: blur(20px);
    border-radius: 0;
    padding: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: none;
  }

  .nav-dropdown-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(57, 161, 255, 0.1);
  }

  .nav-dropdown-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
  }

  .nav-dropdown-group h3 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary);
    margin: 0 0 0.8rem;
  }

  .nav-dropdown-group a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.4rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: all 0.2s;
  }

  .nav-dropdown-group a:hover {
    background: rgba(57, 161, 255, 0.1);
    padding-left: 1rem;
    color: var(--primary);
  }

  /* Mobile menu button */
  .mobile-menu-btn {
    display: flex !important;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
  }

  .mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text);
    border-radius: 1px;
    transition: all 0.3s;
  }

  .mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
  }

  .mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
  }

  .mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
  }

  /* ===== HERO SECTION ===== */
  .hero {
    padding: 2rem 1rem;
    text-align: center;
  }

  .hero h1 {
    font-size: clamp(1.5rem, 7vw, 2.2rem);
    line-height: 1.2;
    margin-bottom: 1rem;
  }

  .hero .lead {
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
  }

  .hero-cta {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .hero-cta .btn {
    width: 100%;
    padding: 0.9rem 1.5rem;
    font-size: 0.95rem;
  }

  .hero-visual {
    max-width: 100%;
    height: auto;
    margin-top: 1.5rem;
  }

  /* ===== CONTENT SECTIONS ===== */
  .section {
    padding: 2rem 1rem;
  }

  h2 {
    font-size: clamp(1.3rem, 6vw, 1.8rem);
    margin-bottom: 1.5rem;
    text-align: center;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .grid-3 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .grid-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .card {
    padding: 1.25rem;
  }

  .card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
  }

  /* ===== FORMS & INPUT ===== */
  input,
  textarea,
  select {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 0.9rem;
    border-radius: 0.5rem;
  }

  textarea {
    min-height: 120px;
    resize: vertical;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .form-group label {
    font-size: 0.95rem;
  }

  .btn {
    padding: 0.9rem 1.5rem;
    font-size: 0.95rem;
    border-radius: 0.5rem;
    min-height: 44px; /* Touch target minimum */
  }

  /* ===== TABLES & DATA ===== */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
  }

  table {
    font-size: 0.9rem;
  }

  th,
  td {
    padding: 0.75rem;
  }

  /* ===== THREAT FEED ===== */
  .feed-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .threat-item {
    padding: 1rem;
    border-radius: 0.5rem;
  }

  .threat-item h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .threat-filters {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
  }

  .threat-filter-btn {
    flex-shrink: 0;
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }

  /* ===== PRICING ===== */
  .pricing-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .price-card {
    padding: 1.5rem;
  }

  /* ===== FOOTER ===== */
  footer {
    padding: 2rem 1rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  footer h4 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
  }

  footer a {
    font-size: 0.9rem;
    line-height: 1.8;
  }

  /* ===== MODALS & OVERLAYS ===== */
  .modal {
    padding: 1rem;
    border-radius: 0.5rem;
    max-height: 90vh;
    overflow-y: auto;
  }

  .modal-header h2 {
    font-size: 1.4rem;
    margin-bottom: 0;
  }

  /* ===== ADMIN DASHBOARD ===== */
  .admin-login {
    padding: 1rem;
  }

  .login-card {
    padding: 1.5rem;
    max-width: 100%;
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .dashboard-card {
    padding: 1.25rem;
  }

  .dashboard-card .metric {
    font-size: 2rem;
  }

  /* ===== TABS ===== */
  .tab-nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1.5rem;
  }

  .tab-nav button {
    flex: 1;
    padding: 0.75rem;
    font-size: 0.85rem;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 80px;
  }

  .tab-nav button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
  }

  .tab-content {
    display: none;
  }

  .tab-content.active {
    display: block;
  }

  /* ===== UTILITIES ===== */
  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block;
  }

  .container {
    padding: 0 1rem;
  }

  /* ===== SPACING ADJUSTMENTS ===== */
  margin-top,
  margin-bottom,
  margin-left,
  margin-right {
    --space: 0.5rem;
  }
}

/* ========== TABLET (769px - 1024px) ========== */
@media (min-width: 769px) and (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .feed-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .nav-dropdown {
    position: fixed !important;
    top: 60px !important;
    left: 0 !important;
    right: 0 !important;
    max-width: none !important;
  }
}

/* ========== SMALL DEVICES (480px and below) ========== */
@media (max-width: 480px) {
  h1 {
    font-size: clamp(1.3rem, 6vw, 1.8rem);
  }

  h2 {
    font-size: clamp(1.1rem, 5vw, 1.5rem);
  }

  .section {
    padding: 1.5rem 1rem;
  }

  .hero {
    padding: 1.5rem 1rem;
  }

  .hero-cta {
    flex-direction: column;
  }

  .hero-cta .btn {
    font-size: 0.9rem;
    padding: 0.8rem 1.2rem;
  }

  .card {
    padding: 1rem;
  }

  .btn {
    padding: 0.8rem 1.2rem;
    font-size: 0.9rem;
  }

  .dashboard-card .metric {
    font-size: 1.75rem;
  }

  input,
  textarea,
  select {
    font-size: 16px;
    padding: 0.8rem;
  }

  .tab-nav button {
    font-size: 0.8rem;
    padding: 0.6rem;
  }

  .form-group label {
    font-size: 0.9rem;
  }

  .price-card {
    padding: 1.25rem;
  }

  .threat-item {
    padding: 0.75rem;
  }

  .threat-item h4 {
    font-size: 0.95rem;
  }

  .threat-filters {
    gap: 0.4rem;
  }

  .threat-filter-btn {
    padding: 0.5rem 0.8rem;
    font-size: 0.8rem;
  }

  th,
  td {
    padding: 0.5rem;
    font-size: 0.85rem;
  }
}

/* ========== LANDSCAPE MODE ========== */
@media (max-height: 600px) and (orientation: landscape) {
  .hero {
    padding: 1rem;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  .hero .lead {
    font-size: 0.85rem;
    margin-bottom: 1rem;
  }

  .hero-cta {
    flex-direction: row;
    gap: 0.5rem;
  }

  .hero-visual {
    display: none;
  }

  header {
    padding: 0.5rem 0;
  }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  .btn:hover {
    transform: none;
    background-color: var(--button-bg);
  }

  a:hover {
    color: var(--primary);
  }

  /* Increase touch targets */
  .btn,
  a,
  button {
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1rem;
  }

  /* Remove text selection highlight */
  ::selection {
    background-color: transparent;
  }
}

/* ========== HIGH DPI SCREENS (Retina) ========== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Use higher quality images */
  img {
    image-rendering: -webkit-optimize-contrast;
  }

  .logo {
    image-rendering: crisp-edges;
  }
}

/* ========== DARK MODE MOBILE ========== */
@media (prefers-color-scheme: dark) {
  .mobile-menu-btn span {
    background: var(--text);
  }

  .nav-dropdown {
    background: linear-gradient(135deg, rgba(6, 6, 11, 0.98), rgba(10, 10, 25, 0.98));
  }
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .mobile-menu-btn span {
    transition: none;
  }
}

/* ========== SAFE AREA INSETS (iPhone notch support) ========== */
@supports (padding: max(0px)) {
  header {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  footer {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .modal {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
}
