/* Header */
.main-header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-top { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 1rem; 
}

.header-actions { display: flex; gap: 1.5rem; align-items: center; }

/* Navigation & Logo */
.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

/* User Profile & Menu */
.user-menu { position: relative; display: inline-block; }
.user-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.6rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
}

.user-btn:hover .user-avatar-circle { transform: scale(1.1); }

.user-avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.user-avatar-circle.large { width: 60px; height: 60px; font-size: 1.5rem; }

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    background: var(--card);
    min-width: 200px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    z-index: 200;
    overflow: hidden;
    animation: fadeIn 0.3s ease-out;
}

.dropdown-content a {
    display: block;
    padding: 12px 16px;
    font-size: 0.95rem;
    color: var(--text);
    text-decoration: none;
}
.dropdown-content a:hover { background: var(--bg); color: var(--primary); }

/* Search & Filter Controls */
.header-controls {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.search-filter-layout {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: nowrap; /* Keep on one line on desktop */
}

.search-container {
    flex: 0 0 350px; /* Fixed width for search input on desktop */
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 0.5rem 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    position: relative;
    transition: var(--transition);
}

.search-container:focus-within {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search-container input {
    background: transparent;
    border: none;
    color: inherit;
    outline: none;
    width: 100%;
    font-size: 0.95rem;
    padding-right: 2.5rem; /* Space for the X button */
}

.search-clear {
    position: absolute;
    right: 0.8rem;
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
    z-index: 10;
    display: none; /* Controlled by JS or inline if value exists */
}

.search-clear:hover { color: var(--primary-hover); transform: scale(1.2); }

/* Tag Zones */
.tag-zones-persistent { flex: 1; min-width: 0; }
.active-tags-container { display: flex; gap: 1rem; width: 100%; }
.tag-group { flex: 1; min-width: 0; }

.tag-zone {
    min-height: 42px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.2rem 0.8rem;
    gap: 0.5rem;
    transition: var(--transition);
    overflow: hidden;
}

.tag-zone:hover { border-color: var(--primary); background: rgba(255, 255, 255, 0.08); }

.tag-zone:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    font-size: 0.8rem;
    opacity: 0.7;
    pointer-events: none;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
}

.modal-content {
    background: var(--card);
    margin: 8% auto;
    padding: 2.5rem;
    border: 1px solid var(--border);
    width: 90%;
    max-width: 550px;
    border-radius: var(--radius-md);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.modal-close { cursor: pointer; font-size: 2rem; color: var(--muted); }
.modal-close:hover { color: var(--danger); }

.user-profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.user-info h3 { margin: 0; font-size: 1.4rem; }
.member-since { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.9rem; }

.danger-zone {
    margin-top: 3.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.danger-zone h4 { color: var(--danger); margin-bottom: 0.5rem; }
.danger-zone p { font-size: 0.9rem; color: var(--muted); margin-bottom: 1rem; }

@media (max-width: 1024px) {
    .search-filter-layout { flex-wrap: wrap; }
    .search-container { flex: 1; }
}

/* Homepage Grid Limit */
.homepage-grid .filterable-card:nth-child(n+9) {
    display: none;
}

body.filtering-active .homepage-grid .filterable-card:nth-child(n+9) {
    display: block;
}

/* Active Filter Tags */
.active-inc { background: var(--primary) !important; color: #fff !important; }
.active-exc { background: var(--danger) !important; color: #fff !important; }
.active-inc span, .active-exc span { margin-left: 5px; opacity: 0.7; }

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

/* Google Login Button */
.google-login-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    background: #fff;
    color: #444;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
}

[data-theme="dark"] .google-login-btn {
    background: #2d3748;
    color: #fff;
    border-color: #4a5568;
}

.google-login-btn img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.user-email {
    margin: 0;
    font-size: 0.9rem;
    color: var(--primary);
    opacity: 0.9;
}
