/* EcoMap AI Discover — unified search + ask affordances */

.discover-shell--header {
    position: relative;
    flex-wrap: wrap;
    align-items: center;
}

/* Dual search + AI icon */
.search-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 28px;
    height: 28px;
}

.search-icon-wrap .search-icon {
    position: static;
    transform: none;
    font-size: 16px;
    color: #888;
}

.search-ai-spark {
    position: absolute;
    top: -1px;
    right: 2px;
    font-size: 9px;
    line-height: 1;
    color: #4CAF50;
    font-weight: 700;
    pointer-events: none;
}

.search-box.discover-mode-search {
    border-color: #4CAF50;
    box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.25), 0 0 8px rgba(76, 175, 80, 0.12);
}

.search-box.discover-mode-question {
    border-color: #2e7d32;
    box-shadow:
        0 0 0 1px rgba(46, 125, 50, 0.35),
        0 0 12px rgba(76, 175, 80, 0.18);
}

.search-box.discover-mode-question .search-ai-spark {
    color: #1b5e20;
    transform: scale(1.15);
}

.discover-shell--header.discover-mode-search .mobile-header-search-input {
    border-color: #4CAF50;
    box-shadow: 0 0 0 1px rgba(76, 175, 80, 0.2), 0 2px 8px rgba(0, 0, 0, 0.05);
}

.discover-shell--header.discover-mode-question .mobile-header-search-input {
    border-color: #2e7d32;
    box-shadow: 0 0 0 1px rgba(46, 125, 50, 0.3), 0 2px 10px rgba(76, 175, 80, 0.12);
}

/* Example question chips */
.ai-suggest-section {
    padding: 4px 4px 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color, #e8e8e8);
}

.ai-suggest-section[hidden] {
    display: none !important;
}

.ai-suggest-label {
    margin: 0 0 8px;
    padding: 0 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9ca3af;
}

.ai-suggest-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-suggest-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 7px 12px;
    border: 1px solid rgba(76, 175, 80, 0.25);
    border-radius: 999px;
    background: rgba(76, 175, 80, 0.08);
    color: #2e7d32;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    text-align: left;
}

.ai-suggest-chip::before {
    content: '✦';
    font-size: 10px;
    opacity: 0.75;
    flex-shrink: 0;
}

.ai-suggest-chip:hover,
.ai-suggest-chip:focus-visible {
    background: rgba(76, 175, 80, 0.16);
    border-color: rgba(76, 175, 80, 0.45);
    outline: none;
}

.ai-suggest-chip--pulse {
    animation: ai-chip-pulse 1.6s ease-in-out 2;
}

@keyframes ai-chip-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); }
    50% { box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.22); }
}

@keyframes ai-history-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 125, 50, 0); }
    50% { box-shadow: 0 0 0 5px rgba(76, 175, 80, 0.35); }
}

.search-history-btn.ai-history-pulse {
    border-radius: 50%;
    animation: ai-history-pulse 1.2s ease-in-out 2;
}


/* Unified search + AI ask in results dropdown */

.search-ask-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 8px 0 4px;
    padding: 7px 14px;
    border: none;
    border-radius: 999px;
    background: #f1f3f4;
    color: #202124;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.search-ask-btn__label {
    display: inline-block;
}

.search-ask-btn:hover,
.search-ask-btn:focus-visible {
    background: #e8eaed;
    color: #202124;
    outline: none;
}

.search-ask-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #f1f3f4;
    color: #5f6368;
}

.search-ask-btn:disabled:hover {
    background: #f1f3f4;
    color: #5f6368;
}

.search-ask-btn[hidden] {
    display: none !important;
}

.search-history-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: 0 2px 0 4px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.search-history-btn:hover,
.search-history-btn:focus-visible {
    background: rgba(0, 0, 0, 0.06);
    color: #2e7d32;
    outline: none;
}

.search-history-btn[hidden] {
    display: none !important;
}

/* Mobile header: keep history / ask / clear on one vertically centered row */
.search-input-wrapper .search-trailing-actions {
    position: absolute;
    right: 8px;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
    pointer-events: none;
}

.search-input-wrapper .search-trailing-actions > * {
    pointer-events: auto;
}

.search-input-wrapper .search-history-btn {
    position: static;
    top: auto;
    right: auto;
    transform: none;
    margin: 0;
    width: 28px;
    height: 28px;
    font-size: 14px;
    line-height: 1;
    z-index: auto;
}

.search-input-wrapper .search-history-btn i {
    display: block;
    line-height: 1;
}

.search-input-wrapper .search-ask-btn {
    position: static;
    top: auto;
    right: auto;
    transform: none;
    margin: 0;
    padding: 5px 12px 5px 10px;
    font-size: 12px;
    z-index: auto;
}

.search-input-wrapper .search-clear-btn {
    position: static;
    top: auto;
    right: auto;
    transform: none;
    margin: 0;
    padding: 6px;
    line-height: 1;
}

.search-input-wrapper:has(.search-ask-btn) .mobile-header-search-input {
    padding-right: 128px;
}

.search-input-wrapper:has(.search-history-btn:not([hidden])) .mobile-header-search-input {
    padding-right: 72px;
}

.search-input-wrapper:has(.search-ask-btn):has(.search-history-btn:not([hidden])) .mobile-header-search-input {
    padding-right: 168px;
}

.search-box:has(.search-history-btn:not([hidden])) .search-input {
    padding-right: 4px;
}

.search-box:has(.search-ask-btn) .search-input {
    padding-right: 118px;
}

.search-box:has(.search-ask-btn):has(.search-history-btn:not([hidden])) .search-input {
    padding-right: 154px;
}

/* AI answer block inside search-results */
.ai-results-section {
    position: relative;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
}

/* Zero-height sticky anchor — no empty row, pill floats top-right */
.ai-panel-toolbar {
    position: sticky;
    top: 0;
    z-index: 3;
    height: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
    pointer-events: none;
}

.ai-panel-toolbar-actions {
    position: absolute;
    top: 0;
    right: 0;
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    padding: 2px;
    background: var(--bg-white, #fff);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 9px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.ai-panel-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #888;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-panel-btn.ai-close-btn {
    border-radius: 0 6px 6px 0;
    border-left: 1px solid rgba(0, 0, 0, 0.07);
    margin-left: 1px;
}

.ai-share-wrap .ai-panel-btn.ai-share-btn {
    border-radius: 6px 0 0 6px;
}

.ai-panel-btn:hover,
.ai-panel-btn:focus-visible {
    background: rgba(0, 0, 0, 0.06);
    color: #555;
    outline: none;
}

.ai-share-wrap {
    position: relative;
}

.ai-share-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 212px;
    padding: 6px;
    background: var(--bg-white, #fff);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.06),
        0 12px 28px -4px rgba(0, 0, 0, 0.14);
    z-index: 10;
    animation: ai-share-in 0.16s ease-out;
}

@keyframes ai-share-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.ai-share-menu[hidden] {
    display: none !important;
}

.ai-share-menu-head {
    padding: 4px 10px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #9ca3af;
    user-select: none;
}

.ai-share-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 8px;
    border: none;
    border-radius: 8px;
    background: none;
    text-align: left;
    font: inherit;
    color: var(--text-main, #333);
    cursor: pointer;
    transition: background 0.14s ease;
}

.ai-share-item:hover,
.ai-share-item:focus-visible {
    background: #f4f6f8;
    outline: none;
}

.ai-share-item:active {
    background: #eef1f4;
}

.ai-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    font-size: 14px;
    flex-shrink: 0;
    transition: background 0.14s ease, color 0.14s ease, transform 0.14s ease;
}

.ai-share-item:hover .ai-share-icon {
    transform: scale(1.04);
}

.ai-share-icon--wa {
    background: #e8faf0;
    color: #25d366;
}

.ai-share-item:hover .ai-share-icon--wa {
    background: #25d366;
    color: #fff;
}

.ai-share-icon--email {
    background: #eef4ff;
    color: #4f7cff;
}

.ai-share-item:hover .ai-share-icon--email {
    background: #4f7cff;
    color: #fff;
}

.ai-share-icon--print {
    background: #f3f4f6;
    color: #6b7280;
}

.ai-share-item:hover .ai-share-icon--print {
    background: #6b7280;
    color: #fff;
}

.ai-share-label {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: #374151;
}

.search-results.ai-history-mode {
    max-height: min(480px, 60vh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.search-results.ai-history-mode .ai-results-section {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.search-results.ai-history-mode .search-section {
    display: none !important;
}

.ai-results-section[hidden] {
    display: none !important;
}

/* Hide keyword search sections while AI answer is loading or shown */
.search-results.ai-ask-active .search-section,
.search-results.ai-ask-active .search-empty-msg {
    display: none !important;
}

.search-results.ai-suggest-mode .search-section {
    display: none !important;
}

.ai-chat-disclaimer {
    margin: 10px 0 2px;
    padding-top: 8px;
    border-top: 1px solid #f0f0f0;
    font-size: 11px;
    line-height: 1.45;
    color: #9ca3af;
}

.ai-results-section .ai-msg {
    padding: 10px 12px;
    border-radius: 10px;
    line-height: 1.5;
    margin-bottom: 8px;
    font-size: 14px;
}

.ai-results-section .ai-msg-user {
    background: rgba(0, 123, 255, 0.1);
    color: var(--text-main, #333);
}

.ai-results-section .ai-msg-assistant {
    background: #f8f9fa;
    color: var(--text-main, #333);
    border: 1px solid #eee;
}

.ai-results-section .ai-msg-datetime {
    margin: 0 0 4px 0;
    padding: 0;
    font-size: 11px;
    line-height: 1.3;
    color: #9ca3af;
}

.ai-history-load-sentinel {
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
}

.ai-history-loading-older {
    margin: 8px 0 4px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.4;
    color: #9ca3af;
    text-align: center;
}

.ai-results-section .ai-msg-text {
    margin: 0;
}

.ai-ref-chip {
    display: inline-block;
    vertical-align: middle;
    border: none;
    padding: 2px 8px;
    margin: 3px 2px;
    border-radius: 8px;
    background: rgba(0, 123, 255, 0.30);
    cursor: pointer;
    font: inherit;
    color: inherit;
    line-height: 1.4;
}

.ai-ref-chip:hover { background: rgba(0, 123, 255, 0.45); }
.ai-ref-chip:focus-visible { outline: 2px solid rgba(0, 123, 255, 0.6); outline-offset: 1px; }

.ai-ref-chip--news:first-of-type {
    margin-top: 6px;
}

.ai-ref-chip--news {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    cursor: pointer;
    background: rgba(16, 185, 129, 0.28);
    padding: 7px 10px;
    margin: 0 0 4px;
    line-height: 1.35;
}
.ai-ref-chip--news:hover { background: rgba(16, 185, 129, 0.42); }

.ai-ref-chip__title {
    font: inherit;
    color: inherit;
}

.ai-ref-chip__when {
    font-size: 0.78em;
    font-weight: 400;
    opacity: 0.82;
    margin-left: 0.45em;
    white-space: nowrap;
}

.ai-typo-suggest {
    display: inline;
    margin-left: 0.35rem;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    font: inherit;
    color: #0b5ed7;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ai-typo-suggest:hover { color: #084298; }
.ai-typo-suggest:focus-visible { outline: 2px solid rgba(0, 123, 255, 0.6); outline-offset: 2px; }

.ai-nav-chip {
    display: inline;
    vertical-align: baseline;
    border: none;
    padding: 2px 8px;
    margin: 0 2px;
    border-radius: 8px;
    background: rgba(0, 123, 255, 0.30);
    cursor: pointer;
    font: inherit;
    color: inherit;
    line-height: 1.4;
}
.ai-nav-chip:hover { background: rgba(0, 123, 255, 0.45); }
.ai-nav-chip:focus-visible { outline: 2px solid rgba(0, 123, 255, 0.6); outline-offset: 1px; }

.ai-rate-limit-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: #2563eb;
    text-decoration: underline;
    cursor: pointer;
}

.ai-rate-limit-link:hover { color: #1d4ed8; }

.ai-feedback { margin-top: 4px; display: flex; gap: 6px; }
.ai-feedback button { background: none; border: none; cursor: pointer; opacity: 0.6; font-size: 16px; }
.ai-feedback button.chosen { opacity: 1; }

.ai-sor-working {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
    font-size: 13px;
    color: var(--text-muted, #888);
}

.ai-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.4;
    animation: ai-blink 1.2s infinite;
}

.ai-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-blink {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}
