/* ==================== RESPONSIVE STYLES ==================== */

/* Tablet: max-width 1024px */
@media (max-width: 1024px) {
  .categories-grid {
    grid-template-columns: repeat(3, 1fr);
  }

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

  .calc-layout {
    flex-direction: column;
  }

  .calc-main {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .calc-sidebar {
    flex: 0 0 100%;
    max-width: 100%;
    position: static;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

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

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

  .hero-section h1 {
    font-size: 2.25rem;
  }
}

/* Mobile landscape: max-width 768px */
@media (max-width: 768px) {
  .categories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .main-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    border-top: 1px solid var(--border);
    z-index: 999;
  }

  .main-nav.active {
    display: block;
  }

  .nav-list {
    flex-direction: column;
    padding: 0.5rem 0;
  }

  .nav-list li {
    width: 100%;
  }

  .nav-list li a {
    color: var(--dark);
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
  }

  .nav-list li a:hover {
    background: var(--light);
    color: var(--primary);
  }

  .nav-list li .dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: var(--light);
    opacity: 0;
    pointer-events: none;
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    transition: opacity 0.2s ease, max-height 0.2s ease;
  }

  .nav-list li .dropdown-menu.active {
    opacity: 1;
    pointer-events: auto;
    max-height: 500px;
  }

  .nav-list li .dropdown-menu a {
    padding-left: 2.5rem;
    font-size: 0.85rem;
  }

  .menu-toggle {
    display: flex;
  }

  .hero-section {
    padding: 3rem 0 2.5rem;
    margin-top: 4rem;
  }

  .hero-section h1 {
    font-size: 1.75rem;
  }

  .hero-section .hero-subtitle {
    font-size: 1rem;
  }

  .search-box .btn {
    padding: 0.625rem 1rem;
    font-size: 0.9rem;
  }

  .hero-stats {
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
  }

  .header-actions .lang-switcher,
  .header-actions .user-menu {
    display: none;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .user-layout {
    flex-direction: column;
    margin-top: 5rem;
  }

  .user-sidebar {
    flex: 0 0 auto;
    width: 100%;
  }

  .section {
    padding: 2rem 0;
  }

  .page-content {
    padding: 2rem 0;
  }

  .auth-card {
    padding: 1.75rem;
  }

  .user-content {
    padding: 1.25rem;
  }

  .calc-layout {
    flex-direction: column;
  }

  .calc-main {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .calc-sidebar {
    flex: 0 0 100%;
    max-width: 100%;
    position: static;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .admin-layout {
    flex-direction: column;
  }

  .admin-sidebar {
    flex: 0 0 auto;
    width: 100%;
    position: static;
    height: auto;
  }

  .admin-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 0.5rem;
    gap: 0.25rem;
  }

  .admin-nav a {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
  }

  .admin-content {
    padding: 1rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Mobile portrait: max-width 480px */
@media (max-width: 480px) {
  .categories-grid {
    grid-template-columns: 1fr;
  }

  .calculators-grid {
    grid-template-columns: 1fr;
  }

  .hero-section h1 {
    font-size: 1.5rem;
  }

  .hero-section .hero-subtitle {
    font-size: 0.9rem;
  }

  .header-top {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .site-header .logo {
    font-size: 1.1rem;
  }

  .header-actions .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }

  .btn-lg {
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .calc-sidebar {
    grid-template-columns: 1fr;
  }

  .admin-stats-grid {
    grid-template-columns: 1fr;
  }

  .admin-content {
    padding: 0.75rem;
  }

  .pagination a,
  .pagination span {
    min-width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

  .social-share-btn {
    width: 36px;
    height: 36px;
    font-size: 0.9rem;
  }

  .cookie-notice .container {
    flex-direction: column;
    text-align: center;
  }

  .cookie-notice .cookie-actions {
    width: 100%;
    justify-content: center;
  }

  .footer-donate {
    flex-direction: column;
  }

  .footer-donate .btn {
    width: 100%;
  }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.35rem; }
  h3 { font-size: 1.15rem; }
}

/* Touch-friendly adjustments */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-list li a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .pagination a,
  .pagination span {
    min-width: 44px;
    min-height: 44px;
  }

  .social-share-btn {
    width: 44px;
    height: 44px;
  }

  .category-card {
    padding: 1.25rem;
  }

  .admin-nav a {
    min-height: 44px;
  }
}

/* Print styles */
@media print {
  .header,
  .main-nav,
  .footer,
  .back-to-top,
  .cookie-notice,
  .social-share,
  .ad-slider {
    display: none !important;
  }

  body {
    background: white;
    color: black;
    font-size: 12pt;
  }

  .hero-section {
    background: none;
    color: black;
    padding: 1rem 0;
    margin-top: 0;
  }

  .hero-section h1 {
    color: black;
  }

  .calc-layout {
    flex-direction: column;
  }

  .calc-sidebar {
    position: static;
  }

  a {
    color: black;
    text-decoration: underline;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border: #000;
    --gray: #333;
  }

  .btn-primary {
    background: #0000EE;
    border-color: #0000EE;
  }

  .form-control:focus {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.3);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
