/* Mobile Optimization Styles */

/* Touch-friendly buttons and links */
@media (max-width: 768px) {

    /* Minimum touch target size: 44px */
    button,
    .btn,
    a.button,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    /* Larger tap targets for navigation */
    nav a,
    .nav-link,
    .menu-item {
        min-height: 48px;
        display: flex;
        align-items: center;
        padding: 12px 16px;
    }

    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        min-height: 44px;
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px 16px;
    }

    /* MOBILE HEADER SPECIFIC OVERRIDES - Must come after generic input styles */
    #oldSearchInput {
        min-height: 24px !important;
        height: 24px !important;
        line-height: 24px !important;
        font-size: 13px !important;
        padding: 0 8px !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    #searchCategory {
        min-height: 24px !important;
        height: 24px !important;
        font-size: 12px !important;
        padding: 0 6px !important;
        max-width: 100px !important;
        flex-shrink: 0 !important;
    }

    .search-box {
        padding: 2px 8px !important;
        border-radius: 12px !important;
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        gap: 4px !important;
    }

    .header-row1 {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        overflow: visible !important;
    }

    .search-filter-container {
        display: flex !important;
        gap: 8px !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 !important;
        order: 1 !important;
    }

    #searchWrapper {
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    #searchForm {
        flex: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
    }

    /* Filter button should be on the right */
    .filter-toggle-btn,
    #filterToggle,
    .search-filter-btn {
        order: 2 !important;
        flex-shrink: 0 !important;
        margin-left: auto !important;
    }

    /* Ensure header container is full width */
    .header-container {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Redundant toggle styles removed - controlled by header.php */
    /* .mobile-sidebar-toggle { ... } */

    /* Larger font sizes for readability */
    body {
        font-size: 16px;
        line-height: 1.6;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 24px;
    }

    h3 {
        font-size: 20px;
    }

    h4 {
        font-size: 18px;
    }

    /* Spacing improvements */
    .container,
    .content {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Cards and sections */
    .card,
    .section {
        margin-bottom: 16px;
        padding: 16px;
    }

    /* Tables - make scrollable */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Images responsive */
    img {
        max-width: 100%;
        height: auto;
    }

    /* Hide desktop-only elements */
    .desktop-only {
        display: none !important;
    }

    /* Show mobile-only elements */
    .mobile-only {
        display: block !important;
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 720px;
    }

    /* Adjust grid layouts */
    .grid-3-col {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Landscape phone optimizations */
@media (max-width: 768px) and (orientation: landscape) {

    /* Reduce header height in landscape */
    header {
        min-height: 60px;
    }

    /* Adjust modal heights */
    .modal-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Prevent text selection on buttons (better mobile UX) */
button,
.btn,
a.button {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Smooth scrolling on mobile */
html {
    -webkit-overflow-scrolling: touch;
}

/* Fix viewport issues */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* ==========================================================================
   NUCLEAR MOBILE COMBAT STYLES (Ported from index-mobile.php - User Request)
   "So this devil will not flash or come out without asking"
   ========================================================================== */
@media (max-width: 980px) {

    /* 1. Global Reset & Tightening */
    body,
    html,
    .main-content,
    main {
        margin: 0 !important;
        padding-top: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow-x: hidden !important;
    }

    /* 2. Remove Header Gaps & Fix Banner */
    #mainHeader {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    #redCrisisBanner {
        margin-top: 10px !important;
        /* Removed negative margin that caused overlap */
        position: relative !important;
        z-index: 995 !important;
    }

    /* 3. Center and Compact the Navigator (Tight Layout) */
    #navigator-container {
        display: flex !important;
        justify-content: center !important;
        gap: 1px !important;
        width: 100% !important;
        margin: 0 auto !important;
        padding: 0 1px !important;
        pointer-events: auto !important;
        z-index: 20002 !important;
        position: relative !important;
    }

    #navigator-container .nav-item {
        margin: 0 !important;
        padding: 0 !important;
        pointer-events: auto !important;
        z-index: 20003 !important;
    }

    #navigator-container .nav-btn {
        padding: 2px 4px !important;
        /* Ultra-tight touch target to fit 7+ items */
        cursor: pointer !important;
        pointer-events: auto !important;
        z-index: 20003 !important;

        /* Show Icon + Text tiny */
        font-size: 10px !important;
        color: #111827 !important;
        /* Deep dark color for visibility */
        font-weight: 600 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 2px !important;
        width: auto !important;
        min-width: 25px !important;
        /* Ensure click area */
    }

    /* Ensure Icons are visible and sized correctly */
    #navigator-container .nav-btn i {
        font-size: 18px !important;
        color: #333 !important;
        /* Default dark icon */
        display: block !important;
        visibility: visible !important;
        margin: 0 !important;
    }

    /* Specific colors for specific icons (re-apply if needed) */
    #navigator-container .nav-btn i.fa-home {
        color: #3b82f6 !important;
    }

    #navigator-container .nav-btn i.fa-heart {
        color: #ec4899 !important;
    }

    #navigator-container .nav-btn i.fa-images {
        color: #6366f1 !important;
    }

    #navigator-container .nav-btn i.fa-gavel {
        color: #f97316 !important;
    }

    #navigator-container .nav-btn i.fa-shopping-bag {
        color: #10b981 !important;
    }

    #navigator-container .nav-btn i.fa-chart-line {
        color: #8b5cf6 !important;
    }

    #navigator-container .nav-btn i.fa-globe {
        color: #14b8a6 !important;
    }

    #navigator-container .nav-btn i.fa-tools {
        color: #ef4444 !important;
    }

    /* Show text spans (Match Desktop) */
    #navigator-container .nav-btn span,
    #navigator-container .nav-text {
        display: inline !important;
    }

    /* 4. KILL THE FLASHING DEVIL (UFO Panel)
       But allow it if .mobile-summoned (The Strip) is active. */
    /* DISABLED - Relying on .ufo-mobile-hidden class
    #ufoControlPanel:not(.mobile-summoned),
    .ufo-right-control-panel:not(.mobile-summoned) {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    */

    /* 5. Sanity Bar (Visual Confidence) */
    .sanity-bar {
        height: 3px !important;
        background: #39ff14 !important;
        /* Neon Green */
        width: 100% !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 2147483647 !important;
    }
}

/* ============================================
   SMOOTH PAGE TRANSITIONS
   Eliminates shake, jerk, and wave-like movements
   ============================================ */

/* Prevent layout shifts and reflow */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    /* Prevent jerky movements */
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
    /* Smooth rendering */
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
    /* Prevent text selection causing shifts */
    -webkit-tap-highlight-color: transparent;
}

/* Smooth page transition overlay */
.page-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 9998;
    /* Below header overlays but still high */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-transition-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Smooth fade transition for page content */
.page-content {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-content.loading {
    opacity: 0;
    transform: translateY(10px);
}

.page-content.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Prevent layout shifts during load */
* {
    box-sizing: border-box;
}

/* Smooth image loading */
img {
    max-width: 100%;
    height: auto;
    display: block;
    /* Prevent layout shift */
    opacity: 1;
    /* FIXED: Default to visible to prevent invisible images if JS fails */
    transition: opacity 0.3s ease;
}

img, img.loaded { opacity: 1 !important; visibility: visible !important; }

/* Smooth link transitions */
a {
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
    text-decoration: none;
}

a:hover {
    transform: translateY(-1px);
}

a:active {
    transform: translateY(0);
}

/* Smooth button transitions */
button,
.button,
input[type="submit"],
input[type="button"] {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

button:hover,
.button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    transform: translateY(-2px) translateZ(0);
    -webkit-transform: translateY(-2px) translateZ(0);
}

button:active,
.button:active,
input[type="submit"]:active,
input[type="button"]:active {
    transform: translateY(0) translateZ(0);
    -webkit-transform: translateY(0) translateZ(0);
}

/* Smooth form element transitions */
input,
textarea,
select {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

input:focus,
textarea:focus,
select:focus {
    transform: translateZ(0) scale(1.01);
    -webkit-transform: translateZ(0) scale(1.01);
}

/* Prevent jerky scroll */
* {
    scroll-behavior: smooth;
}

/* Smooth container transitions */
.container,
.container-fluid,
main,
section,
article {
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Eliminate wave-like animations */
@keyframes smoothFadeIn {
    from {
        opacity: 0;
        transform: translateY(0) translateZ(0);
    }

    to {
        opacity: 1;
        transform: translateY(0) translateZ(0);
    }
}

@keyframes smoothSlideIn {
    from {
        opacity: 0;
        transform: translateX(-20px) translateZ(0);
    }

    to {
        opacity: 1;
        transform: translateX(0) translateZ(0);
    }
}

/* Smooth modal transitions */
.modal,
.popup,
.overlay {
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Prevent layout shifts from dynamic content */
.dynamic-content {
    min-height: 50px;
    transition: opacity 0.3s ease, min-height 0.3s ease;
}

/* Smooth navigation transitions */
nav,
.navbar,
.navigation {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Smooth header transitions */
header {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

/* Smooth footer transitions */
footer {
    transition: opacity 0.3s ease;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Eliminate shake on hover */
*:hover {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* Smooth table transitions */
table {
    transition: opacity 0.3s ease;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Smooth card transitions */
.card,
.panel,
.box {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.card:hover,
.panel:hover,
.box:hover {
    transform: translateY(-4px) translateZ(0);
    -webkit-transform: translateY(-4px) translateZ(0);
}

/* Prevent jerky animations */
@keyframes noShake {
    from {
        transform: translateZ(0);
    }

    to {
        transform: translateZ(0);
    }
}

/* Smooth loading states */
.loading,
.spinner {
    animation: smoothSpin 0.8s linear infinite;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

@keyframes smoothSpin {
    from {
        transform: rotate(0deg) translateZ(0);
    }

    to {
        transform: rotate(360deg) translateZ(0);
    }
}

/* GPU acceleration for smooth transitions */
.smooth-transition {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-perspective: 1000;
    perspective: 1000;
}

/* Prevent reflow on page load */
body.loading {
    overflow: hidden;
}

body.loaded {
    overflow: auto;
}

/* Smooth page change indicator */
.page-change-indicator {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    z-index: 10000;
    transition: width 0.3s ease;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Mobile optimizations */
@media (max-width: 768px) {

    /* Reduce transitions on mobile for better performance */
    * {
        transition-duration: 0.2s !important;
    }

    /* Prevent layout shifts */
    body {
        -webkit-overflow-scrolling: touch;
    }
}

/* Print styles - no transitions */
@media print {
    * {
        transition: none !important;
        animation: none !important;
    }
}

/* Form Validation CSS - Stub file to prevent 404 errors */
/* This file can be populated with actual validation styles if needed */

.form-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 4px;
}

.form-success {
    color: #28a745;
    font-size: 12px;
    margin-top: 4px;
}

.password-strength {
    margin-top: 8px;
    font-size: 12px;
}

