/* =========================
   GLOBAL RESPONSIVE ENGINE
   ========================= */

/* 1️⃣ Universal Box Model */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* 2️⃣ Fluid Typography & Core Variables */
:root {
    --vh: 1vh;
    --header-height: 70px;
    --nav-height: 60px;
}

html {
    font-size: clamp(14px, 1.2vw, 16px);
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

/* 🔒 MOBILE: Prevent horizontal scrolling */
@media (max-width: 768px) {

    html,
    body {
        max-width: 100vw !important;
    }

    /* Prevent any element from causing horizontal scroll */
    .container,
    .card,
    main,
    #app {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* EXCEPTION: Allow dropdowns to overflow for proper click handling */
    #user-menu-dropdown,
    .dropdown,
    [id*="dropdown"] {
        overflow: visible !important;
    }
}

h1 {
    font-size: clamp(2rem, 8vw, 4rem);
    line-height: 1.1;
}

h2 {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    line-height: 1.2;
}

h3 {
    font-size: clamp(1.25rem, 4vw, 1.8rem);
    line-height: 1.3;
}

p {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

/* 3️⃣ Container Safety */
.container {
    width: 100%;
    max-width: 1200px;
    margin-inline: auto;
    padding-inline: clamp(1rem, 5vw, 2rem);
    position: relative;
}

/* 4️⃣ Buttons – Touch Optimized */
.btn {
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .btn {
        width: 100%;
        padding: 0.6rem 1.25rem;
        /* Standardized vertical padding to match View More Details button */
    }
}

/* 5️⃣ Layout Utilities */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: 2rem;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 6️⃣ Header & Navigation */
.ag-navbar {
    height: var(--header-height);
    background: var(--bg-secondary);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* Hamburger classes for Layout.js */
.ag-hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.ag-hamburger span {
    display: block;
    width: 25px;
    height: 2px;
    background: var(--text-main);
    margin: 5px 0;
    transition: 0.3s;
}

/* Mobile Nav Overlay */
.ag-nav-overlay {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 2000;
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

.ag-nav-overlay.open {
    right: 0;
}

.ag-nav-close {
    align-self: flex-end;
    background: none;
    border: none;
    font-size: 2.5rem;
    color: var(--text-main);
    cursor: pointer;
    line-height: 1;
}

.ag-nav-mobile-list {
    list-style: none;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.ag-nav-mobile-list button,
.ag-nav-mobile-list a {
    width: 100%;
    text-align: left;
    font-size: 1.5rem;
    font-weight: 600;
    background: none;
    border: none;
    color: var(--text-main);
    padding: 0.5rem 0;
}

/* Visibility Utilities */
@media (max-width: 768px) {

    .hide-mobile,
    .ag-hide-mobile {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        pointer-events: none !important;
    }

    .ag-hamburger {
        display: flex !important;
    }

    /* Ensure header doesn't overflow */
    .ag-navbar .flex-between {
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .ag-navbar .flex-between>.flex-between {
        flex-shrink: 0;
    }

    /* Ensure nav items inside hidden nav don't show */
    .hide-mobile *,
    .ag-hide-mobile * {
        display: none !important;
    }
}

@media (min-width: 769px) {

    .hide-desktop,
    .ag-hide-desktop {
        display: none !important;
    }

    .ag-hamburger {
        display: none !important;
    }

    /* Desktop: Show nav with flex layout */
    .hide-mobile {
        display: flex !important;
        align-items: center;
        gap: 0.5rem;
    }
}

/* Custom Scroll Lock */
body.menu-open {
    overflow: hidden !important;
    height: 100vh;
}

/* Hide footer when chat is locked to viewport */
body.dmgr-chat-open footer,
body.msg-chat-open footer {
    display: none !important;
}

/* Forms Fix */
.input-group input,
.input-group select,
.input-group textarea {
    font-size: 16px !important;
    /* Prevent iOS Zoom */
}