/**
 * FORDIPS TECH - PRODUCT SEARCH STYLES
 * Real-time search bar styling
 */

/* ============================================
   SEARCH CONTAINER
   ============================================ */
.product-search-container,
.global-search-section {
    position: relative;
    max-width: 900px;
    margin: 3rem auto 2rem;
    z-index: 100;
    padding: 0 1.5rem;
}

.global-search-section {
    background: linear-gradient(180deg, transparent 0%, rgba(44, 169, 161, 0.02) 50%, transparent 100%);
    padding: 2.5rem 1.5rem;
    margin-bottom: 1rem;
}

.global-search-section .container {
    max-width: 100%;
    padding: 0;
}

/* ============================================
   SEARCH BAR
   ============================================ */
.search-bar-wrapper,
.global-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 50px;
    padding: 0.75rem 1.75rem;
    box-shadow:
        0 8px 30px rgba(44, 169, 161, 0.15),
        0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(44, 169, 161, 0.12);
    min-height: 60px;
}

.search-bar-wrapper:hover,
.global-search-wrapper:hover {
    box-shadow:
        0 8px 35px rgba(44, 169, 161, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: rgba(44, 169, 161, 0.15);
    transform: translateY(-2px);
}

.search-bar-wrapper:focus-within,
.global-search-wrapper:focus-within {
    box-shadow:
        0 12px 40px rgba(44, 169, 161, 0.25),
        0 6px 16px rgba(0, 0, 0, 0.1);
    border-color: rgba(44, 169, 161, 0.4);
    transform: translateY(-3px);
}

.search-icon {
    color: #2ca9a1;
    flex-shrink: 0;
    margin-right: 14px;
    width: 24px;
    height: 24px;
    transition: all 0.3s ease;
}

.search-bar-wrapper:focus-within .search-icon,
.global-search-wrapper:focus-within .search-icon {
    color: #167d8c;
    transform: scale(1.1);
}

.product-search-input,
.global-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 18px 16px;
    font-size: 17px;
    font-family: 'Inter', sans-serif;
    background: transparent;
    width: 100%;
    color: #1e293b;
    font-weight: 500;
}

.product-search-input::placeholder,
.global-search-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.search-clear-btn {
    background: rgba(44, 169, 161, 0.08);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.search-clear-btn:hover {
    background: rgba(44, 169, 161, 0.15);
    transform: scale(1.1) rotate(90deg);
}

.search-clear-btn:active {
    transform: scale(0.95) rotate(90deg);
}

.search-clear-btn svg {
    color: #2ca9a1;
}

/* ============================================
   SEARCH RESULTS DROPDOWN
   ============================================ */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 20px;
    box-shadow:
        0 24px 70px rgba(44, 169, 161, 0.2),
        0 12px 30px rgba(0, 0, 0, 0.1);
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-15px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    border: 2px solid rgba(44, 169, 161, 0.1);
}

.search-results-dropdown.active {
    max-height: 650px;
    opacity: 1;
    transform: translateY(0);
    overflow-y: auto;
}

.search-results-dropdown::-webkit-scrollbar {
    width: 10px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 0 20px 20px 0;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #2ca9a1 0%, #167d8c 100%);
    border-radius: 5px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #167d8c 0%, #6366f1 100%);
}

/* ============================================
   SEARCH RESULTS CONTENT
   ============================================ */
.search-results-content {
    padding: 10px;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 10px;
}

.search-results-header span {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.search-view-all {
    background: linear-gradient(135deg, #2ca9a1 0%, #167d8c 100%);
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(44, 169, 161, 0.25);
}

.search-view-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(44, 169, 161, 0.4);
    background: linear-gradient(135deg, #167d8c 0%, #6366f1 100%);
}

.search-view-all:active {
    transform: translateY(0);
}

/* ============================================
   SEARCH RESULT ITEMS
   ============================================ */
.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    display: flex;
    gap: 16px;
    padding: 14px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
}

.search-result-item:hover,
.search-result-item.active {
    background: linear-gradient(90deg, rgba(44, 169, 161, 0.03) 0%, rgba(255, 255, 255, 0) 100%);
    border-color: rgba(44, 169, 161, 0.15);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(44, 169, 161, 0.08);
}

.search-result-image {
    position: relative;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
}

.search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.search-result-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

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

.search-result-info h4 {
    margin: 0 0 5px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-info h4 mark {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 4px;
    border-radius: 3px;
}

.search-result-category {
    margin: 0 0 5px 0;
    font-size: 12px;
    color: #6b7280;
}

.search-result-description {
    margin: 0;
    font-size: 13px;
    color: #9ca3af;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
    flex-shrink: 0;
}

.search-result-price .price {
    font-size: 19px;
    font-weight: 700;
    background: linear-gradient(135deg, #2ca9a1 0%, #167d8c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.search-result-price .stock {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 12px;
}

.search-result-price .stock.in-stock {
    background: #d1fae5;
    color: #065f46;
}

.search-result-price .stock.out-of-stock {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================
   SEARCH STATES
   ============================================ */
.search-no-results,
.search-loading,
.search-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
}

.search-no-results svg,
.search-loading svg {
    color: #cbd5e1;
    margin-bottom: 15px;
}

.search-no-results p {
    margin: 0 0 5px 0;
    font-size: 15px;
    color: #374151;
}

.search-no-results strong {
    color: #1f2937;
}

.search-no-results small {
    font-size: 13px;
    color: #9ca3af;
}

/* Loading spinner */
.search-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 15px;
}

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

.search-loading p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

.search-error p {
    margin: 0 0 5px 0;
    font-size: 15px;
    color: #dc2626;
}

.search-error small {
    font-size: 13px;
    color: #9ca3af;
}

/* ============================================
   SEARCH OVERLAY
   ============================================ */
.search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.3s ease;
    z-index: 99;
}

.search-overlay.active {
    background: rgba(0, 0, 0, 0.3);
    pointer-events: all;
}

/* ============================================
   PRODUCT HIGHLIGHT
   ============================================ */
.highlight-product {
    animation: highlightPulse 0.5s ease-in-out 3;
    border: 2px solid #2563eb !important;
}

@keyframes highlightPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
    }
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .product-search-container,
    .global-search-section {
        max-width: 100%;
        margin: 0;
        padding: 1.5rem 1rem;
    }

    .global-search-section {
        background: linear-gradient(180deg, rgba(248, 250, 252, 0.5) 0%, rgba(44, 169, 161, 0.03) 50%, rgba(248, 250, 252, 0.5) 100%);
        padding: 2rem 1rem;
    }

    .search-bar-wrapper,
    .global-search-wrapper {
        padding: 0.65rem 1.25rem;
        min-height: 54px;
        border-radius: 30px;
    }

    /* Fix search icon spacing on mobile */
    .search-icon {
        width: 20px;
        height: 20px;
        min-width: 20px;
        margin-right: 12px;
    }

    .product-search-input,
    .global-search-input {
        padding: 14px 8px;
        font-size: 15px;
        padding-left: 0;
    }

    .product-search-input::placeholder,
    .global-search-input::placeholder {
        font-size: 14px;
    }

    .search-results-dropdown {
        max-height: calc(100vh - 200px);
    }

    .search-result-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .search-result-image {
        width: 100%;
        height: 150px;
    }

    .search-result-price {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }

    .search-result-info h4 {
        white-space: normal;
    }
}

@media (max-width: 480px) {
    .product-search-container,
    .global-search-section {
        margin: 1rem 0.75rem 0;
    }

    .search-bar-wrapper,
    .global-search-wrapper {
        padding: 0 12px;
    }

    /* Smaller search icon on very small screens */
    .search-icon {
        width: 18px;
        height: 18px;
        min-width: 18px;
        margin-right: 10px;
    }

    .product-search-input,
    .global-search-input {
        padding: 12px 6px;
        font-size: 14px;
        padding-left: 0;
    }

    .search-results-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .search-view-all {
        width: 100%;
        text-align: center;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.product-search-input:focus,
.global-search-input:focus {
    outline: none;
}

.search-result-item:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .search-bar-wrapper {
        border: 2px solid #000;
    }

    .search-result-item {
        border: 1px solid #000;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .search-results-dropdown,
    .search-result-item,
    .search-loading-spinner,
    .highlight-product {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .search-bar-wrapper,
    .global-search-wrapper {
        background: #1f2937;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    .product-search-input,
    .global-search-input {
        color: #f9fafb;
    }

    .product-search-input::placeholder,
    .global-search-input::placeholder {
        color: #6b7280;
    }

    .search-results-dropdown {
        background: #1f2937;
    }

    .search-result-item:hover,
    .search-result-item.active {
        background: #374151;
        border-color: #4b5563;
    }

    .search-result-info h4 {
        color: #f9fafb;
    }

    .search-results-header {
        border-bottom-color: #374151;
    }

    .search-results-header span {
        color: #f9fafb;
    }

    .search-clear-btn {
        background: #374151;
    }

    .search-clear-btn:hover {
        background: #4b5563;
    }
}
