/**
 * ANTIGRAVITY - GLOBAL PORTAL STYLESHEET (SINGLE MASTER CSS)
 * All global styles, typography, components, animations, and custom dropdown menus.
 */

:root {
    --brand-red: #dc2626;
    --brand-red-dark: #b91c1c;
    --brand-red-light: #fef2f2;
    --brand-black: #0f172a;
    --brand-slate: #1e293b;
    --border-color: #e2e8f0;
}

html {
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: auto;
    scrollbar-gutter: stable;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: #f0f2f5;
    color: #1e293b;
    margin: 0;
    min-height: 100vh;
    position: relative;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent !important;
}

.mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Category Grid Buttons */
.category-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.category-btn.active {
    border-color: var(--brand-red);
    background-color: #fef2f2;
    color: #b91c1c;
    box-shadow: 0 0 0 1px var(--brand-red), 0 10px 15px -3px rgba(220, 38, 38, 0.1);
}

/* Input Glowing Focus */
.input-glow:focus {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.08);
    outline: none;
}

/* Interactive Buttons */
.btn-interactive {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-interactive:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(220, 38, 38, 0.3), 0 10px 10px -5px rgba(220, 38, 38, 0.2);
}
.btn-interactive:active {
    transform: translateY(0);
}

/* Toast Animations */
@keyframes slideUp {
    from {
        transform: translate(-50%, 30px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -20px);
        opacity: 1;
    }
}
.toast-visible {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Auth Wrapper & Password */
.auth-wrapper {
    min-width: 320px;
    width: 100%;
    max-width: 440px;
}
.pass-wrapper {
    position: relative;
}
.pass-toggle {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 4px;
    z-index: 10;
}
.pass-toggle:hover {
    color: var(--brand-red);
    transform: translateY(-50%) scale(1.1);
}

.auth-error-box {
    animation: fadeInDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   BEAUTIFUL DROPDOWN ITEMS MENU & SELECT SYSTEM
   ========================================================================== */

/* 1. Global Native Select Styling with Custom Red Chevron */
select,
.custom-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: #ffffff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23dc2626' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 0.95rem 0.95rem;
    padding-right: 2.5rem !important;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

select:hover,
.custom-select:hover {
    border-color: #f87171;
    background-color: #fffdfd;
    box-shadow: 0 4px 14px -2px rgba(220, 38, 38, 0.08);
}

select:focus,
.custom-select:focus {
    border-color: var(--brand-red) !important;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.09) !important;
    outline: none !important;
    background-color: #ffffff;
}

/* Native Option Styling (Chromium / Firefox / Edge) */
select option {
    background-color: #ffffff;
    color: #0f172a;
    font-size: 0.8125rem;
    font-weight: 700;
    padding: 0.75rem 1rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

select option:hover,
select option:focus,
select option:checked {
    background-color: #fef2f2 !important;
    color: var(--brand-red) !important;
    font-weight: 800;
}

/* 2. Custom Floating Dropdown Menu Component */
.custom-dropdown {
    position: relative;
    display: inline-block;
}

.custom-dropdown.w-full {
    width: 100%;
}

.custom-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.875rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    user-select: none;
}

.custom-dropdown-toggle:hover {
    border-color: #fca5a5;
    background: #fffcfc;
    box-shadow: 0 4px 14px -2px rgba(220, 38, 38, 0.08);
}

.custom-dropdown-toggle:focus,
.custom-dropdown.active .custom-dropdown-toggle {
    border-color: var(--brand-red);
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.09);
    outline: none;
}

.custom-dropdown-toggle .chevron-icon {
    width: 0.875rem;
    height: 0.875rem;
    color: var(--brand-red);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.custom-dropdown.active .custom-dropdown-toggle .chevron-icon {
    transform: rotate(180deg);
}

/* The Open Dropdown Items Menu Card */
.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 220px;
    z-index: 99999 !important;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 1.25rem;
    padding: 0.5rem;
    box-shadow: 
        0 20px 40px -10px rgba(15, 23, 42, 0.16),
        0 10px 20px -5px rgba(15, 23, 42, 0.06),
        0 0 0 1px rgba(226, 232, 240, 0.8),
        0 2px 4px rgba(15, 23, 42, 0.04);
    display: none;
    flex-direction: column;
    max-height: 420px;
    overflow-x: hidden !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform-origin: top center;
    box-sizing: border-box;
}

/* Custom Smooth Scrollbar for Dropdown Menu */
.custom-dropdown-menu::-webkit-scrollbar {
    width: 5px;
}
.custom-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
    margin: 6px;
}
.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 10px;
}
.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Open Dropdown Animation */
@keyframes dropdownMenuEnter {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

.custom-dropdown.active .custom-dropdown-menu,
.custom-dropdown-menu.show {
    display: flex !important;
    flex-direction: column !important;
    animation: dropdownMenuEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Strict full-width vertical column containment for all dropdown children */
.custom-dropdown-menu > * {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    flex-shrink: 0;
}

/* Header & Divider in Menu */
.custom-dropdown-header {
    padding: 0.5rem 0.85rem 0.35rem 0.85rem;
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #94a3b8;
    box-sizing: border-box;
}

.custom-dropdown-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #e2e8f0, transparent);
    margin: 0.35rem 0.25rem;
    border: none;
    box-sizing: border-box;
}

/* Dropdown Item */
.custom-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.65rem 0.85rem;
    border-radius: 0.875rem;
    font-size: 0.775rem;
    font-weight: 700;
    color: #334155;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    user-select: none;
    position: relative;
    gap: 0.75rem;
    white-space: nowrap !important;
    box-sizing: border-box;
}

.custom-dropdown-item:hover {
    background-color: #f8fafc;
    color: var(--brand-red);
    transform: translateX(2px);
}

.custom-dropdown-item:focus {
    background-color: #f8fafc;
    color: var(--brand-red);
    outline: none;
}

/* Active Selected Dropdown Item */
.custom-dropdown-item.active {
    background-color: #fef2f2;
    color: var(--brand-red);
    font-weight: 800;
}

.custom-dropdown-item .item-check {
    width: 0.875rem;
    height: 0.875rem;
    color: var(--brand-red);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: scale(0.7);
    flex-shrink: 0;
}

.custom-dropdown-item.active .item-check {
    opacity: 1;
    transform: scale(1);
}

.custom-dropdown-item .item-badge {
    font-size: 0.625rem !important;
    padding: 0.2rem 0.55rem !important;
    border-radius: 9999px !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.04em !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    line-height: 1 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Right-aligned dropdown variation */
.custom-dropdown-menu-right {
    right: 0 !important;
    left: auto !important;
}

/* Spinner Animation for Dynamic Action Icons */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
.animate-spin {
    animation: spin 0.85s linear infinite !important;
}

/* ==========================================================================
   MULTI-DEVICE & MOBILE RESPONSIVE ENHANCEMENTS
   ========================================================================== */

/* Prevent accidental horizontal overflow without locking document vertical scrolling */
#app,
.portal-container {
    overflow-x: clip;
}

/* iOS momentum touch scrolling for tables and navigation bars */
.overflow-x-auto,
.table-responsive,
.table-responsive-wrapper {
    -webkit-overflow-scrolling: touch;
}

/* Modern slim scrollbar for tables */
.overflow-x-auto::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}
.overflow-x-auto::-webkit-scrollbar-track,
.table-responsive::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 9999px;
}
.overflow-x-auto::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
}
.overflow-x-auto::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Hide scrollbar utility */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Mobile dropdown positioning guard */
@media (max-width: 768px) {
    #mobileUserNavDropdown,
    .custom-dropdown-menu-mobile {
        max-width: calc(100vw - 2rem) !important;
        right: 0 !important;
        left: auto !important;
    }
    
    /* Ensure modal containers fit smaller displays */
    #qrModal > div {
        max-width: calc(100vw - 2rem) !important;
        padding: 1.5rem 1rem !important;
    }

    /* Touch target comfort */
    button, a, input, select {
        touch-action: manipulation;
    }

    /* Zero Layout Shift on Input Focus: Font-size 16px prevents mobile auto-zoom and screen shift */
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        font-size: 16px !important;
        line-height: 1.4 !important;
        box-sizing: border-box !important;
    }

    /* Ample padding to prevent fixed mobile bottom nav from covering content */
    body {
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0.75rem)) !important;
    }
}

/* Fixed Mobile Navigation Position Guarantee */
.mobile-bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 80 !important;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem)) !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* ==========================================================================
   REALTIME SOCIAL PREVIEW THUMBNAIL ENGINE
   ========================================================================== */

.social-preview-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1.91 / 1;
    background-color: #0f172a;
    overflow: hidden;
    border-top-left-radius: 1.5rem;
    border-top-right-radius: 1.5rem;
}

.social-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s ease;
}

.social-preview-placeholder {
    position: absolute;
    inset: 0;
    user-select: none;
    transition: opacity 0.25s ease;
}

.social-preview-shimmer {
    background: linear-gradient(90deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.03) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.8s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.aspect-social-card {
    aspect-ratio: 1.91 / 1;
}

/* ==========================================================================
   PORTAL SEARCH INDEX STYLING & CREDENTIAL AUTOFILL ISOLATION
   ========================================================================== */
#searchLinks:-webkit-autofill,
#searchLinks:-webkit-autofill:hover, 
#searchLinks:-webkit-autofill:focus,
#searchLinks:-internal-autofill-selected {
    -webkit-box-shadow: 0 0 0 1000px #f8fafc inset !important;
    -webkit-text-fill-color: #0f172a !important;
    box-shadow: 0 0 0 1000px #f8fafc inset !important;
    color: #0f172a !important;
    transition: background-color 5000s ease-in-out 0s;
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
    display: none;
}

/* ==========================================================================
   MOBILE NATIVE BOTTOM NAVIGATION & FULL SCREEN SETTINGS SHEET
   ========================================================================== */
.pb-safe {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
}

.mobile-bottom-nav {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 80 !important;
    box-shadow: 0 -8px 30px -4px rgba(15, 23, 42, 0.08), 0 -2px 6px -1px rgba(15, 23, 42, 0.04);
    touch-action: manipulation;
}

#mobileFullScreenMenu.active {
    opacity: 1 !important;
    pointer-events: auto !important;
}

#mobileFullScreenMenu.active .mobile-menu-sheet {
    transform: translateY(0) !important;
}

/* ==========================================================================
   NATIVE APP EXPERIENCE & ANTI-LAYOUT SHIFT RULES
   ========================================================================== */

/* Prevent iOS & Android Auto-Zoom layout shift when focusing inputs */
@media (max-width: 768px) {
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
        font-size: 16px !important;
        scroll-margin-top: 5rem;
        scroll-margin-bottom: 5.5rem;
    }

    body {
        padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0.75rem)) !important;
    }
}

/* Native App Touch & Interaction Feel */
button, 
a, 
input, 
select, 
textarea, 
.custom-dropdown-toggle, 
.category-btn {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent !important;
}

/* Native Micro-Feedback on Mobile Tap */
@media (hover: none) and (pointer: coarse) {
    button:active,
    .btn-interactive:active,
    .mobile-bottom-nav a:active,
    .mobile-bottom-nav button:active {
        transform: scale(0.96) !important;
        transition: transform 0.1s ease-out !important;
    }
}

/* Native App Scrollbar Behavior */
@media (max-width: 768px) {
    ::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }
    ::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.4);
        border-radius: 9999px;
    }
    ::-webkit-scrollbar-track {
        background: transparent;
    }
}

/* ==========================================================================
   BEAUTIFIED HIGH-PERFORMANCE CUSTOM CHECKBOX ENGINE
   ========================================================================== */
input[type="checkbox"]:not(.sr-only) {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 1.15rem;
    height: 1.15rem;
    min-width: 1.15rem;
    min-height: 1.15rem;
    border-radius: 0.425rem;
    border: 1.5px solid #cbd5e1;
    background-color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    vertical-align: middle;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    outline: none;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
    margin: 0;
    accent-color: #dc2626;
}

input[type="checkbox"]:not(.sr-only):hover {
    border-color: #ef4444;
    background-color: #fff8f8;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

input[type="checkbox"]:not(.sr-only):focus-visible {
    border-color: #dc2626;
    box-shadow: 0 0 0 3.5px rgba(220, 38, 38, 0.25);
}

/* Checked State: Crimson Brand Color + Clean Vector SVG Checkmark */
input[type="checkbox"]:not(.sr-only):checked {
    background-color: #dc2626;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.5 8.5L6.5 11.5L12.5 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 82% 82%;
    border-color: #dc2626;
    box-shadow: 0 2px 6px -1px rgba(220, 38, 38, 0.45), 0 1px 3px -1px rgba(220, 38, 38, 0.3);
}

/* Indeterminate State (Partial Batch Selection) */
input[type="checkbox"]:not(.sr-only):indeterminate {
    background-color: #dc2626;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 8H12'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 80% 80%;
    border-color: #dc2626;
    box-shadow: 0 2px 6px -1px rgba(220, 38, 38, 0.45);
}

/* Micro-press on tap/click */
input[type="checkbox"]:not(.sr-only):active {
    transform: scale(0.9);
}

/* Disabled State */
input[type="checkbox"]:not(.sr-only):disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f1f5f9;
    border-color: #e2e8f0;
    box-shadow: none;
    transform: none;
}



