/* Custom CSS for Header Improvements */

/* =========================================
   LOGO IMAGE STYLES (Banner Logo Class)
   Keep this separate and don't mix with others.
   ========================================= */
header.hd figure.logo img {
    /* Dimensions */
    height: 32px;      /* Default height */
    width: auto;       /* Maintain aspect ratio */
    max-width: 100%;   /* Prevent overflow */
    
    /* Display & Positioning */
    display: block;
    object-fit: contain;
    
    /* Effects */
    transition: all 0.3s ease;
}

/* Mobile Responsiveness for Logo */
@media (max-width: 768px) {
    header.hd figure.logo img {
        height: 28px; /* Smaller height on mobile */
        width: auto;
    }
}

/* 2. Search Component Logic */
/* Desktop State (> 768px) */
.search-wrap-main {
    flex-grow: 1;
    display: flex;
    justify-content: center; /* Center horizontally */
    align-items: center;
    margin-left: 20px; /* Adjust left margin */
    margin-right: 220px; /* Push search box slightly left by increasing right margin */
    position: relative;
}

.search-trigger-mobile {
    display: none;
}

/* Desktop Search Form - Ensure visibility and styling */
.search-form-container {
    display: block;
    width: 100%;
    max-width: 580px; /* Slightly reduced width for better proportion */
}

/* Override any theme hidden classes if present */
.search-form-container form.search {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    background: #1f1f1f; /* Slightly lighter dark background to match screenshot */
    border-radius: 50px; /* Pill shape */
    padding: 0; /* Remove padding from form container */
    border: 1px solid rgba(255,255,255,0.08); /* Subtle border */
    align-items: center;
    box-shadow: none !important; /* Prevent white strip */
    height: 48px; /* Slightly taller for better touch target */
}

/* Prevent white background on focus/active if theme adds it */
.search-form-container form.search.on,
.search-form-container form.search:focus-within {
    background: #2a2a2a !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Move button (icon) to LEFT */
.search-form-container form.search button {
    order: -1; /* Move to start */
    background: transparent;
    border: none;
    color: #bbb; /* Slightly lighter icon color */
    cursor: pointer;
    padding: 0 12px 0 15px; /* Adjust padding: right 12px, left 15px */
    font-size: 16px;
    display: flex;
    align-items: center;
    height: 100%; /* Match container height */
}

/* Fix vertical alignment of icon */
.search-form-container form.search button i {
    vertical-align: middle;
    line-height: 1;
    font-size: 16px; /* Ensure icon size */
}

/* Input styling */
.search-form-container form.search input {
    background: transparent;
    border: none;
    color: #fff;
    width: 100%;
    outline: none !important;
    box-shadow: none !important; /* Prevent white strip */
    padding: 0 20px 0 0; /* Padding right */
    font-size: 15px; /* Slightly larger font */
    height: 100%; /* Match container height */
    line-height: normal;
}

.search-form-container form.search input::placeholder {
    color: #888;
}

/* Live Search Results Dropdown */
.live-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1f1f1f;
    border-radius: 12px;
    margin-top: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

.live-search-results ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.live-search-results li {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.live-search-results li:last-child {
    border-bottom: none;
}

.live-search-results a {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    color: #fff;
    text-decoration: none;
    transition: background 0.2s;
}

.live-search-results a:hover {
    background: rgba(255,255,255,0.05);
}

.live-search-results .thumb {
    width: 40px;
    height: 60px;
    margin-right: 15px;
    border-radius: 4px;
    overflow: hidden;
    background: #111;
    flex-shrink: 0;
}

.live-search-results .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.live-search-results .info {
    flex-grow: 1;
}

.live-search-results .title {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.live-search-results .meta {
    display: block;
    font-size: 12px;
    color: #9ca3af;
}

.live-search-results .no-results {
    padding: 15px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* Mobile State (< 768px) */
@media (max-width: 768px) {
    .search-wrap-main {
        flex-grow: 0;
        margin: 0 10px 0 0;
        position: static; /* For absolute dropdown positioning */
    }

    .search-trigger-mobile {
        display: flex;
        background: transparent;
        border: none;
        color: #fff;
        padding: 8px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
    }
    
    .search-trigger-mobile:hover {
        color: #ff9800;
    }

    /* Mobile Dropdown Search Form - Transparent Overlay Style */
    .search-form-container {
        display: none; /* Hidden by default */
        position: absolute;
        top: 100%; /* Below header */
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        background: transparent; /* Fully transparent background */
        padding: 8px 15px; /* Adjust padding */
        box-shadow: none; /* Remove background shadow */
        z-index: 999;
        margin-top: 2px; /* Very slight gap */
        backdrop-filter: none; /* Remove blur from container */
    }
    
    .search-form-container.mobile-show {
        display: block;
        animation: slideDown 0.2s ease-out; /* Faster, snappier animation */
    }
    
    /* Input box styling for mobile */
    .search-form-container form.search {
        border-radius: 8px; /* Softer, more modern rounded rectangle */
        background: rgba(35, 35, 35, 0.95); /* Elegant dark grey with slight transparency */
        border: 1px solid rgba(255, 255, 255, 0.08); /* Very subtle border */
        padding: 0; /* Let internal elements handle spacing */
        height: 42px; /* Slimmer, sleeker height */
        box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important; /* Elegant floating shadow */
        outline: none !important; /* Prevent focus outline */
        align-items: center; /* Ensure contents are centered vertically */
        backdrop-filter: blur(8px); /* Add blur directly to the bar for a premium glass feel */
    }

    /* Move button (icon) styling for mobile */
    .search-form-container form.search button {
        color: #9ca3af; /* Soft grey icon, not harsh white */
        padding: 0 12px; /* Adjust padding */
        transition: color 0.2s;
    }
    
    .search-form-container form.search button i {
        font-size: 16px; /* perfectly sized icon */
    }

    /* Prevent white background on focus for mobile */
    .search-form-container form.search.on,
    .search-form-container form.search:focus-within,
    .search-form-container form.search:active {
        background: rgba(45, 45, 45, 0.98) !important; /* Slightly lighter when active */
        box-shadow: 0 8px 24px rgba(0,0,0,0.5) !important;
        outline: none !important;
        border: 1px solid rgba(255,255,255,0.15) !important; /* Slightly visible border on focus */
    }
    
    .search-form-container form.search:focus-within button {
        color: #ffffff; /* Icon brightens when focused */
    }
    
    /* Ensure input stays transparent on focus and styling */
    .search-form-container form.search input,
    .search-form-container form.search input:focus,
    .search-form-container form.search input:active {
        background: transparent !important;
        outline: none !important;
        box-shadow: none !important;
        color: #f3f4f6; /* Off-white text, easier on eyes */
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        font-size: 15px; /* Perfect reading size */
        padding-left: 0; /* Icon already has padding */
        width: 100%;
    }
    
    /* Placeholder styling */
    .search-form-container form.search input::placeholder {
        color: #6b7280; /* Elegant muted placeholder */
        font-weight: 400;
    }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 3. User Menu / Auth Buttons Logic */

/* Shared Styles */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-menu button.btn {
    transition: all 0.3s ease;
}

/* Mobile Styles (< 768px) */
@media (max-width: 768px) {
    /* Hide Sign Up Button on Mobile */
    .signup-btn {
        display: none !important;
    }
    
    /* Modify Login Button to be Icon Only */
    .login-btn span {
        display: none !important; /* Hide "Log in" text */
    }
    
    .login-btn {
        padding: 0 !important;
        border-radius: 50% !important;
        width: 40px;
        height: 40px;
        min-width: 40px; /* Prevent shrinking */
        display: flex !important;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(255,255,255,0.2) !important;
        background: transparent !important;
    }
    
    /* Ensure Icon is visible */
    .login-btn .avatar {
        display: block !important;
        font-size: 18px;
        color: #fff;
        margin: 0 !important;
    }
    
    /* Logged In User Avatar */
    .user-menu .avatar {
        width: 35px;
        height: 35px;
        border-radius: 50%;
        border: 2px solid rgba(255,255,255,0.2);
    }
    
    /* Dropdown position adjustment for mobile */
    .user-menu .sub-menu {
        right: 10px;
        left: auto;
    }
}

/* Ensure logged-in dropdown styles are consistent */
.user-menu .sub-menu {
    background: #1f1f1f;
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 10px 0;
    min-width: 150px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 101;
    display: none;
    margin-top: 10px;
}

.user-menu.on .sub-menu {
    display: block;
    animation: fadeIn 0.2s ease;
}

.user-menu .sub-menu li {
    list-style: none;
}

.user-menu .sub-menu li a {
    color: #ccc;
    padding: 10px 20px;
    display: block;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 14px;
}

.user-menu .sub-menu li a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
