/* ==================== MOBILE RESPONSIVE STYLES ==================== */
/* Подключается ко всем страницам для адаптивности */

/* Базовые настройки для всех устройств */
* {
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
    width: 100%;
}

/* Предотвращаем выход контента за границы */
.max-w-7xl,
.max-w-6xl,
.max-w-5xl,
.max-w-4xl,
.max-w-3xl,
section,
div {
    max-width: 100%;
}

/* Tablets and smaller (1024px and below) */
@media (max-width: 1024px) {
    /* Hero section text */
    .hero-bg h1,
    h1.text-5xl,
    h1.md\\:text-7xl {
        font-size: 3.5rem !important;
        line-height: 1.2;
    }

    .hero-bg p,
    p.text-xl,
    p.md\\:text-2xl {
        font-size: 1.25rem !important;
    }
}

/* Mobile devices (768px and below) */
@media (max-width: 768px) {
    /* Prevent text overflow and word breaking */
    * {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Контейнеры не должны выходить за границы */
    .max-w-7xl,
    .max-w-6xl,
    .max-w-5xl,
    .max-w-4xl,
    .max-w-3xl {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
        box-sizing: border-box !important;
    }

    /* Hero section - smaller text */
    .hero-bg {
        background-attachment: scroll !important;
        min-height: 100vh;
        padding-top: 80px !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden !important;
    }

    /* Hero контейнер */
    .hero-bg > div {
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 16px !important;
        padding-right: 16px !important;
        box-sizing: border-box !important;
    }

    .hero-bg h1,
    h1.text-5xl,
    h1.md\\:text-7xl,
    h1.text-4xl,
    h1.md\\:text-6xl {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        margin-bottom: 1rem !important;
        padding: 0 !important;
        white-space: normal !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .hero-bg h1 span,
    .hero-bg h1 span.block {
        display: block !important;
        margin-bottom: 0.25rem !important;
        white-space: nowrap !important;
        word-break: keep-all !important;
        width: 100% !important;
        max-width: 100% !important;
        font-size: inherit !important;
        letter-spacing: normal !important;
    }

    /* Allow natural text wrapping but prevent breaking mid-word */
    .hero-bg h1 {
        text-align: center !important;
    }

    .hero-bg p,
    p.text-xl,
    p.md\\:text-2xl {
        font-size: 0.95rem !important;
        line-height: 1.6 !important;
        padding: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Контейнер кнопок */
    .hero-bg .flex,
    .flex.flex-col,
    .flex.sm\\:flex-row,
    .flex-col.sm\\:flex-row,
    #hero-buttons {
        flex-direction: column !important;
        width: 100% !important;
        max-width: 100% !important;
        gap: 0.75rem !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        align-items: stretch !important;
    }

    /* Кнопки на мобильном */
    a.btn-primary,
    a.border-2,
    button.btn-primary,
    .hero-bg a,
    #hero-buttons a {
        width: 100% !important;
        max-width: 100% !important;
        text-align: center !important;
        padding: 14px 20px !important;
        font-size: 0.95rem !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        display: block !important;
    }

    /* Navigation adjustments */
    nav h1 {
        font-size: 1.1rem !important;
    }

    nav span {
        font-size: 0.65rem !important;
    }

    nav .hidden.md\\:block {
        display: none !important;
    }

    /* Section headings */
    h2,
    h2.text-4xl,
    h2.md\\:text-5xl,
    h2.text-3xl,
    h2.md\\:text-4xl {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
        padding: 0 1rem;
        word-break: keep-all !important;
        hyphens: none !important;
    }

    /* Prevent breaking long words in headings */
    h2 br,
    h1 br {
        display: none !important;
    }

    h3,
    h3.text-xl,
    h3.text-2xl {
        font-size: 1.25rem !important;
        padding: 0 0.5rem;
    }

    /* Special handling for long service page heading */
    .hero-bg h1.text-5xl.md\\:text-6xl,
    h1.text-5xl.md\\:text-6xl {
        font-size: 1.6rem !important;
        line-height: 1.4 !important;
        word-spacing: -0.05em;
        letter-spacing: -0.02em;
        padding: 0 0.8rem !important;
    }

    /* Grid layouts - stack vertically */
    .grid.lg\\:grid-cols-2,
    .grid.md\\:grid-cols-2,
    .grid.grid-cols-2,
    .grid.md\\:grid-cols-3,
    .grid.grid-cols-1.md\\:grid-cols-3 {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Paragraphs - better readability */
    p {
        font-size: 1rem !important;
        line-height: 1.7 !important;
    }

    /* Padding adjustments */
    section {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    .py-20 {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    .py-16 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }

    .max-w-7xl,
    .max-w-6xl,
    .max-w-5xl,
    .max-w-4xl {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    .px-4,
    .sm\\:px-6,
    .lg\\:px-8 {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    /* Quote blocks */
    blockquote {
        font-size: 1.125rem !important;
        padding: 1rem !important;
        line-height: 1.6 !important;
    }

    /* Images - responsive */
    img {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Footer adjustments */
    footer {
        text-align: center;
    }

    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Chat button */
    #chat-button {
        bottom: 20px !important;
        right: 20px !important;
        width: 55px !important;
        height: 55px !important;
    }

    #chat-window {
        width: calc(100vw - 2rem) !important;
        height: calc(100vh - 4rem) !important;
        right: 1rem !important;
        bottom: 1rem !important;
        max-width: none !important;
    }

    /* Forms - full width inputs */
    input,
    textarea,
    select {
        width: 100% !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px !important;
    }

    button {
        padding: 14px 20px !important;
        font-size: 1rem !important;
    }

    /* Modal adjustments */
    .modal,
    [id$="-modal"],
    .fixed.inset-0 > div {
        margin: 1rem !important;
        max-width: calc(100% - 2rem) !important;
        width: calc(100% - 2rem) !important;
    }

    /* Calendar on mobile */
    .calendar {
        overflow-x: auto;
    }

    .time-slot {
        min-width: 70px;
        font-size: 0.875rem !important;
    }

    /* Cards - better spacing */
    .card,
    [class*="card"] {
        padding: 1.5rem !important;
        margin-bottom: 1rem;
    }

    /* Testimonials/Reviews */
    .testimonial,
    .review {
        padding: 1.5rem !important;
    }

    /* Fix slider arrows on mobile */
    .splide__arrow,
    .slider-arrow,
    [class*="arrow"] {
        width: 45px !important;
        height: 45px !important;
        background: rgba(184, 134, 11, 0.95) !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        opacity: 1 !important;
        z-index: 100 !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
        border: 2px solid white !important;
    }

    .splide__arrow--prev {
        left: -5px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    .splide__arrow--next {
        right: -5px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }

    .splide__arrow svg {
        width: 22px !important;
        height: 22px !important;
        fill: white !important;
    }

    /* Hide arrows when they overlap text */
    .splide__arrow:disabled {
        opacity: 0.3 !important;
    }

    /* Ensure slider is visible on mobile */
    .splide__track {
        overflow: visible !important;
        padding: 0 50px !important;
    }

    .splide__list {
        display: flex !important;
    }

    /* Testimonial card adjustments to avoid arrow overlap */
    .splide__slide {
        padding: 0 10px !important;
    }

    /* Services cards */
    .service-card {
        padding: 2rem 1.5rem !important;
    }

    /* Spacing utilities */
    .gap-8 {
        gap: 2rem !important;
    }

    .gap-12 {
        gap: 2rem !important;
    }

    .mb-16 {
        margin-bottom: 3rem !important;
    }

    .mb-12 {
        margin-bottom: 2rem !important;
    }

    /* Contact form sections */
    .contact-info {
        margin-bottom: 2rem;
    }

    /* Tables - make scrollable */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Small mobile devices (414px and below) - Most modern phones */
@media (max-width: 414px) {
    /* Строгие ограничения ширины */
    html, body {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .hero-bg h1,
    h1 {
        font-size: 1.5rem !important;
        padding: 0 !important;
        line-height: 1.35 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .hero-bg h1 span,
    .hero-bg h1 span.block {
        font-size: 1.5rem !important;
    }

    .hero-bg h1 span.text-gradient {
        font-size: 1.4rem !important;
    }

    .hero-bg p,
    p.text-xl {
        font-size: 0.9rem !important;
        padding: 0 !important;
        line-height: 1.5 !important;
    }

    h2 {
        font-size: 1.4rem !important;
        padding: 0 !important;
    }

    h3 {
        font-size: 1.1rem !important;
    }

    /* Контейнеры */
    .max-w-7xl,
    .max-w-6xl,
    .max-w-5xl,
    .max-w-4xl {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Кнопки */
    button,
    a.btn-primary,
    a.border-2,
    #hero-buttons a {
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Секция о психологе */
    section {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
}

/* Very small mobile devices (360px and below) - Samsung, older phones */
@media (max-width: 360px) {
    .hero-bg h1,
    h1 {
        font-size: 1.35rem !important;
        padding: 0 !important;
        line-height: 1.3 !important;
    }

    .hero-bg h1 span,
    .hero-bg h1 span.block {
        font-size: 1.35rem !important;
    }

    .hero-bg h1 span.text-gradient {
        font-size: 1.25rem !important;
    }

    .hero-bg p,
    p.text-xl {
        font-size: 0.85rem !important;
    }

    h2 {
        font-size: 1.3rem !important;
    }

    /* Ещё меньше отступы */
    .max-w-7xl,
    .max-w-6xl,
    .max-w-5xl,
    .max-w-4xl {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    a.btn-primary,
    a.border-2,
    button {
        padding: 10px 14px !important;
        font-size: 0.85rem !important;
    }
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific fixes */
    .hero-bg {
        min-height: -webkit-fill-available;
    }

    input,
    textarea,
    select {
        font-size: 16px !important; /* Prevents auto-zoom */
        -webkit-appearance: none;
        border-radius: 0;
    }

    /* Fix iOS button styling */
    button {
        -webkit-appearance: none;
        border-radius: inherit;
    }
}

/* Landscape mobile orientation */
@media (max-width: 768px) and (orientation: landscape) {
    .hero-bg {
        min-height: auto;
        padding-top: 100px;
        padding-bottom: 50px;
    }

    .hero-bg h1 {
        font-size: 2rem !important;
        margin-bottom: 1rem !important;
    }

    .hero-bg p {
        font-size: 0.9rem !important;
        margin-bottom: 1.5rem !important;
    }

    section {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Slightly reduce font sizes on high-res mobile screens */
    @media (max-width: 768px) {
        body {
            font-size: 15px;
        }
    }
}

/* Accessibility - respects user's reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support (if user's system is in dark mode) */
@media (prefers-color-scheme: dark) {
    /* Optional: can add dark mode adjustments here */
}

/* Print styles - if someone tries to print */
@media print {
    .hero-bg {
        background: white !important;
    }

    #chat-button,
    #chat-window,
    #intro-loader {
        display: none !important;
    }

    * {
        color: black !important;
        background: white !important;
    }
}
