/* Mobile Responsiveness Fixes for Real Devices */

/* Search Input Visibility Fix - CRITICAL */
input[type="search"],
input[type="text"]#blog-search,
.search-input,
form input[type="search"] {
    color: #ffffff !important;
    caret-color: #ffffff !important;
    background-color: rgba(22, 27, 34, 0.8) !important;
    /* Ensure background contrasts with text */
    -webkit-text-fill-color: #ffffff !important;
    /* Force webkit to paint text white */
    opacity: 1 !important;
}

input[type="search"]::placeholder,
input[type="text"]#blog-search::placeholder,
.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
    opacity: 1 !important;
}

/* Ensure proper viewport scaling */
:root {
    font-size: 16px;
    /* Base size for mobile */
}

/* Mobile-specific font scaling */
@media screen and (max-width: 768px) {

    /* Increase base font size for better readability */
    html {
        font-size: 16px !important;
        -webkit-text-size-adjust: 100%;
        -moz-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }

    body {
        font-size: 1rem;
        /* 16px */
        line-height: 1.6;
    }

    /* Headings - More readable on mobile */
    h1 {
        font-size: clamp(1.75rem, 5vw, 2.5rem) !important;
        line-height: 1.2;
    }

    h2 {
        font-size: clamp(1.5rem, 4vw, 2rem) !important;
        line-height: 1.3;
    }

    h3 {
        font-size: clamp(1.25rem, 3.5vw, 1.5rem) !important;
        line-height: 1.4;
    }

    h4 {
        font-size: clamp(1.125rem, 3vw, 1.25rem) !important;
    }

    h5,
    h6 {
        font-size: clamp(1rem, 2.5vw, 1.125rem) !important;
    }

    /* Paragraphs and text content */
    p,
    li,
    span,
    a,
    div {
        font-size: clamp(0.9375rem, 2.5vw, 1rem) !important;
        line-height: 1.6;
    }

    /* Small text (copyright, labels, etc) - Still readable */
    .text-xs,
    small {
        font-size: clamp(0.8125rem, 2vw, 0.875rem) !important;
    }

    .text-sm {
        font-size: clamp(0.875rem, 2.25vw, 0.9375rem) !important;
    }

    /* Buttons - Larger tap targets */
    button,
    .btn,
    a.btn {
        font-size: clamp(0.9375rem, 2.5vw, 1rem) !important;
        padding: 0.75rem 1.5rem !important;
        min-height: 44px;
        /* Apple's recommended minimum */
    }

    /* Input fields - Better mobile UX */
    input,
    textarea,
    select {
        font-size: 16px !important;
        /* Prevents zoom on iOS */
        padding: 0.75rem !important;
        min-height: 44px;
    }

    /* Header Fixes - Scale down logo and re-organize */
    header .max-w-7xl {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        padding: 0.75rem 1rem !important;
    }

    header a.flex.items-center {
        width: 100% !important;
        justify-content: center !important;
        margin-bottom: 0.25rem !important;
    }

    header img {
        height: clamp(24px, 5vw, 28px) !important;
        width: auto !important;
    }

    header span.text-xl {
        font-size: 1.125rem !important;
    }

    header button#open-menu {
        position: absolute !important;
        right: 1rem !important;
        top: 0.75rem !important;
        padding: 0.25rem !important;
    }

    /* Ensure blog content doesn't get blocked by fixed header if needed */
    main {
        padding-top: 0 !important;
    }
}

/* Widget positioning for mobile */
@media screen and (max-width: 768px) {

    /* Reposition widgets to avoid overlap: WhatsApp/Mail LEFT, Chatbot RIGHT */
    #floating-widgets {
        bottom: 2rem !important;
        left: 1rem !important;
        /* Move to LEFT */
        right: auto !important;
        gap: 0.75rem !important;
        z-index: 99 !important;
    }

    .floating-widget {
        width: 50px !important;
        height: 50px !important;
    }

    /* Chatbot widget - Keep RIGHT */
    #chatbot-widget {
        bottom: 1.5rem !important;
        right: 1rem !important;
        left: auto !important;
        z-index: 100 !important;
    }

    #chatbot-toggle {
        width: 56px !important;
        height: 56px !important;
    }

    #chatbot-window {
        width: calc(100vw - 2rem) !important;
        max-width: 350px !important;
        height: 70vh !important;
        max-height: 500px !important;
        bottom: 5rem !important;
        right: 0.5rem !important;
    }

    /* Chatbot message text */
    .cb-message {
        font-size: 0.9375rem !important;
    }

    .cb-input {
        font-size: 16px !important;
        /* Prevent zoom */
    }
}

/* Blog-specific mobile fixes */
@media screen and (max-width: 768px) {

    /* Blog grid */
    .blog-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
        padding: 1rem !important;
    }

    /* Blog post content */
    .blog-content {
        padding: 1.25rem !important;
    }

    .blog-content h1 {
        font-size: clamp(1.75rem, 5vw, 2.25rem) !important;
        margin-bottom: 1rem !important;
    }

    .blog-content h2 {
        font-size: clamp(1.375rem, 4vw, 1.75rem) !important;
        margin-top: 1.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    .blog-content p {
        font-size: clamp(0.9375rem, 2.5vw, 1.0625rem) !important;
        line-height: 1.7 !important;
        margin-bottom: 1rem !important;
    }

    .blog-content li {
        font-size: clamp(0.9375rem, 2.5vw, 1rem) !important;
        line-height: 1.6 !important;
        margin-bottom: 0.5rem !important;
    }

    /* Blog excerpt */
    .blog-excerpt {
        font-size: clamp(0.875rem, 2.25vw, 0.9375rem) !important;
        line-height: 1.6 !important;
    }
}

/* Table responsiveness */
@media screen and (max-width: 768px) {
    table {
        font-size: 0.875rem !important;
    }

    th,
    td {
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }
}

/* Footer mobile fixes */
@media screen and (max-width: 768px) {
    footer {
        padding: 2rem 1rem !important;
    }

    footer h3 {
        font-size: clamp(0.875rem, 2.5vw, 1rem) !important;
    }

    footer a,
    footer p {
        font-size: clamp(0.8125rem, 2.25vw, 0.9375rem) !important;
    }

    footer .grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: center !important;
    }

    footer .grid>div {
        align-items: center !important;
        display: flex !important;
        flex-direction: column !important;
    }
}

/* Ensure images don't break layout */
@media screen and (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto !important;
    }
}