/* =================================================================
   AAPE TECHNOLOGIES — MOBILE FIXES
   Applied LAST in both layouts so it wins the cascade.
   Covers: typography, spacing, section geometry, nav, admin UX.
   Does NOT change colour theme, layout structure, or branding.
   ================================================================= */

/* ================================================================
   0. UNIVERSAL MOBILE RESETS
   Prevent any overflow or text from escaping its container
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; }

@media (max-width: 1024px) {
    html, body { overflow-x: hidden; max-width: 100vw; }

    /* Prevent runaway wide elements */
    img, video, iframe, canvas, svg {
        max-width: 100%;
        height: auto;
    }

    /* Kill rogue horizontal scroll from inline widths */
    [style*="width:"] {
        max-width: 100% !important;
    }

    /* Word-wrap everywhere */
    p, h1, h2, h3, h4, h5, h6, li, td, th, span, a, label {
        overflow-wrap: break-word;
        word-break: break-word;
    }
}

/* ================================================================
   1. TYPOGRAPHY SCALE — Mobile-first fluid sizing
   Prevents text from being too large or too small on phones
   ================================================================ */
@media (max-width: 768px) {
    h1, .h1 { font-size: clamp(1.5rem, 6vw, 2.2rem) !important; line-height: 1.22 !important; margin-bottom: 0.75rem !important; }
    h2, .h2 { font-size: clamp(1.25rem, 5vw, 1.75rem) !important; line-height: 1.28 !important; margin-bottom: 0.65rem !important; }
    h3, .h3 { font-size: clamp(1.05rem, 4vw, 1.35rem) !important; line-height: 1.35 !important; margin-bottom: 0.55rem !important; }
    h4, .h4 { font-size: 1rem !important; line-height: 1.4 !important; }
    h5, .h5 { font-size: 0.92rem !important; }

    p       { font-size: 0.92rem !important; line-height: 1.7 !important; margin-bottom: 1rem !important; }
    li      { font-size: 0.92rem; line-height: 1.65; }

    /* Section label / eyebrow text */
    .section-label,
    [class*="section-label"],
    [class*="eyebrow"]        { font-size: 0.7rem !important; letter-spacing: 0.1em !important; }

    /* Stat / counter numbers on public pages */
    .stat-number,
    [class*="stat-num"],
    .counter-number            { font-size: clamp(1.6rem, 5vw, 2.4rem) !important; }
}

@media (max-width: 480px) {
    h1, .h1 { font-size: clamp(1.35rem, 7vw, 1.8rem) !important; }
    h2, .h2 { font-size: clamp(1.1rem, 5.5vw, 1.5rem) !important; }
    h3, .h3 { font-size: 1rem !important; }

    p       { font-size: 0.88rem !important; }
    li      { font-size: 0.88rem; }
}

/* ================================================================
   2. SECTION PADDING — tighter on phones, no giant top/bottom gaps
   ================================================================ */
@media (max-width: 768px) {
    .section               { padding: 3rem 0 !important; }
    .section-sm            { padding: 1.75rem 0 !important; }
    .container             { padding-left: 1rem !important; padding-right: 1rem !important; }
    .container-sm          { padding-left: 1rem !important; padding-right: 1rem !important; }

    /* Fix hero over-padding injected as inline styles */
    section[style*="padding:"] {
        padding-top:    4rem !important;
        padding-bottom: 2.5rem !important;
    }
    section[style*="padding: "] {
        padding-top:    4rem !important;
        padding-bottom: 2.5rem !important;
    }

    /* Named hero block */
    #hero-section {
        padding-top:    5rem !important;
        padding-bottom: 3rem !important;
        min-height: 70vh !important;
    }

    /* Prevent sections inside hero from overflowing their bounds */
    #hero-section * { max-width: 100%; }
}

@media (max-width: 480px) {
    .section    { padding: 2.25rem 0 !important; }
    .section-sm { padding: 1.25rem 0 !important; }
    .container  { padding-left: 0.85rem !important; padding-right: 0.85rem !important; }

    #hero-section { padding-top: 4.5rem !important; min-height: 65vh !important; }
}

/* ================================================================
   3. GEOMETRY — Fix oval shapes: force perfect aspect-ratio circles
   ================================================================ */

/* Any element using border-radius:50% must have equal w/h.
   We enforce this via aspect-ratio and min dimensions. */
@media (max-width: 1024px) {

    /* Icon boxes / avatar circles */
    [style*="border-radius:50%"],
    [style*="border-radius: 50%"] {
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0 !important;
    }

    /* Named circle classes */
    .icon-box,
    .icon-circle,
    .avatar,
    .avatar-circle,
    .step-number,
    .process-icon,
    .team-avatar,
    .stat-icon,
    .feature-icon-box,
    .service-icon-box,
    .testimonial-avatar,
    .review-avatar,
    .client-avatar,
    [class*="-icon"][class*="circle"],
    [class*="icon"][class*="-circle"],
    [class*="avatar"],
    [class*="-badge"][class*="round"] {
        aspect-ratio: 1 / 1 !important;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Force correct sizing for small icon circles */
    .icon-box,
    .icon-circle    { width: 3rem !important; height: 3rem !important; min-width: 3rem !important; min-height: 3rem !important; }
    .step-number    { width: 2.5rem !important; height: 2.5rem !important; min-width: 2.5rem !important; min-height: 2.5rem !important; font-size: 1rem !important; }
    .user-avatar    { width: 2rem !important; height: 2rem !important; min-width: 2rem !important; min-height: 2rem !important; }
}

@media (max-width: 768px) {
    /* Slightly smaller icon boxes on real phones */
    .icon-box,
    .icon-circle    { width: 2.75rem !important; height: 2.75rem !important; min-width: 2.75rem !important; min-height: 2.75rem !important; }

    /* Card images inside rounded containers — maintain ratio */
    .card-img,
    .portfolio-img,
    .team-img,
    .blog-img,
    .service-img {
        width: 100% !important;
        height: auto !important;
        object-fit: cover;
        display: block;
    }
}

/* ================================================================
   4. GRID OVERFLOW PREVENTION
   Stop items from bleeding outside grid containers
   ================================================================ */
@media (max-width: 768px) {
    /* Any CSS grid with explicit column counts → single column */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Allow two columns only for very small cards */
    .grid-cols-2.allow-2col-mobile {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Process / step grids */
    .process-grid,
    [class*="process-grid"],
    .steps-grid,
    [class*="steps-grid"] {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }

    /* Flex rows → column */
    .flex-row-mobile-col {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Two-col service/feature grid items */
    .service-card,
    .feature-card,
    .pricing-card {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }

    /* Stat / info strip — 2 columns on mobile */
    .stat-strip,
    .stats-row,
    [class*="stat-row"] {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
}

@media (max-width: 480px) {
    .grid-cols-2   { grid-template-columns: 1fr !important; }
    .stat-strip,
    .stats-row     { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ================================================================
   5. TEXT OVERLAP FIX — stacking & z-index corrections
   ================================================================ */
@media (max-width: 768px) {

    /* Absolute-positioned text layers inside hero/section */
    .hero-text,
    .hero-content,
    [class*="hero-"] > * {
        position: relative !important;
        z-index: 2 !important;
    }

    /* Gradient / background overlays must sit behind text */
    .hero-bg,
    .section-bg,
    .hero-overlay,
    [class*="-overlay"],
    [class*="-bg-layer"] {
        z-index: 0 !important;
    }

    /* Cards with absolute badges / labels */
    .card,
    .service-card,
    .portfolio-card,
    .pricing-card,
    .team-card,
    .blog-card {
        overflow: hidden !important;
        position: relative !important;
    }

    /* Badge positioned inside cards — keep inside */
    .card-badge,
    .status-badge,
    .price-badge,
    [class*="card-badge"],
    [class*="-pill"][style*="position:absolute"],
    [class*="-pill"][style*="position: absolute"] {
        max-width: calc(100% - 1.5rem) !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Prevent hero headings from going behind nav */
    main { padding-top: 70px !important; }
}

/* ================================================================
   6. PUBLIC SITE — MOBILE NAVIGATION (modern compact redesign)
   Replaces the legacy wide/tall mobile menu with a sleek bottom sheet
   ================================================================ */

/* ── Base hamburger button style (no inline style on the element) ── */
.mobile-menu-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Pill navbar shrinks cleanly on mobile ──────────────────────── */
@media (max-width: 992px) {
    .navbar-wrapper {
        padding: 0.75rem 0 !important;
    }

    .navbar-pill {
        width: calc(100% - 2rem) !important;
        max-width: 480px !important;
        padding: 0.55rem 1.1rem !important;
        gap: 0 !important;
        justify-content: space-between !important;
        border-radius: 40px !important;
    }

    /* Logo in pill — slightly smaller */
    .navbar-pill .site-logo img {
        height: 32px !important;
    }

    /* Hamburger button — compact and modern */
    .mobile-menu-btn {
        width: 34px !important;
        height: 34px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: rgba(255,255,255,0.08) !important;
        transition: background 0.2s ease !important;
        flex-shrink: 0 !important;
    }
    .mobile-menu-btn:hover,
    .mobile-menu-btn:active {
        background: rgba(255,255,255,0.16) !important;
    }
    #menu-icon { font-size: 1rem !important; }
}

/* ── Mobile nav menu — compact bottom-sheet style ───────────────── */
@media (max-width: 992px) {
    .nav-links {
        /* Bottom sheet from top, not full-screen panic */
        position: fixed !important;
        top: 72px !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(-12px) !important;
        width: calc(100% - 2rem) !important;
        max-width: 480px !important;

        /* Clean card look */
        background: rgba(10, 10, 10, 0.97) !important;
        backdrop-filter: blur(24px) !important;
        -webkit-backdrop-filter: blur(24px) !important;
        border-radius: 20px !important;
        border: 1px solid rgba(255,255,255,0.07) !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.6) !important;

        /* Internal spacing — compact */
        padding: 0.75rem !important;
        gap: 0 !important;

        /* Animation from closed */
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.25s ease, transform 0.28s cubic-bezier(0.4,0,0.2,1), visibility 0.25s !important;
        display: flex !important;
        flex-direction: column !important;
        z-index: 1002 !important;
    }

    .nav-links.open {
        transform: translateX(-50%) translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Nav links inside the dropdown — row style with icon support */
    .nav-links .nav-link {
        padding: 0.7rem 0.9rem !important;
        border-radius: 10px !important;
        border-bottom: none !important;
        font-size: 0.9rem !important;
        font-weight: 500 !important;
        color: rgba(255,255,255,0.88) !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        transition: background 0.15s ease, color 0.15s ease !important;
        margin-bottom: 1px !important;
    }

    .nav-links .nav-link:hover,
    .nav-links .nav-link:active {
        background: rgba(255,255,255,0.06) !important;
        color: #fff !important;
    }

    .nav-links .nav-link.active {
        color: var(--accent) !important;
        background: rgba(244,197,0,0.08) !important;
    }

    /* Dropdown wrapper */
    .nav-links .nav-dropdown {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    /* Sub-items inside accordion */
    .nav-dropdown-menu {
        border-top: none !important;
        padding-left: 0.5rem !important;
        padding-top: 0.25rem !important;
        padding-bottom: 0.25rem !important;
        gap: 0 !important;
    }

    .nav-dropdown-menu a {
        font-size: 0.85rem !important;
        padding: 0.55rem 0.9rem !important;
        border-radius: 8px !important;
        display: block !important;
        color: rgba(255,255,255,0.62) !important;
        transition: background 0.15s, color 0.15s !important;
        border-bottom: none !important;
    }

    .nav-dropdown-menu a:hover {
        background: rgba(255,255,255,0.05) !important;
        color: var(--accent) !important;
        padding-left: 1.1rem !important;
    }

    /* Active sub-nav link */
    .nav-dropdown-menu a.active-sub {
        color: var(--accent) !important;
        font-weight: 600 !important;
    }

    /* Divider between main links and sub-items */
    .nav-links .nav-dropdown {
        border-bottom: 1px solid rgba(255,255,255,0.04) !important;
        padding-bottom: 0.25rem !important;
        margin-bottom: 0.25rem !important;
    }

    .nav-links .nav-link:last-child,
    .nav-links > a:last-child {
        border-bottom: none !important;
        margin-bottom: 0 !important;
    }

    /* Overlay — lighter, doesn't block reading */
    .mobile-menu-overlay {
        background: rgba(0,0,0,0.4) !important;
        backdrop-filter: blur(2px) !important;
        -webkit-backdrop-filter: blur(2px) !important;
    }
}

/* Light mode nav adjustments */
@media (max-width: 992px) {
    [data-theme="light"] .nav-links {
        background: rgba(255,255,255,0.98) !important;
        border-color: rgba(0,0,0,0.07) !important;
        box-shadow: 0 20px 60px rgba(0,0,0,0.12) !important;
    }
    [data-theme="light"] .nav-links .nav-link {
        color: #1a1a1a !important;
    }
    [data-theme="light"] .nav-links .nav-link:hover {
        background: rgba(0,0,0,0.04) !important;
        color: #000 !important;
    }
    [data-theme="light"] .nav-links .nav-link.active {
        color: var(--accent) !important;
        background: rgba(244,197,0,0.07) !important;
    }
    [data-theme="light"] .nav-dropdown-menu a {
        color: rgba(0,0,0,0.55) !important;
    }
    [data-theme="light"] .nav-dropdown-menu a:hover {
        color: var(--accent) !important;
        background: rgba(0,0,0,0.04) !important;
    }
    [data-theme="light"] .nav-links .nav-dropdown {
        border-bottom-color: rgba(0,0,0,0.06) !important;
    }
    [data-theme="light"] .mobile-menu-btn {
        background: rgba(0,0,0,0.07) !important;
    }
    [data-theme="light"] #menu-icon {
        color: #1a1a1a !important;
    }
}

/* ================================================================
   7. PUBLIC SITE — FOOTER MOBILE
   ================================================================ */
@media (max-width: 768px) {
    .footer {
        padding: 2.5rem 0 1.5rem !important;
    }

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

    /* Brand column full width */
    .footer-grid > div:first-child {
        grid-column: 1 / -1 !important;
        text-align: center !important;
    }

    .footer-grid > div:first-child img { margin: 0 auto 1rem !important; display: block !important; }
    .footer-grid > div:first-child p   { font-size: 0.84rem !important; max-width: 320px !important; margin: 0 auto 1rem !important; }
    .footer-social                     { justify-content: center !important; gap: 0.6rem !important; }

    /* Contact / last column full width */
    .footer-grid > div:last-child {
        grid-column: 1 / -1 !important;
    }

    .footer-title { font-size: 0.72rem !important; margin-bottom: 0.65rem !important; }
    .footer-link  { font-size: 0.83rem !important; padding: 0.2rem 0 !important; }
    .footer-links { gap: 0.35rem !important; }

    .footer-bottom {
        flex-direction: column !important;
        text-align: center !important;
        gap: 0.6rem !important;
        padding-top: 1rem !important;
    }

    .footer-bottom .footer-link { font-size: 0.78rem !important; }
}

@media (max-width: 480px) {
    .footer-grid { grid-template-columns: 1fr !important; }
    .footer-grid > div { text-align: center !important; }

    /* Quick Links: wrap inline so links flow side-by-side */
    .footer-grid > div:nth-child(2) .footer-links {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 0.3rem 0.75rem !important;
    }

    .footer-grid > div:nth-child(2) .footer-link {
        display: inline-block !important;
        padding: 0.15rem 0 !important;
        white-space: nowrap !important;
    }
}

/* ================================================================
   8. FAB BUTTONS — compact on mobile
   ================================================================ */
@media (max-width: 768px) {
    /* WhatsApp pill → circle */
    .fab-whatsapp {
        bottom: 1.25rem !important;
        left: 1.25rem !important;
        padding: 0.75rem !important;
        border-radius: 50% !important;
        gap: 0 !important;
    }
    .fab-whatsapp span { display: none !important; }
    .fab-whatsapp i    { font-size: 1.3rem !important; margin: 0 !important; }

    /* Feedback tab — smaller */
    .fab-feedback {
        padding: 0.85rem 0.4rem !important;
        font-size: 0 !important;
        letter-spacing: 0 !important;
    }
    .fab-feedback i { font-size: 0.9rem !important; }
}

/* ================================================================
   9. FILTER TABS — horizontal scroll strip (public site)
   ================================================================ */
@media (max-width: 768px) {
    #portfolio-filters,
    #trend-filters,
    .filter-tabs,
    .filter-strip,
    [class*="filter-row"],
    [class*="tab-row"] {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        gap: 0.4rem !important;
        padding-bottom: 0.5rem !important;
        justify-content: flex-start !important;
    }

    #portfolio-filters::-webkit-scrollbar,
    #trend-filters::-webkit-scrollbar,
    .filter-tabs::-webkit-scrollbar,
    .filter-strip::-webkit-scrollbar { display: none !important; }

    .filter-btn,
    .filter-pill {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        font-size: 0.8rem !important;
        padding: 0.4rem 0.9rem !important;
        min-height: 36px !important;
    }
}

/* ================================================================
   10. PROCESS / INDUSTRY TABS (public service pages)
   ================================================================ */
@media (max-width: 768px) {
    .process-layout {
        flex-direction: column !important;
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    /* Tab list becomes horizontal scroll strip */
    .process-tabs {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        gap: 0.4rem !important;
        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 0.4rem !important;
        flex-wrap: nowrap !important;
    }
    .process-tabs::-webkit-scrollbar { display: none !important; }

    .process-tab {
        flex-shrink: 0 !important;
        min-width: 130px !important;
        max-width: 160px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        padding: 0.55rem 0.85rem !important;
        font-size: 0.82rem !important;
        border-radius: 8px !important;
    }

    /* Content panel */
    .process-content-wrapper {
        padding: 1.25rem 1rem !important;
        position: static !important;
        top: auto !important;
        max-height: none !important;
        border-radius: 14px !important;
    }

    .content-title  { font-size: 1.15rem !important; }
    .content-desc   { font-size: 0.88rem !important; }
}

/* ================================================================
   11. FEEDBACK MODAL — slide up from bottom on mobile
   ================================================================ */
@media (max-width: 768px) {
    .feedback-modal-backdrop {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .feedback-modal {
        border-radius: 20px 20px 0 0 !important;
        padding: 1.75rem 1.25rem !important;
        max-width: 100% !important;
        width: 100% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }
}

/* ================================================================
   12. FORMS (public site) — better mobile sizing
   ================================================================ */
@media (max-width: 768px) {
    .form-control,
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important; /* prevent iOS zoom */
        min-height: 48px !important;
        padding: 0.75rem 1rem !important;
        border-radius: 10px !important;
    }

    textarea { min-height: 110px !important; height: auto !important; }

    .form-label { font-size: 0.88rem !important; margin-bottom: 0.5rem !important; }
    .form-group { margin-bottom: 1.25rem !important; }

    /* Button full-width on small screens */
    .btn-primary,
    .btn-secondary,
    [type="submit"] {
        min-height: 50px !important;
        font-size: 0.95rem !important;
        padding: 0.85rem 1.5rem !important;
        border-radius: 12px !important;
    }
}

/* ================================================================
   13. BUTTONS (public) — proper sizing & touch targets
   ================================================================ */
@media (max-width: 768px) {
    .btn {
        min-height: 46px !important;
        padding: 0.7rem 1.35rem !important;
        font-size: 0.88rem !important;
        border-radius: 12px !important;
        display: inline-flex !important;
        align-items: center !important;
        gap: 0.45rem !important;
    }

    /* Two-button side-by-side groups → stack */
    .btn-group:not(.btn-group--inline),
    .cta-buttons,
    .hero-buttons {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }

    .btn-group:not(.btn-group--inline) .btn,
    .cta-buttons .btn,
    .hero-buttons .btn {
        width: 100% !important;
        justify-content: center !important;
    }
}

/* ================================================================
   14. CARDS (public) — consistent internal padding on mobile
   ================================================================ */
@media (max-width: 768px) {
    .card,
    .service-card,
    .feature-card,
    .team-card,
    .blog-card,
    .pricing-card,
    .portfolio-card {
        padding: 1.25rem !important;
        border-radius: 14px !important;
    }

    /* Card icon — consistent circle on mobile */
    .card-icon,
    .service-card-icon,
    .feature-card-icon {
        width: 2.75rem !important;
        height: 2.75rem !important;
        min-width: 2.75rem !important;
        border-radius: 50% !important;
        font-size: 1rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .card-title,
    .service-card h3,
    .feature-card h3 {
        font-size: 1rem !important;
        line-height: 1.35 !important;
    }

    .card-desc,
    .service-card p,
    .feature-card p {
        font-size: 0.86rem !important;
        line-height: 1.65 !important;
    }
}

/* ================================================================
   15. MARQUEE / LOGO STRIP — correct height on mobile
   ================================================================ */
@media (max-width: 768px) {
    .marquee-logo {
        height: 36px !important;
        max-width: 100px !important;
    }
    .logo-marquee { padding: 1rem 0 !important; }
    .marquee-content { gap: 2.5rem !important; }
}

/* ================================================================
   16. ADMIN PANEL — MOBILE REFINEMENTS
   ================================================================ */

/* ── Admin typography ────────────────────────────────────────────── */
@media (max-width: 767px) {
    /* Page header */
    .page-title-bar h1    { font-size: 1.05rem !important; font-weight: 700 !important; line-height: 1.3 !important; }
    .page-title-bar p     { font-size: 0.8rem !important; margin-top: 0.2rem !important; }

    /* Admin cards */
    .admin-card-title     { font-size: 0.85rem !important; }
    .admin-stat-number    { font-size: 1.4rem !important; }
    .admin-stat-label     { font-size: 0.68rem !important; }

    /* Table text */
    .table,
    .admin-table          { font-size: 0.8rem !important; }
    .table th             { font-size: 0.65rem !important; padding: 0.65rem 0.75rem !important; }
    .table td             { padding: 0.7rem 0.75rem !important; font-size: 0.8rem !important; }
}

@media (max-width: 480px) {
    .page-title-bar h1 { font-size: 0.97rem !important; }
    .admin-stat-number { font-size: 1.25rem !important; }
}

/* ── Admin stat cards — 2 col on all phones ──────────────────────── */
@media (max-width: 767px) {
    .stat-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.65rem !important;
    }

    .admin-stat-card,
    .stat-card {
        padding: 0.9rem !important;
        border-radius: 12px !important;
    }

    /* Stat icon — perfect circle */
    .stat-icon,
    .admin-stat-icon {
        width: 2rem !important;
        height: 2rem !important;
        min-width: 2rem !important;
        border-radius: 50% !important;
        aspect-ratio: 1/1 !important;
        font-size: 0.82rem !important;
    }
}

/* ── Admin cards — tighter padding on mobile ─────────────────────── */
@media (max-width: 767px) {
    .admin-card {
        padding: 1rem 0.9rem !important;
        border-radius: 12px !important;
        margin-bottom: 0.75rem !important;
    }

    .admin-card-header {
        padding: 0.75rem 0.9rem !important;
    }

    .admin-card-body {
        padding: 0.9rem !important;
    }
}

/* ── Admin bottom nav — modern pill icons ────────────────────────── */
@media (max-width: 1024px) {
    .mobile-bottom-nav {
        height: 58px !important;
        padding: 0 0.25rem !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }

    .bn-item {
        gap: 0.2rem !important;
        padding: 0.3rem 0.15rem 0.25rem !important;
        font-size: 0.58rem !important;
        font-weight: 600 !important;
        letter-spacing: 0.01em !important;
        border-radius: 10px !important;
        transition: color 0.15s ease, background 0.15s ease !important;
    }

    .bn-item i {
        font-size: 1.05rem !important;
        display: block !important;
    }

    .bn-item.active {
        color: var(--accent) !important;
    }

    /* Active indicator dot above icon */
    .bn-item.active::before {
        content: '';
        display: block;
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background: var(--accent);
        margin: 0 auto -2px;
        position: absolute;
        top: 4px;
        left: 50%;
        transform: translateX(-50%);
    }

    .bn-item { position: relative !important; }
}

@media (max-width: 480px) {
    .bn-item       { font-size: 0.54rem !important; }
    .bn-item i     { font-size: 0.95rem !important; }
    .mobile-bottom-nav { height: 54px !important; }
}

/* Light mode bottom nav */
@media (max-width: 1024px) {
    [data-theme="light"] .bn-item.active {
        color: #111111 !important;
    }
    [data-theme="light"] .bn-item.active::before {
        background: #111111 !important;
    }
}

/* ── Admin topbar — clean and tight ─────────────────────────────── */
@media (max-width: 767px) {
    .admin-topbar {
        height: 50px !important;
        padding: 0 0.75rem !important;
        gap: 0.5rem !important;
    }

    .topbar-left {
        display: flex !important;
        align-items: center !important;
        gap: 0.55rem !important;
        min-width: 0 !important;
        flex: 1 !important;
    }

    .topbar-title {
        font-size: 0.82rem !important;
        font-weight: 600 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 120px !important;
        flex: 1 !important;
    }

    .topbar-actions {
        display: flex !important;
        align-items: center !important;
        gap: 0.35rem !important;
        flex-shrink: 0 !important;
    }

    .topbar-btn {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        border-radius: 50% !important;
        font-size: 0.82rem !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .topbar-user {
        padding: 0.28rem !important;
        border-radius: 50% !important;
    }

    .user-avatar {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        border-radius: 50% !important;
        font-size: 0.7rem !important;
    }
}

@media (max-width: 480px) {
    .admin-mobile-toggle { font-size: 1.05rem !important; }
    .topbar-title { max-width: 95px !important; font-size: 0.78rem !important; }
    .topbar-btn { width: 32px !important; height: 32px !important; min-width: 32px !important; }
}

/* ── Admin page title bar ─────────────────────────────────────────── */
@media (max-width: 767px) {
    .page-title-bar {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        margin-bottom: 1.1rem !important;
    }

    .page-title-bar .ptb-actions {
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    .page-title-bar .ptb-actions .btn-admin {
        flex: 1 !important;
        min-width: 0 !important;
        justify-content: center !important;
        font-size: 0.8rem !important;
        padding: 0.6rem 0.75rem !important;
    }
}

/* ── Admin filter pills — horizontal scroll ───────────────────────── */
@media (max-width: 767px) {
    .filter-pills-wrap {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        gap: 0.4rem !important;
        padding-bottom: 0.4rem !important;
        margin-bottom: 1rem !important;
    }
    .filter-pills-wrap::-webkit-scrollbar { display: none !important; }
    .filter-pills-wrap .filter-pill {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        font-size: 0.76rem !important;
        padding: 0.38rem 0.8rem !important;
        min-height: 32px !important;
    }
}

/* ── Admin tables → data cards on mobile ─────────────────────────── */
@media (max-width: 640px) {
    /* Hide scrollbar hint — replaced by card view */
    .table-responsive::before { display: none !important; }

    /* Min table width so horizontal scroll still works cleanly */
    .table-responsive .table,
    .table-responsive .admin-table {
        min-width: 520px !important;
    }

    /* Shrink action buttons inside table cells */
    .table .btn-admin,
    .admin-table .btn-admin {
        padding: 0.35rem 0.65rem !important;
        font-size: 0.75rem !important;
        min-height: 34px !important;
    }
}

/* ── Admin responsive tabs ────────────────────────────────────────── */
@media (max-width: 767px) {
    .resp-tabs {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        scrollbar-width: none !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 0 !important;
        gap: 0 !important;
    }
    .resp-tabs::-webkit-scrollbar { display: none !important; }

    .resp-tab {
        padding: 0.5rem 0.9rem !important;
        font-size: 0.76rem !important;
        flex-shrink: 0 !important;
        white-space: nowrap !important;
        min-height: 38px !important;
    }

    /* Full tabs-to-accordion switch */
    .tabs-header {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        scrollbar-width: none !important;
    }
    .tabs-header::-webkit-scrollbar { display: none !important; }
    .tab-button {
        flex-shrink: 0 !important;
        font-size: 0.8rem !important;
        padding: 0.65rem 1rem !important;
        white-space: nowrap !important;
    }
}

/* ── Admin forms — mobile-friendly inputs ─────────────────────────── */
@media (max-width: 767px) {
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    .admin-card .form-control,
    .admin-content .form-control {
        font-size: 16px !important; /* stops iOS zoom on focus */
        min-height: 44px !important;
        padding: 0.7rem 0.85rem !important;
    }

    .admin-content select.form-control { min-height: 44px !important; }

    .admin-content textarea.form-control {
        min-height: 100px !important;
        font-size: 0.88rem !important;
    }

    .admin-content .form-label {
        font-size: 0.82rem !important;
        margin-bottom: 0.45rem !important;
    }

    .admin-content .form-group { margin-bottom: 1.1rem !important; }

    .btn-admin {
        min-height: 42px !important;
        font-size: 0.82rem !important;
        padding: 0.6rem 1rem !important;
        border-radius: var(--radius-sm) !important;
        gap: 0.4rem !important;
    }
}

@media (max-width: 480px) {
    .btn-admin {
        min-height: 44px !important;
        font-size: 0.82rem !important;
    }
    .btn-admin-primary,
    [type="submit"].btn-admin {
        min-height: 48px !important;
        font-size: 0.88rem !important;
    }
}

/* ── Admin sidebar — tighter on mobile ───────────────────────────── */
@media (max-width: 767px) {
    .admin-sidebar {
        width: 82vw !important;
        max-width: 300px !important;
    }

    .admin-nav-link {
        padding: 0.65rem 0.85rem !important;
        font-size: 0.84rem !important;
        min-height: 42px !important;
        border-radius: 8px !important;
    }

    .admin-nav-link i {
        font-size: 0.92rem !important;
        width: 20px !important;
    }

    .admin-nav-link span {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .nav-group-toggle {
        font-size: 0.63rem !important;
        padding: 0.45rem 0.55rem 0.3rem !important;
        min-height: 34px !important;
    }

    .sidebar-logo-area {
        padding: 0.85rem 0.85rem 0.65rem !important;
    }

    .sidebar-logo-area img {
        max-height: 32px !important;
    }
}

/* ── Admin confirm dialog — slide-up on mobile ────────────────────── */
@media (max-width: 767px) {
    #aape-confirm-overlay {
        align-items: flex-end !important;
    }

    #aape-confirm-box {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 1.75rem 1.25rem !important;
        margin: 0 !important;
    }
}

/* ── Admin modal slide-up ─────────────────────────────────────────── */
@media (max-width: 767px) {
    .modal-fullmobile {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        margin: auto 0 0 !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
    }
}

/* ── Admin content area padding ───────────────────────────────────── */
@media (max-width: 767px) {
    .admin-content {
        padding: 1rem 0.85rem !important;
        padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 1rem) !important;
        overflow-x: hidden !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
}

@media (max-width: 480px) {
    .admin-content {
        padding: 0.85rem 0.7rem !important;
        padding-bottom: calc(54px + env(safe-area-inset-bottom, 0px) + 0.85rem) !important;
    }
}

/* ── Quick actions grid ───────────────────────────────────────────── */
@media (max-width: 480px) {
    .quick-actions {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.5rem !important;
    }

    .quick-actions a,
    .quick-actions button {
        padding: 0.6rem 0.25rem !important;
        font-size: 0.7rem !important;
        border-radius: 10px !important;
    }

    .quick-actions i {
        font-size: 1.1rem !important;
        display: block !important;
        margin-bottom: 0.3rem !important;
    }
}

/* ── Floating chat button clearance ──────────────────────────────── */
@media (max-width: 1024px) {
    #floating-chat-btn {
        bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
        right: 0.85rem !important;
        width: 48px !important;
        height: 48px !important;
        border-radius: 50% !important;
        aspect-ratio: 1/1 !important;
        font-size: 1.05rem !important;
    }
}

/* ── Toast positioning ────────────────────────────────────────────── */
@media (max-width: 767px) {
    #notif-toast-container {
        bottom: calc(58px + env(safe-area-inset-bottom, 0px) + 0.75rem) !important;
        top: auto !important;
        left: 0.65rem !important;
        right: 0.65rem !important;
        max-width: 100% !important;
    }
}

/* ================================================================
   17. UTILITY HELPERS (mobile-only classes added by this file)
   ================================================================ */
@media (max-width: 767px) {
    .mobile-full-width { width: 100% !important; }
    .mobile-stack      { flex-direction: column !important; align-items: stretch !important; }
    .mobile-center     { text-align: center !important; }
    .mobile-hide       { display: none !important; }
    .mobile-show       { display: block !important; }
    .mobile-show-flex  { display: flex !important; }
    .mobile-gap-sm     { gap: 0.5rem !important; }
    .mobile-gap-md     { gap: 1rem !important; }
    .mobile-p-sm       { padding: 0.75rem !important; }
    .mobile-p-md       { padding: 1rem !important; }
    .mobile-mb-sm      { margin-bottom: 0.75rem !important; }
    .mobile-mb-md      { margin-bottom: 1.25rem !important; }
}

/* ================================================================
   18. LIGHT MODE ADDITIONS for mobile nav & admin
   ================================================================ */
@media (max-width: 992px) {
    [data-theme="light"] .navbar-pill {
        background: rgba(255,255,255,0.95) !important;
        box-shadow: 0 4px 24px rgba(0,0,0,0.09) !important;
    }
}

[data-theme="light"] .admin-topbar {
    background: #ffffff !important;
    border-bottom: 1px solid #e4e6ec !important;
}

[data-theme="light"] .mobile-bottom-nav {
    background: #ffffff !important;
    border-top: 1px solid #e4e6ec !important;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06) !important;
}

[data-theme="light"] #floating-chat-btn {
    box-shadow: 0 4px 20px rgba(184,149,10,0.40), 0 2px 8px rgba(0,0,0,0.15) !important;
}

/* ================================================================
   19. SAFE AREA INSETS (notch / home indicator support)
   ================================================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }

    .admin-content {
        padding-bottom: calc(58px + env(safe-area-inset-bottom) + 1rem) !important;
    }
}

/* ================================================================
   20. PRINT — hide mobile-only chrome
   ================================================================ */
@media print {
    .navbar-wrapper,
    .mobile-bottom-nav,
    .fab-whatsapp,
    .fab-feedback,
    #floating-chat-btn,
    #notif-toast-container,
    #pwa-install-banner { display: none !important; }
}

/* ================================================================
   21. FILTER PILL SCROLL "MORE" INDICATOR
   JS adds .has-more when there are pills beyond the right edge
   ================================================================ */
.filter-pills-wrap.has-more {
    -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
    mask-image: linear-gradient(to right, black 80%, transparent 100%);
}

/* ================================================================
   22. MOBILE DATA-CARDS (generated by admin.js for data-mobile-cards tables)
   ================================================================ */
.data-cards-mobile {
    display: none; /* shown only at ≤640px */
}

@media (max-width: 640px) {
    .data-cards-mobile {
        display: block;
    }

    .data-cards-mobile .data-card {
        background: var(--card-bg, #0d0d0d);
        border: 1px solid var(--border, #1a1a1a);
        border-radius: 12px;
        padding: 0.85rem 1rem;
        margin-bottom: 0.65rem;
    }

    .data-cards-mobile .data-card-row {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.35rem 0;
        border-bottom: 1px solid rgba(255,255,255,0.03);
        font-size: 0.78rem;
    }

    .data-cards-mobile .data-card-row:last-child { border-bottom: none; }

    .data-cards-mobile .data-card-label {
        color: var(--text-muted, #9ca3af);
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        flex-shrink: 0;
        max-width: 40%;
    }

    .data-cards-mobile .data-card-value {
        color: var(--text-main, #f3f4f6);
        text-align: right;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        word-break: break-word;
    }

    /* Buttons inside data-card values stay compact */
    .data-cards-mobile .btn-admin,
    .data-cards-mobile a[class*="btn"] {
        padding: 0.3rem 0.6rem !important;
        font-size: 0.72rem !important;
        min-height: 30px !important;
    }
}

/* Light mode data cards */
@media (max-width: 640px) {
    [data-theme="light"] .data-cards-mobile .data-card {
        background: #ffffff !important;
        border-color: #e0e2e8 !important;
    }

    [data-theme="light"] .data-cards-mobile .data-card-row {
        border-bottom-color: rgba(0,0,0,0.05) !important;
    }

    [data-theme="light"] .data-cards-mobile .data-card-label { color: #8c909c !important; }
    [data-theme="light"] .data-cards-mobile .data-card-value { color: #111111 !important; }
}

/* ================================================================
   23. ADMIN SIDEBAR — nav group body collapse animation
   ================================================================ */
.nav-group-body {
    overflow: hidden;
    transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.22s ease;
    max-height: 600px;
    opacity: 1;
}

.nav-group-body.collapsed {
    max-height: 0 !important;
    opacity: 0;
}

/* ================================================================
   24. BOTTOM NAV ACTIVE INDICATOR — clean dot above active icon
   ================================================================ */
@media (max-width: 1024px) {
    /* Remove the ::before pseudo from mobile-fixes section 16
       and replace with a cleaner pill indicator */
    .bn-item.active::before {
        content: '' !important;
        position: absolute !important;
        top: 3px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 18px !important;
        height: 3px !important;
        border-radius: 2px !important;
        background: var(--accent) !important;
        display: block !important;
    }

    /* Ensure the active bn-item has relative positioning for ::before */
    .bn-item { position: relative !important; }
}

/* ================================================================
   25. ADMIN STATS — light mode number contrast
   ================================================================ */
[data-theme="light"] .admin-stat-number { color: #111111 !important; }
[data-theme="light"] .admin-stat-label  { color: #555a66 !important; }
[data-theme="light"] .admin-stat-footer { color: #8c909c !important; }

/* ================================================================
   26. PUBLIC SITE — inline style overrides for common patterns
   These target the most common inline padding/margin patterns
   found across service, about, and home views on mobile
   ================================================================ */
@media (max-width: 768px) {
    /* Inline padded divs that create oversized gaps */
    [style*="padding:5rem"],
    [style*="padding: 5rem"],
    [style*="padding:6rem"],
    [style*="padding: 6rem"],
    [style*="padding:7rem"],
    [style*="padding: 7rem"],
    [style*="padding:8rem"],
    [style*="padding: 8rem"] {
        padding-top: 3rem !important;
        padding-bottom: 3rem !important;
    }

    /* Inline large margins */
    [style*="margin-top:6rem"],  [style*="margin-top: 6rem"],
    [style*="margin-top:8rem"],  [style*="margin-top: 8rem"],
    [style*="margin-top:10rem"], [style*="margin-top: 10rem"] {
        margin-top: 2rem !important;
    }

    [style*="margin-bottom:6rem"],  [style*="margin-bottom: 6rem"],
    [style*="margin-bottom:8rem"],  [style*="margin-bottom: 8rem"],
    [style*="margin-bottom:10rem"], [style*="margin-bottom: 10rem"] {
        margin-bottom: 2rem !important;
    }

    /* Inline oversized font sizes */
    [style*="font-size:4rem"],   [style*="font-size: 4rem"],
    [style*="font-size:4.5rem"], [style*="font-size: 4.5rem"],
    [style*="font-size:5rem"],   [style*="font-size: 5rem"] {
        font-size: clamp(1.75rem, 8vw, 2.8rem) !important;
        line-height: 1.2 !important;
    }

    [style*="font-size:3rem"],   [style*="font-size: 3rem"],
    [style*="font-size:3.5rem"], [style*="font-size: 3.5rem"] {
        font-size: clamp(1.5rem, 6vw, 2.2rem) !important;
        line-height: 1.22 !important;
    }

    [style*="font-size:2rem"],   [style*="font-size: 2rem"],
    [style*="font-size:2.5rem"], [style*="font-size: 2.5rem"] {
        font-size: clamp(1.2rem, 5vw, 1.65rem) !important;
    }

    /* Inline max-widths that cause overflow on narrow screens */
    [style*="max-width:800px"],  [style*="max-width: 800px"],
    [style*="max-width:900px"],  [style*="max-width: 900px"],
    [style*="max-width:1000px"], [style*="max-width: 1000px"] {
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Inline fixed heights on non-image/canvas elements that cause squash */
    [style*="height:400px"],  [style*="height: 400px"],
    [style*="height:500px"],  [style*="height: 500px"],
    [style*="height:600px"],  [style*="height: 600px"] {
        height: auto !important;
        min-height: 0 !important;
    }

    /* Inline min-height that pushes sections too tall */
    [style*="min-height:600px"],  [style*="min-height: 600px"],
    [style*="min-height:700px"],  [style*="min-height: 700px"],
    [style*="min-height:800px"],  [style*="min-height: 800px"] {
        min-height: 50vh !important;
    }
}

@media (max-width: 480px) {
    [style*="font-size:3rem"],   [style*="font-size: 3rem"],
    [style*="font-size:3.5rem"], [style*="font-size: 3.5rem"],
    [style*="font-size:4rem"],   [style*="font-size: 4rem"],
    [style*="font-size:5rem"],   [style*="font-size: 5rem"] {
        font-size: clamp(1.3rem, 7vw, 1.9rem) !important;
    }
}
