/* Search Button Component Styles */

/* === Base Search Toggle Styles === */
.search-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.search-toggle:hover,
.search-toggle:focus {
    background: rgba(229, 62, 62, 0.1);
    border-color: rgba(229, 62, 62, 0.2);
    color: #e53e3e;
}

.search-toggle[aria-expanded="true"] {
    background: rgba(229, 62, 62, 0.1);
    border-color: #e53e3e;
    color: #e53e3e;
}

/* Search icon styles */
.search-icon {
    width: 1.25rem;
    height: 1.25rem;
    stroke-width: 2;
}

.search-text {
    margin-left: 0.5rem;
}

/* === Size Variations === */
.search-toggle--small {
    padding: 0.375rem;
    font-size: 0.75rem;
}

.search-toggle--small .search-icon {
    width: 1rem;
    height: 1rem;
}

.search-toggle--medium {
    padding: 0.5rem;
    font-size: 0.875rem;
}

.search-toggle--medium .search-icon {
    width: 1.25rem;
    height: 1.25rem;
}

.search-toggle--large {
    padding: 0.75rem;
    font-size: 1rem;
}

.search-toggle--large .search-icon {
    width: 1.5rem;
    height: 1.5rem;
}

/* === Style Variations === */
.search-toggle--icon {
    /* Icon only - default styles above */
}

.search-toggle--text .search-icon {
    display: none;
}

.search-toggle--icon-text {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* === Header Integration === */
.header-actions .search-toggle {
    padding: 0.625rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    color: #374151;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-width: 44px;
    min-height: 44px;
}

.header-actions .search-toggle:hover,
.header-actions .search-toggle:focus {
    background: #f8fafc;
    border-color: #e53e3e;
    color: #e53e3e;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.15);
}

.header-actions .search-toggle[aria-expanded="true"] {
    background: #f8fafc;
    border-color: #e53e3e;
    color: #e53e3e;
    box-shadow: 0 2px 8px rgba(229, 62, 62, 0.15);
}

/* === Navigation Integration === */
.nav-menu .menu-item-search {
    position: relative;
    margin-left: 1rem;
}

.nav-menu .search-component {
    display: inline-block;
}

.nav-menu .search-toggle {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 2px solid transparent;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    border-radius: 0.375rem;
    min-height: 40px;
}

.nav-menu .search-toggle:hover,
.nav-menu .search-toggle:focus {
    background: rgba(229, 62, 62, 0.05);
    border-color: rgba(229, 62, 62, 0.2);
    color: #e53e3e;
    outline: none;
}

.nav-menu .search-toggle[aria-expanded="true"] {
    background: rgba(229, 62, 62, 0.1);
    border-color: #e53e3e;
    color: #e53e3e;
}

.nav-menu .search-icon {
    width: 1.125rem;
    height: 1.125rem;
}

/* === Search Form Container === */
.search-form-container {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    z-index: 1000;
    min-width: 320px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.5rem);
    transition: all 0.2s ease;
}

/* Navigation specific positioning */
.nav-menu .search-form-container {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(-0.5rem);
}

.nav-menu .search-form-container:not([hidden]) {
    transform: translateX(-50%) translateY(0);
}

.search-form-container:not([hidden]) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.search-form-wrapper {
    padding: 1.25rem;
}

/* === Enhanced Search Form === */
.search-form {
    width: 100%;
}

.search-form-inner {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    overflow: hidden;
    transition: all 0.2s ease;
}

.search-form-inner:focus-within {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1);
    background: white;
}

.search-label {
    position: absolute;
    left: -9999px;
}

.search-field {
    flex: 1;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    font-size: 0.875rem;
    color: #374151;
    outline: none;
    font-family: inherit;
}

.search-field::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.search-submit,
.search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem;
    background: transparent;
    border: none;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 0;
}

.search-submit:hover,
.search-close:hover {
    color: #e53e3e;
    background: rgba(229, 62, 62, 0.05);
}

.search-submit {
    border-left: 1px solid #e2e8f0;
}

.search-close {
    border-left: 1px solid #e2e8f0;
}

/* === Mobile Responsiveness === */
@media (max-width: 768px) {
    .header-actions .search-toggle {
        padding: 0.5rem;
        min-width: 40px;
        min-height: 40px;
    }
    
    .nav-menu .search-form-container {
        left: 50%;
        right: auto;
        transform: translateX(-50%) translateY(-0.5rem);
        max-width: calc(100vw - 2rem);
        min-width: 280px;
    }
    
    .nav-menu .search-form-container:not([hidden]) {
        transform: translateX(-50%) translateY(0);
    }
    
    .search-form-wrapper {
        padding: 1rem;
    }
    
    .search-field {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .nav-menu .search-form-container {
        min-width: calc(100vw - 2rem);
        left: 1rem;
        right: 1rem;
        transform: translateY(-0.5rem);
    }
    
    .nav-menu .search-form-container:not([hidden]) {
        transform: translateY(0);
    }
}

/* === Animation Enhancements === */
.search-component {
    position: relative;
}

.search-toggle {
    position: relative;
    overflow: hidden;
}

.search-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(229, 62, 62, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    z-index: -1;
}

.search-toggle:hover::before,
.search-toggle:focus::before {
    width: 100%;
    height: 100%;
}

/* === Accessibility Improvements === */
.search-toggle:focus-visible {
    outline: 2px solid #e53e3e;
    outline-offset: 2px;
}

.search-field:focus-visible {
    outline: none; /* Form container handles focus styling */
}

.search-submit:focus-visible,
.search-close:focus-visible {
    outline: 2px solid #e53e3e;
    outline-offset: -2px;
}
