/**
 * =========================================================================================
 * MYWINGMAN CUSTOM CSS UTILITIES & ANIMATION STYLESHEET
 * =========================================================================================
 */

/* Anti-FOUT & Touch Action Core Reset */
html, body {
    background-color: #000000 !important;
    color: #ffffff;
    -webkit-overflow-scrolling: touch;
}

* {
    -webkit-tap-highlight-color: transparent !important;
}

button, a, .tone-chip, .vibe-chip, .bio-style-chip, .nav-tab-mobile, .nav-tab-desktop {
    touch-action: manipulation !important;
}

/* Custom Scrollbar Styles */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 9999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.4);
    border-radius: 9999px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(168, 85, 247, 0.7);
}

/* Terms Shake Pulse Animation */
@keyframes termsShakePulse {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.terms-shake-pulse {
    animation: termsShakePulse 0.4s ease-in-out 2;
    border-color: rgba(239, 68, 68, 0.8) !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4) !important;
}

/* Mobile Safe Area & Dynamic Viewport Height Support */
:root {
    --app-height: 100vh;
}
@supports (height: 100dvh) {
    :root {
        --app-height: 100dvh;
    }
}
.mobile-safe-bottom {
    padding-bottom: max(1rem, env(safe-area-inset-bottom, 1rem));
}

/* =========================================================================================
 * PRODUCTION MOBILE REPAIR LAYER
 * Keeps all primary controls visible without horizontal discovery gestures and prevents the
 * fixed bottom navigation from obscuring the active workspace.
 * ========================================================================================= */
@media (max-width: 767px) {
    html, body {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        overscroll-behavior-x: none;
        scroll-behavior: auto !important;
    }

    #mainContentCanvas {
        width: 100% !important;
        max-width: 100% !important;
        padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important;
        scroll-padding-top: 72px;
    }

    /* Show all four Practice Partner modes at once: no hidden horizontal-scroll choices. */
    #practiceScenarioBar {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        width: 100% !important;
        overflow: visible !important;
        padding: 2px 0 !important;
    }

    #practiceScenarioBar .scenario-chip,
    #practiceScenarioBar .scenario-pill {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 44px !important;
        padding: 9px 8px !important;
        white-space: normal !important;
        text-align: center !important;
        line-height: 1.2 !important;
        font-size: 11px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Keep the other four-choice selectors wrapped and fully discoverable too. */
    #analyzeToneContainer,
    #vibeContainer,
    #bioStyleContainer {
        flex-wrap: wrap !important;
        overflow: visible !important;
        max-width: 100% !important;
    }

    /* Practice workspace: the composer must remain inside the visible mobile card. */
    #chatboxSection {
        min-height: 0 !important;
        height: auto !important;
        padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #chatbox-simulator-panel {
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }

    #chatbox-simulator-panel > div:first-child {
        display: block !important;
        visibility: visible !important;
        margin-bottom: 12px !important;
    }

    .chatbox-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        height: calc(100dvh - 300px) !important;
        min-height: 350px !important;
        max-height: 620px !important;
        overflow: hidden !important;
        border-radius: 16px !important;
    }

    #chatbox-messages-container {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow-y: auto !important;
        overscroll-behavior-y: contain;
        padding: 12px !important;
    }

    .chatbox-footer-sticky-wrapper {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        flex: 0 0 auto !important;
        width: 100% !important;
        z-index: 35 !important;
    }

    .chatbox-footer {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 9px !important;
    }

    #simulator-chat-input {
        display: block !important;
        visibility: visible !important;
        pointer-events: auto !important;
        min-width: 0 !important;
        width: 100% !important;
        min-height: 46px !important;
        font-size: 16px !important; /* Prevents Chrome/iOS focus zoom. */
        touch-action: manipulation !important;
    }

    #chatbox-send-btn {
        flex: 0 0 auto !important;
        min-width: 74px !important;
        min-height: 46px !important;
        padding: 0 14px !important;
    }

    #mobileNavBar {
        min-height: 78px !important;
        padding-bottom: max(8px, env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Mobile performance: remove expensive decorative layers that do not affect functionality. */
    #ambient-plexus-canvas {
        display: none !important;
    }

    .ambient-glow-1,
    .ambient-glow-2,
    .ambient-glow-3 {
        animation: none !important;
        opacity: 0.28 !important;
        filter: blur(48px) !important;
    }

    .chatbox-footer-sticky-wrapper,
    #mobileNavBar {
        -webkit-backdrop-filter: blur(8px) !important;
        backdrop-filter: blur(8px) !important;
    }

    /* Avoid needless transform layers on long mobile panels. */
    .tab-content-panel,
    .chatbox-wrapper {
        backface-visibility: visible !important;
    }
}

@media (max-width: 390px) {
    #practiceScenarioBar {
        gap: 6px !important;
    }

    #practiceScenarioBar .scenario-chip,
    #practiceScenarioBar .scenario-pill {
        font-size: 10px !important;
        padding: 8px 6px !important;
    }

    .chatbox-wrapper {
        height: calc(100dvh - 285px) !important;
        min-height: 330px !important;
    }
}


/* Accessibility hardening: cross-browser mobile + keyboard contracts. */
.a11y-icon-touch-target {
    min-width: 44px !important;
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

#analyzeEmptyState > p:nth-child(3),
#screenshotPreviewContainer > div > p:nth-child(3) {
    color: #9ca3af !important;
}

@media (max-width: 767px) {
    #authEmailInput,
    #authPasswordInput,
    #forgotEmailInput,
    #resetEmailInput,
    #bioInput,
    #auditBioInput,
    #simulator-chat-input {
        font-size: 16px !important;
    }
}
