/* Universal App Header - Google Cloud Style */

.app-header {
    height: 48px;
    background: #fff;
    border-bottom: 1px solid #dadce0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    z-index: 1000;
    gap: 16px;
}

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

.header-menu-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #5f6368;
    font-size: 18px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.header-menu-btn:hover {
    background-color: #f1f3f4;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-text {
    font-size: 18px;
    font-weight: 400;
    color: #5f6368;
    letter-spacing: -0.5px;
}

.header-logo-img {
    height: 28px;
    width: auto;
}

.header-center {
    flex: 1;
    max-width: 720px;
    display: flex;
    justify-content: center;
}

.header-search {
    width: 100%;
    max-width: 720px;
    height: 36px;
    background: #f1f3f4;
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    transition: background-color 0.2s, box-shadow 0.2s;
    position: relative;
}

.header-search:focus-within {
    background: #fff;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 2px 6px 2px rgba(60, 64, 67, 0.15);
}

.header-search i {
    color: #5f6368;
    font-size: 14px;
}

.header-search input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    color: #202124;
}

.header-search input::placeholder {
    color: #5f6368;
}

/* Search Dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 2px 0 rgba(60, 64, 67, 0.3), 0 2px 6px 2px rgba(60, 64, 67, 0.15);
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 1001;
}

.search-dropdown.active {
    display: block;
}

.search-results {
    padding: 8px 0;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    text-decoration: none;
    color: #202124;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: #f1f3f4;
}

.search-result-item i {
    font-size: 20px;
    color: #5f6368;
    width: 24px;
    text-align: center;
}

.search-result-info {
    flex: 1;
}

.search-result-name {
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 2px;
}

.search-result-desc {
    font-size: 12px;
    color: #5f6368;
}

.search-empty {
    padding: 24px 16px;
    text-align: center;
    color: #5f6368;
    font-size: 14px;
}

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

.header-icon-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #5f6368;
    font-size: 18px;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

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

.header-user {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e8f0fe;
    color: #1967d2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-left: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.header-user:hover {
    background-color: #d2e3fc;
}

/* Services Sidebar */
.services-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: #fff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.services-sidebar.open {
    left: 0;
}

.services-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #dadce0;
}

.services-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    color: #202124;
}

.services-close-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #5f6368;
    font-size: 18px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.services-close-btn:hover {
    background-color: #f1f3f4;
}

.services-list {
    padding: 8px 0;
}

.service-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    color: #202124;
    text-decoration: none;
    transition: background-color 0.2s;
    cursor: pointer;
}

.service-item:hover {
    background-color: #f1f3f4;
}

.service-item i {
    font-size: 24px;
    color: #5f6368;
    width: 24px;
    text-align: center;
}

.service-info {
    flex: 1;
}

.service-name {
    font-size: 14px;
    font-weight: 500;
    color: #202124;
    margin-bottom: 2px;
}

.service-desc {
    font-size: 12px;
    color: #5f6368;
}

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

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

/* Adjust main containers to account for header */
.full-width-content {
    margin-top: 48px;
}

.sql-assist-container {
    margin-top: 0 !important;
    /* Already handled by full-width-content */
}

/* ==================== Responsive: Tablet (≤1024px) ==================== */
@media (max-width: 1024px) {
    .header-center {
        max-width: 400px;
    }

    .header-left,
    .header-right {
        min-width: auto;
    }

    .header-search input::placeholder {
        font-size: 13px;
    }
}

/* ==================== Responsive: Small tablet / large phone (≤768px) ==================== */
@media (max-width: 768px) {
    .app-header {
        padding: 0 4px;
        gap: 8px;
    }

    /* Hide desktop search bar */
    .header-center {
        display: none;
    }

    /* Hide logo text, keep icon */
    .logo-text {
        display: none;
    }

    .header-left {
        gap: 8px;
    }

    /* Touch-friendly icon buttons */
    .header-icon-btn,
    .header-menu-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
        -webkit-tap-highlight-color: transparent;
    }

    .header-right {
        gap: 2px;
    }

    /* Show mobile search button */
    .mobile-search-btn {
        display: flex !important;
    }

    /* Full-width sidebar on mobile */
    .services-sidebar {
        width: 100%;
        left: -100%;
    }
}

/* ==================== Responsive: Phone (≤576px) ==================== */
@media (max-width: 576px) {
    .app-header {
        height: 44px;
        padding: 0 4px;
        padding-left: max(4px, env(safe-area-inset-left));
        padding-right: max(4px, env(safe-area-inset-right));
    }

    /* Hide utility buttons, keep essentials */
    .header-icon-btn[title="Help"],
    .header-icon-btn[title="Settings"],
    .header-icon-btn[title="Notifications"] {
        display: none;
    }

    .header-menu-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .header-logo-img {
        height: 24px;
    }

    .header-user {
        width: 28px;
        height: 28px;
        font-size: 18px;
        margin-left: 4px;
    }
}

/* ==================== Mobile Search Overlay ==================== */
.mobile-search-btn {
    display: none;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #5f6368;
    font-size: 18px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    -webkit-tap-highlight-color: transparent;
}

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

.mobile-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    z-index: 2001;
    display: flex;
    flex-direction: column;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.mobile-search-overlay.active {
    transform: translateY(0);
    opacity: 1;
}

.mobile-search-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid #dadce0;
    background: #fff;
}

.mobile-search-header .header-search {
    flex: 1;
    max-width: none;
}

.mobile-search-close-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #5f6368;
    font-size: 20px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s;
}

.mobile-search-close-btn:hover {
    background-color: #f1f3f4;
}

.mobile-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.mobile-search-results .search-result-item {
    padding: 14px 16px;
}

.mobile-search-empty {
    padding: 40px 16px;
    text-align: center;
    color: #5f6368;
    font-size: 15px;
}