/* Header Specific Variables (if needed to override or ensure standalone capability) */
/* We'll use the variables defined in root, but include the core header styles here */

#main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--card-bg, #ffffff);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: transform 0.3s ease-in-out;
}

#main-header.header-hidden {
    transform: translateY(-100%);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color, #334155);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: #f1f5f9;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color, #334155);
    letter-spacing: -0.5px;
}

.search-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    margin: 0 2rem;
    max-width: 600px;
}

.search-box {
    display: flex;
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 40px;
    overflow: hidden;
    background-color: var(--bg-color, #f4f4f9);
}

.search-box input {
    flex-grow: 1;
    padding: 0.5rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-color, #334155);
    outline: none;
    font-size: 1rem;
}

.search-box input:disabled {
    cursor: not-allowed;
    color: var(--text-muted, #64748b);
}

.search-btn {
    background-color: #f8fafc;
    border: none;
    border-left: 1px solid #cbd5e1;
    padding: 0 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color, #334155);
    transition: background-color 0.2s;
}

.search-btn:hover {
    background-color: #e2e8f0;
}

.search-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 200px;
    justify-content: flex-end;
}

.notification-btn {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: #ef4444; /* red */
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 2px 4px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
    border: 2px solid var(--card-bg, #ffffff);
}

.profile-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
    width: 32px;
    height: 32px;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sign-in-btn {
    display: flex;
    align-items: center;
    border: 1px solid #e2e8f0;
    background-color: transparent;
    color: #065fd4;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.sign-in-btn:hover {
    background-color: #def1ff;
    border-color: transparent;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background-color: var(--card-bg, #ffffff);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    display: none;
    flex-direction: column;
    z-index: 1000;
    border: 1px solid #e2e8f0;
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    color: var(--text-color, #334155);
    text-decoration: none;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: #f1f5f9;
}

/* Side Drawer */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1005;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
}

.drawer-overlay.active {
    opacity: 1;
    visibility: visible;
}

.side-drawer {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100%;
    background-color: var(--card-bg, #ffffff);
    z-index: 1010;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.side-drawer.active {
    left: 0;
}

.drawer-header {
    display: flex;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.drawer-links {
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    overflow-y: auto;
}

.drawer-links a {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-color, #334155);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.drawer-links a:hover {
    background-color: #f1f5f9;
}

.drawer-links svg {
    color: var(--text-muted, #64748b);
}

@media (max-width: 768px) {
    .header-container {
        padding: 1rem;
    }
    .header-left, .nav-right {
        min-width: auto;
    }
    .search-container {
        display: none; /* Handled by mobile logic below */
    }
}

/* Search Specific Styles */
.search-container {
    position: relative;
    box-sizing: border-box;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--card-bg, #ffffff);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 0.5rem;
    z-index: 1001;
    display: none;
    flex-direction: column;
    max-height: 400px;
    overflow-y: auto;
}

.search-dropdown.show {
    display: flex;
}

.search-dropdown-item {
    display: flex;
    align-items: center;
    padding: 10px;
    text-decoration: none;
    color: var(--text-color, #334155);
    border-bottom: 1px solid #f1f5f9;
    gap: 10px;
    transition: background-color 0.2s;
}

.search-dropdown-item:last-child {
    border-bottom: none;
}

.search-dropdown-item:hover {
    background-color: #f1f5f9;
}

.search-dropdown-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.search-dropdown-title {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.mobile-only {
    display: none !important;
}

.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }

    .header-container {
        padding: 0.5rem 1rem;
    }

    /* Mobile Search Expansion styling */
    .search-container.mobile-active {
        display: flex !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: var(--card-bg, #ffffff);
        z-index: 1010;
        align-items: center;
        padding: 0 1rem;
        margin: 0;
        max-width: none;
        animation: slideInLeft 0.3s forwards;
        box-sizing: border-box;
    }

    @keyframes slideInLeft {
        from { transform: translateX(100%); }
        to { transform: translateX(0); }
    }

    .search-container.mobile-active .search-box {
        margin-left: 8px;
        flex-grow: 1;
        /* Ensure it does not cause overflow */
        max-width: 100%;
    }

    .search-container.mobile-active .search-box input {
        min-width: 0; /* Allows input to shrink below its default minimum width */
        padding: 0.5rem 1rem; /* Reduce padding on mobile */
    }

    .search-container.mobile-active .search-btn {
        padding: 0 0.75rem; /* Reduce search button padding to keep magnifying icon within bounds */
    }

    .search-dropdown-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 1.2;
    }

    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: var(--card-bg, #ffffff);
        border-top: 1px solid #e2e8f0;
        justify-content: space-around;
        align-items: center;
        padding: 10px 0;
        z-index: 1005;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    }

    .mobile-nav-btn {
        flex: 1;
        display: flex;
        justify-content: center;
        align-items: center;
        border: none;
        background: none;
        color: var(--text-color, #334155);
        padding: 8px;
        position: relative;
    }

    .mobile-nav-btn svg {
        width: 20px;
        height: 20px;
        z-index: 1;
    }

    .mobile-nav-btn .profile-avatar {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        z-index: 1;
    }

    .mobile-nav-btn.active-nav-item::after {
        content: '';
        position: absolute;
        width: 36px;
        height: 36px;
        background-color: var(--hover-bg, #f1f5f9);
        border-radius: 8px;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        pointer-events: none;
        z-index: 0;
    }

    /* Adjust main body to account for bottom nav */
    body {
        padding-bottom: 70px;
    }

    /* Position dropdowns correctly for mobile bottom nav */
    #profile-dropdown, #signin-dropdown {
        top: auto;
        bottom: 70px; /* Above the bottom nav */
        right: 10px;
        left: auto;
        margin-top: 0;
        margin-bottom: 0.5rem;
    }
}

/* Bottom links in drawer */
.drawer-bottom-links {
    margin-top: auto;
    padding-bottom: 1rem;
    border-top: 1px solid #f1f5f9;
}

.drawer-bottom-links a {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-color, #334155);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.drawer-bottom-links a:hover {
    background-color: #f1f5f9;
}

.drawer-bottom-links svg {
    color: var(--text-muted, #64748b);
}
