/* ===== Header - 345tool.com ===== */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    height: 60px;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.header-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 15px;
    display: flex;
    align-items: center;
    height: 100%;
    gap: 16px;
}

/* Brand */
.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.brand-logo {
    height: 36px;
    width: auto;
}

.brand-name {
    font-size: 25px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

/* Navigation */
.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    color: var(--text-tertiary);
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    font-size: 17px;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--card-hover-bg);
}

.nav-link.active {
    color: var(--text-primary);
    font-weight: 600;
}

/* Search */
.header-search {
    flex: 1;
    max-width: 400px;
    position: relative;
    margin-left: auto;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 8px 36px 8px 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: background 0.2s, border-color 0.2s;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--text-tertiary);
    background: var(--bg-primary);
}

.search-shortcut {
    position: absolute;
    right: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 14px;
    color: var(--text-muted);
    font-family: monospace;
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 9999;
}

[data-theme="dark"] .search-results {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.15s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--card-hover-bg);
}

.search-result-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
    object-fit: cover;
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.search-result-desc {
    font-size: 14px;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-badge {
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--badge-bg);
    color: var(--text-tertiary);
    white-space: nowrap;
}

.search-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 16px;
}

/* Theme Toggle */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== User Section (Desktop) ===== */
.header-user {
    flex-shrink: 0;
    position: relative;
}

.google-login-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xs);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.google-login-btn:hover {
    background: var(--card-hover-bg);
    border-color: var(--text-tertiary);
}

.google-login-btn svg {
    flex-shrink: 0;
}

.user-avatar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
    transition: border-color 0.2s;
}

.user-avatar-btn:hover .user-avatar {
    border-color: var(--text-tertiary);
}

.user-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    padding: 4px 0;
}

[data-theme="dark"] .user-dropdown {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.user-dropdown.open {
    display: block;
}

.user-dropdown-info {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
}

.user-dropdown-name {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-credits {
    display: block;
    font-size: 14px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.user-dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: 16px;
    color: var(--text-secondary);
    text-decoration: none;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.user-dropdown-item:hover {
    background: var(--card-hover-bg);
    color: var(--text-primary);
}

.user-dropdown-logout {
    color: var(--text-tertiary);
    border-top: 1px solid var(--border-color);
}

/* Mobile nav user section */
.nav-user-mobile {
    display: none;
    padding-top: 8px;
    margin-top: 8px;
    border-top: 1px solid var(--border-color);
}

.nav-login-btn,
.nav-logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    text-align: left;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-tertiary);
    transition: background 0.2s, color 0.2s;
}

.theme-toggle:hover {
    background: var(--card-hover-bg);
    color: var(--text-primary);
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: block; }

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    width: 36px;
    height: 36px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 6px;
}

.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-tertiary);
    border-radius: 2px;
    transition: transform 0.2s;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
    .mobile-menu-btn {
        display: flex;
    }

    .header-nav {
        display: none;
    }

    .header-nav.mobile-open {
        display: flex;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--header-bg);
        padding: 12px;
        border-bottom: 1px solid var(--header-border);
    }

    .header-nav.mobile-open .nav-user-mobile {
        display: block;
        text-align: center;
    }

    .header-nav.mobile-open .nav-link {
        text-align: center;
    }

    /* Hide desktop user section on mobile */
    .header-user {
        display: none;
    }
}

@media (max-width: 768px) {
    /* Brand: compact for phones */
    .brand-name {
        font-size: 21px;
    }

    /* Search: narrower on phones */
    .header-search {
        max-width: 200px;
    }

    .search-shortcut {
        display: none;
    }

    /* Search results: break out of narrow search box, full-width centered */
    .search-results {
        position: fixed;
        top: 66px;
        left: 15px;
        right: 15px;
        width: auto;
    }
}
