/**
 * Turbo Global Search - Frontend Styles
 * 
 * Modern dropdown UI with animations and beautiful design
 * Includes both inline and icon-based search styles
 * 
 * @since 1.0.0
 */

/* ===========================
   CSS Variables
   =========================== */
:root {
    --tgs-primary: #6366f1;
    --tgs-primary-dark: #4f46e5;
    --tgs-primary-light: #818cf8;
    --tgs-success: #10b981;
    --tgs-danger: #ef4444;
    --tgs-warning: #f59e0b;
    --tgs-dark: #1e293b;
    --tgs-gray-50: #f8fafc;
    --tgs-gray-100: #f1f5f9;
    --tgs-gray-200: #e2e8f0;
    --tgs-gray-300: #cbd5e1;
    --tgs-gray-400: #94a3b8;
    --tgs-gray-500: #64748b;
    --tgs-gray-600: #475569;
    --tgs-gray-700: #334155;
    --tgs-gray-800: #1e293b;
    --tgs-gray-900: #0f172a;
    --tgs-white: #ffffff;
    --tgs-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --tgs-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --tgs-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --tgs-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --tgs-radius: 12px;
    --tgs-radius-sm: 8px;
    --tgs-radius-lg: 16px;
    --tgs-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   INLINE STYLE (Default)
   =========================== */

/* Search Wrapper */
.tgs-search-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Search Form */
.tgs-search-form {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--tgs-white);
    border: 2px solid var(--tgs-gray-200);
    border-radius: var(--tgs-radius);
    padding: 4px;
    transition: var(--tgs-transition);
    box-shadow: var(--tgs-shadow-sm);
    z-index: 100;
}

.tgs-search-form:focus-within {
    border-color: var(--tgs-primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), var(--tgs-shadow);
}

.tgs-search-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 14px 18px;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--tgs-gray-900);
    background: transparent;
    border-radius: var(--tgs-radius-sm);
}

.tgs-search-input::placeholder {
    color: var(--tgs-gray-400);
}

.tgs-search-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--tgs-primary) 0%, var(--tgs-primary-dark) 100%);
    color: var(--tgs-white);
    border: none;
    border-radius: var(--tgs-radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--tgs-transition);
    white-space: nowrap;
    box-shadow: var(--tgs-shadow);
}

.tgs-search-button:hover {
    background: linear-gradient(135deg, var(--tgs-primary-dark) 0%, #3730a3 100%);
    box-shadow: var(--tgs-shadow-lg);
    transform: translateY(-2px);
}

.tgs-search-button:active {
    transform: translateY(0);
}

.tgs-search-button svg {
    width: 20px;
    height: 20px;
}

/* Loader */
.tgs-search-loader {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    visibility: hidden;
    transition: var(--tgs-transition);
    pointer-events: none;
}

.tgs-search-loader.tgs-loader-active {
    opacity: 1;
    visibility: visible;
}

.tgs-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--tgs-gray-300);
    border-top-color: var(--tgs-primary);
    border-radius: 50%;
    animation: tgs-spin 0.6s linear infinite;
}

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

/* ===========================
   Dropdown Panel
   =========================== */
.tgs-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--tgs-white);
    border-radius: var(--tgs-radius);
    box-shadow: var(--tgs-shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--tgs-transition);
    z-index: 99;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tgs-search-dropdown.tgs-dropdown-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Header */
.tgs-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 12px;
    border-bottom: 1px solid var(--tgs-gray-200);
    background: var(--tgs-gray-50);
}

.tgs-dropdown-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--tgs-transition);
    color: var(--tgs-gray-600);
}

.tgs-dropdown-close:hover {
    background: var(--tgs-gray-200);
    color: var(--tgs-gray-900);
}

/* Dropdown Content */
.tgs-dropdown-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.tgs-dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.tgs-dropdown-content::-webkit-scrollbar-track {
    background: var(--tgs-gray-100);
}

.tgs-dropdown-content::-webkit-scrollbar-thumb {
    background: var(--tgs-gray-300);
    border-radius: 3px;
}

.tgs-dropdown-content::-webkit-scrollbar-thumb:hover {
    background: var(--tgs-gray-400);
}

/* ===========================
   Results Sections
   =========================== */
.tgs-result-section {
    margin-bottom: 24px;
}

.tgs-result-section:last-child {
    margin-bottom: 0;
}

.tgs-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tgs-result-section-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--tgs-gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
}

.tgs-result-section-title::before {
    content: '';
    width: 3px;
    height: 14px;
    background: linear-gradient(135deg, var(--tgs-primary) 0%, var(--tgs-primary-light) 100%);
    border-radius: 2px;
    margin-right: 8px;
}

.tgs-view-all {
    font-size: 12px;
    font-weight: 600;
    color: var(--tgs-primary);
    text-decoration: none;
    transition: var(--tgs-transition);
}

.tgs-view-all:hover {
    color: var(--tgs-primary-dark);
}

/* Result Items */
.tgs-result-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tgs-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: var(--tgs-white);
    border: 1px solid var(--tgs-gray-200);
    border-radius: var(--tgs-radius-sm);
    text-decoration: none;
    color: inherit;
    transition: var(--tgs-transition);
    position: relative;
    overflow: hidden;
}

.tgs-result-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(135deg, var(--tgs-primary) 0%, var(--tgs-primary-light) 100%);
    transform: scaleY(0);
    transition: var(--tgs-transition);
}

.tgs-result-item:hover {
    border-color: var(--tgs-primary);
    box-shadow: var(--tgs-shadow);
    transform: translateX(2px);
}

.tgs-result-item:hover::before {
    transform: scaleY(1);
}

.tgs-item-image {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: var(--tgs-radius-sm);
    overflow: hidden;
    background: var(--tgs-gray-100);
}

.tgs-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--tgs-transition);
}

.tgs-result-item:hover .tgs-item-image img {
    transform: scale(1.05);
}

.tgs-item-content {
    flex: 1;
    min-width: 0;
}

.tgs-item-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--tgs-gray-900);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tgs-item-title mark {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(129, 140, 248, 0.2) 100%);
    color: var(--tgs-primary);
    padding: 2px 4px;
    border-radius: 3px;
}

.tgs-item-excerpt {
    margin: 0;
    font-size: 12px;
    color: var(--tgs-gray-600);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

.tgs-item-price {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 700;
    color: var(--tgs-success);
}

/* No Results */
.tgs-no-results {
    text-align: center;
    padding: 32px 16px;
}

.tgs-no-results svg {
    color: var(--tgs-gray-300);
    margin-bottom: 12px;
}

.tgs-no-results p {
    margin: 0;
    font-size: 14px;
    color: var(--tgs-gray-600);
}

/* Error Message */
.tgs-error {
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--tgs-danger);
    border-radius: var(--tgs-radius-sm);
    color: var(--tgs-danger);
    text-align: center;
    font-size: 14px;
}

/* ===========================
   ICON STYLE
   =========================== */

/* Icon Trigger Button */
.tgs-style-icon {
    width: auto;
    max-width: none;
}

.tgs-search-icon-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--tgs-primary) 0%, var(--tgs-primary-dark) 100%);
    color: var(--tgs-white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--tgs-transition);
    box-shadow: var(--tgs-shadow);
}

.tgs-search-icon-trigger:hover {
    background: linear-gradient(135deg, var(--tgs-primary-dark) 0%, #3730a3 100%);
    box-shadow: var(--tgs-shadow-lg);
    transform: scale(1.05);
}

.tgs-search-icon-trigger svg {
    width: 24px;
    height: 24px;
}

/* Modal */
.tgs-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--tgs-transition);
}

.tgs-search-modal.tgs-modal-active {
    opacity: 1;
    visibility: visible;
}

.tgs-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
}

.tgs-modal-content {
    position: relative;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    background: var(--tgs-white);
    border-radius: var(--tgs-radius-lg);
    box-shadow: var(--tgs-shadow-xl);
    padding: 32px;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--tgs-transition);
}

.tgs-modal-active .tgs-modal-content {
    transform: scale(1);
}

.tgs-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--tgs-gray-100);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--tgs-transition);
    color: var(--tgs-gray-600);
    z-index: 10;
}

.tgs-modal-close:hover {
    background: var(--tgs-gray-200);
    color: var(--tgs-gray-900);
    transform: rotate(90deg);
}

/* Modal Search Form */
.tgs-style-icon .tgs-search-form {
    max-width: 100%;
    margin-bottom: 16px;
}

.tgs-style-icon .tgs-search-dropdown {
    position: relative;
    top: 0;
    box-shadow: none;
    border: 1px solid var(--tgs-gray-200);
    margin-top: 0;
}

/* Prevent body scroll when modal is open */
body.tgs-modal-open {
    overflow: hidden;
}

/* ===========================
   Search Results Page
   =========================== */
.tgs-search-results-page {
    padding: 60px 0;
    background: var(--tgs-gray-50);
    min-height: 60vh;
}

.tgs-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.tgs-page-header {
    text-align: center;
    margin-bottom: 48px;
    padding: 40px;
    background: var(--tgs-white);
    border-radius: var(--tgs-radius-lg);
    box-shadow: var(--tgs-shadow);
}

.tgs-page-title {
    margin: 0 0 12px;
    font-size: 36px;
    font-weight: 800;
    color: var(--tgs-gray-900);
}

.tgs-page-title .search-query {
    color: var(--tgs-primary);
    position: relative;
}

.tgs-page-title .search-query::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--tgs-primary) 0%, var(--tgs-primary-light) 100%);
    border-radius: 2px;
}

.tgs-results-count {
    margin: 0 0 24px;
    font-size: 16px;
    color: var(--tgs-gray-600);
}

.tgs-page-search-form {
    max-width: 600px;
    margin: 0 auto;
}

/* Results Grid */
.tgs-results-section {
    margin-bottom: 48px;
    background: var(--tgs-white);
    border-radius: var(--tgs-radius-lg);
    padding: 32px;
    box-shadow: var(--tgs-shadow);
    scroll-margin-top: 100px;
    /* For smooth scroll anchor */
}

.tgs-section-title {
    margin: 0 0 24px;
    font-size: 24px;
    font-weight: 700;
    color: var(--tgs-gray-900);
    padding-bottom: 12px;
    border-bottom: 2px solid var(--tgs-gray-200);
}

.tgs-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.tgs-result-link {
    display: block;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.tgs-result-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: var(--tgs-gray-100);
}

.tgs-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--tgs-transition);
}

.tgs-result-item:hover .tgs-result-image img {
    transform: scale(1.05);
}

.tgs-result-content {
    padding: 20px;
}

.tgs-result-title {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 700;
    color: var(--tgs-gray-900);
    line-height: 1.4;
}

.tgs-result-excerpt {
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--tgs-gray-600);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    line-clamp: 3;
    overflow: hidden;
}

.tgs-result-price {
    margin-bottom: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--tgs-success);
}

.tgs-result-type {
    display: inline-block;
    padding: 4px 12px;
    background: var(--tgs-gray-100);
    color: var(--tgs-gray-700);
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tgs-no-results-message {
    text-align: center;
    padding: 80px 24px;
    background: var(--tgs-white);
    border-radius: var(--tgs-radius-lg);
    box-shadow: var(--tgs-shadow);
}

.tgs-no-results-message svg {
    color: var(--tgs-gray-300);
    margin-bottom: 24px;
}

.tgs-no-results-message h2 {
    margin: 0 0 12px;
    font-size: 28px;
    font-weight: 700;
    color: var(--tgs-gray-900);
}

.tgs-no-results-message p {
    margin: 0;
    font-size: 16px;
    color: var(--tgs-gray-600);
    max-width: 500px;
    margin: 0 auto;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .tgs-search-wrapper {
        max-width: 100%;
    }

    .tgs-search-button-text {
        display: none;
    }

    .tgs-search-button {
        padding: 12px;
    }

    .tgs-search-dropdown {
        max-height: 60vh;
    }

    .tgs-dropdown-content {
        padding: 12px;
    }

    .tgs-result-section {
        margin-bottom: 20px;
    }

    .tgs-results-grid {
        grid-template-columns: 1fr;
    }

    .tgs-page-title {
        font-size: 24px;
    }

    .tgs-page-header {
        padding: 24px;
    }

    .tgs-results-section {
        padding: 20px;
    }

    /* Icon style responsive */
    .tgs-search-icon-trigger {
        width: 44px;
        height: 44px;
    }

    .tgs-modal-content {
        width: 95%;
        padding: 24px;
        max-height: 90vh;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .tgs-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}