/* ========================================
   Omniverti - Responsive Enhancements
   Covers all breakpoints comprehensively
   ======================================== */

/* === Very small phones (< 400px) === */
@media (max-width: 399px) {
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .category-cards {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .tool-card-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
    min-width: 32px;
  }
  .tool-card {
    padding: 10px;
    gap: 8px;
  }
  .tool-card-name {
    font-size: 12px;
  }
  .hero {
    padding: 90px 0 28px;
  }
  .hero-title {
    font-size: 1.4rem;
  }
  .hero-subtitle {
    font-size: 0.85rem;
  }
  .hero-badge {
    font-size: 11px;
    padding: 5px 12px;
  }
  .section-title {
    font-size: 1.2rem;
  }
  .section-subtitle {
    font-size: 0.85rem;
  }
  .converter-box {
    padding: var(--space-4);
  }
  .upload-area {
    padding: 24px 14px;
  }
  .upload-icon {
    font-size: 36px;
  }
  .upload-area h3 {
    font-size: 15px;
  }
  .upload-area p {
    font-size: 12px;
  }
  .file-info {
    flex-wrap: wrap;
    gap: 10px;
  }
  .file-info-name {
    font-size: 12px;
  }
  .convert-btn {
    font-size: 14px;
    padding: 12px var(--space-4);
  }
  .result-box {
    padding: var(--space-5) var(--space-4);
  }
  .result-icon {
    font-size: 36px;
  }
  .result-box h3 {
    font-size: 16px;
  }
  .result-box p {
    font-size: 13px;
  }
  .download-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
  }
  .breadcrumb {
    font-size: 11px;
    gap: 5px;
    flex-wrap: wrap;
  }
  .breadcrumb a,
  .breadcrumb span {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tool-header h1 {
    font-size: 1.2rem;
  }
  .tool-header p {
    font-size: 0.85rem;
  }
  .share-buttons {
    gap: 6px;
  }
  .share-btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }
  .share-label {
    font-size: 12px;
  }
  .header-inner {
    height: 60px;
  }
  .logo {
    font-size: 18px;
  }
  .logo-icon {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .mobile-toggle {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
  .nav.open {
    top: 60px;
    max-height: calc(100vh - 60px);
    padding: var(--space-4);
  }
  .nav.open a {
    padding: 10px 14px;
    font-size: 14px;
  }
  .features-grid {
    grid-template-columns: 1fr;
  }
  .feature-card {
    padding: 24px 16px;
  }
  .feature-card h3 {
    font-size: 15px;
  }
  .feature-card p {
    font-size: 13px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }
  .stat-number {
    font-size: 1.5rem;
  }
  .stat-label {
    font-size: 12px;
  }
  .footer {
    padding: var(--space-10) 0 0;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
  .footer h4 {
    font-size: 13px;
  }
  .footer-links a {
    font-size: 12px;
  }
  .footer-bottom {
    font-size: 11px;
    padding: 16px 0;
  }
  .page-content {
    padding: 80px 0 40px;
  }
  .page-card {
    padding: var(--space-4);
    margin: 0 var(--space-2);
  }
  .page-card h2 {
    font-size: 1.3rem;
  }
  .page-card p {
    font-size: 13px;
  }
  .modal {
    padding: var(--space-4);
    margin: var(--space-3);
  }
  .modal-header h2 {
    font-size: 1.1rem;
  }
  .toast-container {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }
  .toast {
    padding: 10px 14px;
    font-size: 13px;
  }
  .back-to-top {
    width: 34px;
    height: 34px;
    font-size: 12px;
    bottom: 12px;
    right: 12px;
  }
  .search-box input {
    font-size: 13px !important;
    padding: 12px 38px 12px 14px !important;
  }
}

/* === Small phones (400px - 480px) === */
@media (min-width: 400px) and (max-width: 480px) {
  .tools-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .tool-card-icon {
    width: 36px;
    height: 36px;
    font-size: 16px;
    min-width: 36px;
  }
  .hero-title {
    font-size: 1.6rem;
  }
  .download-btn {
    width: 100%;
    justify-content: center;
  }
  .file-info {
    flex-wrap: wrap;
  }
  .breadcrumb {
    font-size: 12px;
    flex-wrap: wrap;
  }
  .header-inner {
    height: 64px;
  }
  .nav.open {
    top: 64px;
    max-height: calc(100vh - 64px);
  }
}

/* === Phones / Small tablets (480px - 640px) === */
@media (min-width: 481px) and (max-width: 640px) {
  .header-inner {
    height: 64px;
  }
  .nav.open {
    top: 64px;
  }
  .hero-title {
    font-size: 1.8rem;
  }
  .tools-grid {
    grid-template-columns: 1fr 1fr;
  }
  .download-btn {
    width: 100%;
    justify-content: center;
  }
  .breadcrumb {
    font-size: 12px;
    flex-wrap: wrap;
  }
}

/* === Landscape phones / Small tablets (640px - 768px) === */
@media (min-width: 641px) and (max-width: 768px) {
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
  .download-btn {
    width: auto;
  }
}

/* === Tablets (768px - 1024px) === */
@media (min-width: 769px) and (max-width: 1024px) {
  .tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  }
  .header-inner {
    height: 72px;
  }
}

/* === Fix: Breadcrumb on mobile !== RTL === */
@media (max-width: 768px) {
  .breadcrumb {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  .breadcrumb::-webkit-scrollbar {
    display: none;
  }
}

/* === Fix: Touch targets for mobile === */
@media (hover: none) and (pointer: coarse) {
  .tool-card {
    -webkit-tap-highlight-color: transparent;
  }
  .tool-card:active {
    transform: scale(0.98);
  }
  .btn:active,
  .download-btn:active,
  .convert-btn:active {
    transform: scale(0.97);
  }
  .category-chip {
    padding: 12px 22px;
  }
  .filter-btn {
    padding: 12px 24px;
  }
}

/* === Fix: All-tools page on mobile === */
@media (max-width: 768px) {
  .all-tools-page {
    padding: 100px 0 40px;
  }
  .all-tools-page .section-header {
    margin-bottom: var(--space-6);
  }
  .categories-filter {
    margin-bottom: var(--space-5);
  }
}

/* === Fix: Tool page on mobile === */
@media (max-width: 768px) {
  .tool-page {
    padding: 100px 0 40px;
  }
  .tool-header {
    margin-bottom: 24px;
  }
  .tool-header h1 {
    font-size: 1.3rem;
    line-height: 1.4;
  }
}

/* === Fix: Hero actions stacking === */
@media (max-width: 480px) {
  .hero-actions {
    flex-direction: column;
    gap: 10px;
  }
  .hero-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .hero-actions .btn-lg {
    width: 100%;
  }
}

/* === Fix: Tool card overflow on mobile === */
@media (max-width: 480px) {
  .tool-card {
    position: relative;
  }
  .tool-card-badge {
    width: 18px;
    height: 18px;
    font-size: 8px;
    top: 8px;
    left: 8px;
  }
  body[class*="lang-"]:not(.lang-ar) .tool-card-badge,
  html[dir="rtl"] .tool-card-badge {
    left: auto;
    right: 8px;
  }
}

/* === Fix: Improve search on mobile === */
@media (max-width: 480px) {
  .tools-search {
    margin-bottom: var(--space-5);
  }
  .search-input-wrap input {
    font-size: 14px;
    padding: 12px 40px 12px 16px !important;
  }
  .search-hint {
    font-size: 12px;
    margin-top: 8px;
  }
}

/* === Fix: Cookie consent on very small screens === */
@media (max-width: 480px) {
  .cookie-consent-content p {
    font-size: 12px;
    min-width: 0;
  }
  .cookie-btn {
    padding: 8px 18px;
    font-size: 12px;
  }
}

/* === Fix: Modal content overflow on mobile === */
@media (max-width: 480px) {
  .modal-footer {
    flex-direction: column;
    gap: 8px;
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
  }
}

/* === Fix: Empty/Error states on mobile === */
@media (max-width: 480px) {
  .empty-state {
    padding: var(--space-10) var(--space-4);
  }
  .error-state {
    padding: var(--space-10) var(--space-4);
  }
  .empty-state-icon {
    font-size: 40px;
  }
  .empty-state h3 {
    font-size: 17px;
  }
}

/* === Fix: Converter quality/options on mobile === */
@media (max-width: 480px) {
  .convert-options label {
    font-size: 12px;
  }
  .convert-options select,
  .convert-options input[type="number"] {
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* === Fix: Preloader on mobile === */
@media (max-width: 480px) {
  .preloader-logo {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

/* === Fix: Safe area insets for modern phones === */
@supports (padding: max(0px)) {
  .header-inner {
    padding-left: max(var(--container-pad), env(safe-area-inset-left));
    padding-right: max(var(--container-pad), env(safe-area-inset-right));
  }
  .toast-container {
    bottom: max(16px, env(safe-area-inset-bottom));
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
  }
  .cookie-consent {
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-right: max(var(--space-4), env(safe-area-inset-right));
    padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
  }
}

/* === Fix: Upload area on small screens - better tap target === */
@media (max-width: 480px) {
  .upload-area {
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
}

/* === Fix: LTR support for mobile === */
body[class*="lang-"]:not(.lang-ar) .back-to-top {
  left: 16px;
  right: auto;
}

body[class*="lang-"]:not(.lang-ar) .toast-container {
  left: auto;
  right: 16px;
}

@media (max-width: 768px) {
  body[class*="lang-"]:not(.lang-ar) .toast-container {
    left: 16px;
    right: 16px;
  }
}

/* === Fix: Nav open mobile dark mode compatibility === */
@media (max-width: 768px) {
  .nav.open {
    background: var(--white);
    border-bottom-color: var(--gray-100);
  }
}

/* === Fix: Language dropdown in mobile nav should not auto-show === */
@media (max-width: 768px) {
  .nav.open .lang-dropdown {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    max-height: 0;
    overflow: hidden;
    transition: opacity var(--transition), visibility var(--transition), transform var(--transition), max-height var(--transition);
  }
  .nav.open .lang-switcher.open .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    position: static;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: none;
    border: 1px solid var(--gray-100);
    margin-top: 8px;
  }
  .nav.open .lang-switcher {
    position: relative;
  }
}

/* === Fix: Prevent horizontal scroll on mobile === */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
  }
  .hero::before,
  .hero::after {
    display: none;
  }
}

/* === Fix: Ratings on mobile === */
@media (max-width: 480px) {
  .ratings-section {
    padding: var(--space-10) 0;
  }
  .ratings-avg {
    font-size: 22px;
  }
  .ratings-prompt {
    font-size: 13px;
  }
}

/* === Fix: Features section icons on small screens === */
@media (max-width: 480px) {
  .feature-icon {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }
}

/* === Fix: Category filter scroll padding === */
@media (max-width: 480px) {
  .categories-filter {
    -webkit-overflow-scrolling: touch;
  }
}

/* === Fix: Page content on tool info pages === */
@media (max-width: 768px) {
  .page-content {
    padding: 100px 0 40px !important;
  }
}

/* === Fix: Large gaps on mobile === */
@media (max-width: 768px) {
  .gap-6 {
    gap: var(--space-4);
  }
  .gap-4 {
    gap: var(--space-3);
  }
}
