/* ============================================================
   Mobile & Tablet Responsive Styles
   ============================================================ */

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Safe area for notched devices */
.container,
.container-fluid {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
}

#main-content {
    overflow-x: hidden;
}

/* ---- Touch-friendly targets ---- */
.btn,
.nav-link,
.dropdown-item,
.format-card,
.platform-card,
.btn-ghost,
.navbar-toggler,
.accordion-button {
    -webkit-tap-highlight-color: transparent;
}

.btn-download,
.btn-primary,
.btn-outline-primary,
.btn-outline-secondary,
#btnAudioDownload {
    min-height: 48px;
}

.btn-outline-secondary,
.btn-ghost,
#btnPaste,
#btnBatch {
    min-width: 48px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---- Navbar mobile ---- */
@media (max-width: 991.98px) {
    .navbar-glass {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        max-width: calc(100% - 56px);
    }

    .site-logo {
        height: 36px;
        max-width: min(180px, 100%);
    }

    .footer-logo {
        height: 36px;
        max-width: 180px;
    }

    .navbar-collapse {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 0.75rem;
        margin-top: 0.75rem;
        box-shadow: var(--shadow-md);
    }

    .navbar-nav {
        gap: 0.15rem;
    }

    .nav-link {
        padding: 0.75rem 1rem !important;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .navbar-nav .dropdown-menu {
        position: static !important;
        transform: none !important;
        width: 100%;
        margin-top: 0.25rem;
        box-shadow: none;
        border: 1px solid var(--border-color);
    }

    .navbar-actions-mobile {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem 0.25rem;
        margin-top: 0.5rem;
        border-top: 1px solid var(--border-color);
    }
}

@media (min-width: 992px) {
    .navbar-actions-mobile {
        display: none !important;
    }
}

@media (max-width: 991.98px) {
    .navbar-actions-desktop {
        display: none !important;
    }
}

/* ---- Hero ---- */
@media (max-width: 767.98px) {
    .hero-section {
        padding: 2.5rem 0 1.5rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        padding: 0 0.25rem;
        margin-bottom: 1.25rem;
    }

    .hero-stats {
        gap: 1.25rem;
        flex-wrap: wrap;
    }

    .hero-stat {
        flex: 1 1 30%;
        min-width: 80px;
    }

    .hero-stat .stat-number {
        font-size: 1.4rem;
    }
}

@media (max-width: 380px) {
    .hero-title {
        font-size: 1.65rem;
    }

    .hero-stats {
        gap: 0.75rem;
    }
}

/* ---- Downloader box ---- */
.downloader-section {
    padding-left: 0;
    padding-right: 0;
}

.url-input-wrapper {
    position: relative;
}

.url-input-wrapper .input-group {
    flex-wrap: nowrap;
    align-items: stretch;
}

.url-input-wrapper .glow-input {
    font-size: 16px; /* prevents iOS zoom on focus */
    min-width: 0;
    flex: 1 1 auto;
    padding-right: 2.75rem !important;
    word-break: break-all;
}

.url-input-wrapper .input-group-text {
    flex-shrink: 0;
    padding-left: 0.75rem;
    padding-right: 0.5rem;
}

.url-input-wrapper .input-group-text i {
    font-size: 1.25rem !important;
}

.btn-clear {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.download-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.download-actions .btn-download {
    flex: 1 1 100%;
}

.download-actions .btn-action-secondary {
    flex: 1 1 calc(50% - 0.25rem);
}

@media (min-width: 480px) {
    .download-actions .btn-download {
        flex: 1 1 auto;
    }

    .download-actions .btn-action-secondary {
        flex: 0 0 auto;
        width: 48px;
    }
}

@media (max-width: 575.98px) {
    .url-input-wrapper .input-group-lg > .form-control,
    .url-input-wrapper .input-group-lg > .input-group-text {
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    .downloader-section {
        margin-top: -1rem;
        padding-bottom: 1.5rem;
    }

    .downloader-box.glass-card {
        padding: 1rem;
        border-radius: var(--radius-lg);
        margin-left: -0.25rem;
        margin-right: -0.25rem;
    }

    .platform-badge {
        top: -10px;
        left: 12px;
        font-size: 0.7rem;
        padding: 2px 10px;
    }
}

/* ---- Download result ---- */
.result-header {
    flex-direction: column;
}

.result-thumb {
    width: 100%;
    max-width: 100%;
}

.result-thumb img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.result-info {
    width: 100%;
    min-width: 0;
}

.result-meta {
    gap: 0.5rem !important;
}

.result-title {
    font-size: 0.95rem;
    word-break: break-word;
}

.format-options h6 {
    font-size: 0.95rem;
}

.format-card {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.75rem;
}

.format-card .quality-label {
    font-size: 1rem;
}

.download-error .alert {
    font-size: 0.9rem;
    flex-wrap: wrap;
}

/* ---- Sections ---- */
@media (max-width: 767.98px) {
    .platforms-section,
    .features-section,
    .steps-section,
    .faq-section,
    .testimonials-section {
        padding: 2.5rem 0;
    }

    .section-title {
        font-size: 1.45rem;
        padding: 0 0.5rem;
    }

    .section-subtitle {
        font-size: 0.95rem;
        margin-bottom: 2rem;
        padding: 0 0.5rem;
    }

    .platform-card {
        padding: 1.25rem 0.75rem;
    }

    .platform-card .platform-icon-wrap {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
        margin-bottom: 0.75rem;
    }

    .platform-card h6 {
        font-size: 0.85rem;
    }

    .platform-card p {
        font-size: 0.75rem;
        display: none;
    }

    .feature-card {
        padding: 1.25rem;
        text-align: center;
    }

    .feature-icon {
        margin-left: auto;
        margin-right: auto;
    }

    .step-card {
        padding: 1rem 0.5rem;
    }

    .testimonial-card {
        padding: 1.25rem;
    }

    .accordion-button {
        font-size: 0.95rem;
        padding: 1rem;
        line-height: 1.4;
    }

    .accordion-body {
        font-size: 0.9rem;
        padding: 1rem;
    }
}

/* ---- Page headers ---- */
@media (max-width: 767.98px) {
    .page-header {
        padding: 2.5rem 0 1.5rem;
    }

    .page-header h1 {
        font-size: 1.65rem;
        padding: 0 0.5rem;
    }

    .page-header p {
        font-size: 0.95rem;
        padding: 0 0.75rem;
    }
}

/* ---- Footer ---- */
@media (max-width: 767.98px) {
    .site-footer {
        margin-top: 2.5rem;
    }

    .site-footer .row.g-4 {
        --bs-gutter-y: 1.5rem;
    }

    .site-footer .col-lg-4 {
        text-align: center;
    }

    .site-footer .social-links {
        justify-content: center;
    }

    .footer-heading {
        margin-bottom: 0.75rem;
        font-size: 0.85rem;
    }

    .footer-links a {
        font-size: 0.85rem;
        display: inline-block;
        padding: 0.2rem 0;
        min-height: 32px;
    }

    .footer-bottom {
        text-align: center;
    }

    .footer-bottom .col-md-6 {
        text-align: center !important;
        margin-bottom: 0.35rem;
    }
}

@media (max-width: 575.98px) {
    .site-footer .col-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* ---- Blog & legal pages ---- */
@media (max-width: 767.98px) {
    .blog-card-img {
        height: 160px;
        font-size: 2.25rem;
    }

    .blog-card-body {
        padding: 1.15rem;
    }

    .glass-card {
        padding: 1.15rem;
    }

    .legal-content h4 {
        font-size: 1.1rem;
    }

    .legal-content p,
    .legal-content li {
        font-size: 0.95rem;
    }
}

/* ---- Modal ---- */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.75rem;
    }

    .modal-content.glass-card {
        padding: 0.25rem;
    }

    .modal-body textarea {
        font-size: 16px;
    }
}

/* ---- Toast notifications ---- */
.toast-mobile-container {
    z-index: 9999;
    bottom: 0;
    right: 0;
    left: auto;
    max-width: 100%;
    padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
}

@media (max-width: 575.98px) {
    .toast-mobile-container {
        left: 0 !important;
        right: 0 !important;
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .toast-mobile-container .toast {
        width: 100%;
        max-width: 100%;
    }
}

/* ---- SEO platform page horizontal cards ---- */
@media (max-width: 575.98px) {
    .platform-card.d-flex {
        flex-direction: column !important;
        text-align: center !important;
        padding: 1rem !important;
    }

    .platform-card.d-flex .platform-icon-wrap {
        margin-bottom: 0.5rem !important;
    }
}

/* ---- Utility: prevent overflow ---- */
pre, code {
    word-break: break-word;
    white-space: pre-wrap;
}

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .hero-section {
        padding: 1.5rem 0 1rem;
    }

    .hero-stats {
        margin-top: 1rem;
    }
}
