/* ========================================
   BASE STYLES
   CSS Reset, HTML/Body, Typography
   ======================================== */

/* CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* HTML & Body */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f2f5;
    /* Softer background */
    min-height: 100vh;
    /* iOS Safari viewport fix */
    min-height: -webkit-fill-available;
    font-size: 18px;
    font-weight: 500;
    color: #222;
    overscroll-behavior-y: none;
    /* Prevent iOS Safari from auto-adjusting font sizes on orientation change */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html {
    /* iOS Safari viewport fix */
    height: -webkit-fill-available;
}

/* Lock to portrait orientation on mobile devices */
@media screen and (max-width: 768px) and (orientation: landscape) {
    html {
        transform: rotate(-90deg);
        transform-origin: left top;
        width: 100vh;
        height: 100vw;
        overflow-x: hidden;
        position: absolute;
        top: 100%;
        left: 0;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Prevent text selection on buttons */
button {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight on mobile */
}

/* iOS-specific fixes for address bar and safe areas */
@supports (-webkit-touch-callout: none) {

    /* This targets iOS Safari specifically */
    body {
        /* Ensure body fills entire viewport on iOS */
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }

    /* Extra padding for iOS in standalone mode (PWA) */
    @media (display-mode: standalone) {

        .home-header,
        .chat-header {
            padding-top: max(20px, calc(20px + env(safe-area-inset-top)));
        }
    }
}

/* Device rotation protection for iPhone-like devices (not iPads) */
@media only screen
  and (max-width: 926px)
  and (orientation: landscape) {

    body::before {
        content: '📱 Please rotate your device to portrait mode for the best experience';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.95);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 20px;
        z-index: 99999;
        font-size: 20px;
        line-height: 1.5;
    }
}