/* ============================================================
   AROMEX SEARCH BAR
   Loupe dans le header → bar dépliable plein largeur + dropdown
   ============================================================ */

.aromex-search {
    position: static;
    display: inline-flex;
    align-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

/* Override : on neutralise le transform de fadeInLeft sur la search bar
   pour ne pas créer de containing block qui casse position:absolute du panel */
#aromex-header .header-actions > .aromex-search {
    transform: none !important;
    animation: none !important;
    opacity: 1 !important;
}

#aromex-header .header-actions {
    position: relative;
}

.aromex-search-trigger {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease, opacity 0.2s ease;
    width: 36px;
    height: 36px;
}

.aromex-search.is-open .aromex-search-trigger {
    opacity: 0;
    pointer-events: none;
}

.aromex-search-trigger:hover {
    background: #f0f0f0;
}

.aromex-search-trigger svg path {
    transition: fill 0.2s ease;
}

.aromex-search-trigger:hover svg path {
    fill: #000;
}

/* Panel : position: fixed, dimensions définies dynamiquement par JS via custom properties.
   --aromex-panel-collapsed-left : position au repos (collé à droite, près de la loupe)
   --aromex-panel-open-left      : position ouverte (juste après le logo)
   --aromex-panel-right          : position du bord droit (juste avant les actions) */
.aromex-search-panel {
    position: fixed;
    top: var(--aromex-panel-top, 16px);
    right: var(--aromex-panel-right, 30px);
    left: var(--aromex-panel-collapsed-left, calc(100vw - 60px));
    height: 48px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    padding: 0 8px 0 12px;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                right 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                visibility 0s linear 0.35s;
    z-index: 1500;
    overflow: visible;
    box-sizing: border-box;
}

.aromex-search.is-open .aromex-search-panel {
    left: var(--aromex-panel-open-left, 30px);
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                right 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.25s ease,
                visibility 0s linear 0s;
}


.aromex-search-close {
    background: transparent;
    border: none;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #666;
    transition: background 0.2s ease, color 0.2s ease;
    flex-shrink: 0;
}

.aromex-search-close:hover {
    background: #f0f0f0;
    color: #000;
}

.aromex-search-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px;
    min-width: 0;
}

.aromex-search-input-icon {
    flex-shrink: 0;
}

.aromex-search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: #222;
    min-width: 0;
    padding: 0;
    height: 32px;
    font-family: inherit;
}

.aromex-search-input::placeholder {
    color: #999;
}

.aromex-search-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top-color: #666;
    border-radius: 50%;
    animation: aromex-search-spin 0.7s linear infinite;
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.aromex-search.is-loading .aromex-search-spinner {
    opacity: 1;
}

@keyframes aromex-search-spin {
    to { transform: rotate(360deg); }
}

/* Dropdown des résultats */
.aromex-search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 70vh;
    overflow-y: auto;
    display: none;
    z-index: 1001;
}

.aromex-search.has-results .aromex-search-results,
.aromex-search.has-message .aromex-search-results {
    display: block;
}

.aromex-search-section {
    border-bottom: 1px solid #f0f0f0;
}

.aromex-search-section:last-child {
    border-bottom: none;
}

.aromex-search-section-title {
    padding: 10px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    background: #fafafa;
    position: sticky;
    top: 0;
    z-index: 1;
}

.aromex-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.aromex-search-result-item:hover,
.aromex-search-result-item.is-active {
    background: #f5f5f5;
}

.aromex-search-result-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    background: #f5f5f5;
    flex-shrink: 0;
}

.aromex-search-result-thumb-placeholder {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    flex-shrink: 0;
    font-size: 20px;
}

.aromex-search-result-content {
    flex: 1;
    min-width: 0;
}

.aromex-search-result-name {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aromex-search-result-meta {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aromex-search-result-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-right: 4px;
    vertical-align: middle;
}

.aromex-search-result-badge.badge-affiliate {
    background: #fff4e0;
    color: #b87a00;
}

.aromex-search-result-badge.badge-history {
    background: #e0f0ff;
    color: #0066b8;
}

.aromex-search-result-badge.badge-group {
    background: #f0e0ff;
    color: #7a00b8;
}

.aromex-search-result-price {
    font-size: 13px;
    font-weight: 600;
    color: #000;
    flex-shrink: 0;
    margin-left: 8px;
}

.aromex-search-highlight {
    background: rgba(255, 220, 0, 0.4);
    font-weight: 700;
    border-radius: 2px;
    padding: 0 1px;
}

.aromex-search-message {
    padding: 24px 16px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.aromex-search-message strong {
    color: #444;
}

/* Mobile : font-size 16px pour éviter le zoom iOS au focus */
@media (max-width: 768px) {
    .aromex-search-input {
        font-size: 16px;
    }
}
