/**
 * MF Search Plugin Styles
 * Modal-based search with icon button
 */

/* Container - Just holds the button */
.mf-search-container {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    position: relative;
    vertical-align: middle;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1;
    width: auto !important;
    max-width: none !important;
}

/* Remove WordPress auto-paragraph wrapping */
.mf-search-container p {
    display: inline;
    margin: 0;
    padding: 0;
}

/* Search Toggle Button - Square matching Sign Up button height */
.mf-search-toggle-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #7ECDBA;
    background-color: #101820;
    color: #7ecdba;
    border-radius: 0px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
    vertical-align: middle;
}

.mf-search-toggle-btn:hover {
    background-color: #1a2530;
    border-color: #8ff5d7;
}

.mf-search-toggle-btn:active {
    transform: scale(0.95);
}

.mf-search-toggle-btn .mf-search-icon {
    font-size: 18px;
    line-height: 1;
    display: block;
    filter: grayscale(100%) brightness(0) invert(1);
    opacity: 0.9;
}

/* Modal Overlay - Hidden by default */
.mf-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none !important;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
}

.mf-search-modal.mf-search-modal-open {
    display: flex !important;
}

.mf-search-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal Content */
.mf-search-modal-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s ease;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Header */
.mf-search-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e0e0e0;
}

.mf-search-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.mf-search-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f5f5f5;
    color: #666;
    font-size: 24px;
    line-height: 1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mf-search-close-btn:hover {
    background: #e0e0e0;
    color: #333;
}

/* Search Wrapper */
.mf-search-wrapper {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

/* Filter Tabs */
.mf-search-filter-wrapper {
    margin-bottom: 16px;
    display: block;
}

.mf-search-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.mf-search-filter-tab {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #2196F3;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    white-space: nowrap;
}

.mf-search-filter-tab:hover {
    background-color: #e3f2fd;
    color: #1565C0;
}

.mf-search-filter-tab:focus {
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

.mf-search-filter-tab.active {
    background-color: #2196F3;
    color: #fff;
}

.mf-search-filter-tab.active:hover {
    background-color: #1976D2;
    color: #fff;
}

/* Search Input Wrapper */
.mf-search-input-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 16px;
}

/* Search Input */
.mf-search-input {
    width: 100%;
    padding: 16px 50px 16px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background-color: #fff;
    color: #4a4a4a;
    transition: all 0.3s ease;
    outline: none;
    box-sizing: border-box;
}

.mf-search-input:focus {
    border-color: #2196F3;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.15);
}

.mf-search-input::placeholder {
    color: #999;
}

/* Loading Spinner */
.mf-search-loading {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
}

.mf-search-spinner {
    animation: rotate 2s linear infinite;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2196F3;
    border-radius: 50%;
}

@keyframes rotate {
    100% {
        transform: rotate(360deg);
    }
}

/* Results Container */
.mf-search-results {
    background: #fafafa;
    border-radius: 8px;
    overflow: hidden;
}

/* Results Header */
.mf-search-results-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fff;
}

.mf-search-results-count {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Results List */
.mf-search-results-list {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom Scrollbar */
.mf-search-results-list::-webkit-scrollbar {
    width: 8px;
}

.mf-search-results-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mf-search-results-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.mf-search-results-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Result Item */
.mf-search-result-item {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: white;
}

.mf-search-result-item:last-child {
    border-bottom: none;
}

.mf-search-result-item:hover {
    background-color: #f5f9ff;
}

.mf-search-result-item:active {
    background-color: #e3f2fd;
}

/* Result Item Content */
.mf-search-result-main {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mf-search-result-vrnm {
    font-size: 16px;
    font-weight: 600;
    color: #1565C0 !important;
    text-decoration: none;
    flex: 1;
    min-width: 150px;
    display: inline-block;
}

.mf-search-result-vrnm:hover {
    text-decoration: underline;
    color: #0D47A1 !important;
}

.mf-search-result-vrnm:visited {
    color: #1565C0 !important;
}

.mf-search-result-symb {
    font-size: 13px;
    color: #666;
    background-color: #f0f0f0;
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
}

/* Result Item Meta */
.mf-search-result-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.mf-search-result-cnt,
.mf-search-result-tp {
    font-size: 13px;
    color: #666;
}

.mf-search-result-cnt strong,
.mf-search-result-tp strong {
    color: #333;
    font-weight: 600;
}

/* No Results */
.mf-search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    background: white;
}

.mf-search-no-results-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.mf-search-no-results-text {
    font-size: 16px;
    margin-bottom: 8px;
}

.mf-search-no-results-hint {
    font-size: 14px;
    color: #bbb;
}

/* Mobile Optimization */
@media screen and (max-width: 768px) {
    .mf-search-modal {
        padding-top: 40px;
    }
    
    .mf-search-modal-content {
        width: 95%;
        max-height: 85vh;
    }
    
    .mf-search-modal-header {
        padding: 16px 20px;
    }
    
    .mf-search-modal-header h3 {
        font-size: 18px;
    }
    
    .mf-search-wrapper {
        padding: 20px;
    }
    
    .mf-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 50px 14px 18px;
    }
    
    .mf-search-filter {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .mf-search-results-list {
        max-height: 300px;
    }
    
    .mf-search-result-item {
        padding: 14px 16px;
    }
    
    .mf-search-result-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .mf-search-result-vrnm {
        font-size: 15px;
        min-width: auto;
        width: 100%;
    }
    
    .mf-search-result-symb {
        font-size: 12px;
    }
    
    .mf-search-result-meta {
        gap: 12px;
        font-size: 12px;
    }
}

@media screen and (max-width: 480px) {
    .mf-search-toggle-btn {
        width: 26px;
        height: 26px;
    }
    
    .mf-search-toggle-btn svg {
        width: 13px;
        height: 13px;
    }
    
    .mf-search-modal-content {
        border-radius: 12px 12px 0 0;
    }
    
    .mf-search-input {
        padding: 12px 45px 12px 16px;
    }
    
    .mf-search-results-list {
        max-height: 250px;
    }
    
    .mf-search-result-item {
        padding: 12px 14px;
    }
    
    .mf-search-result-vrnm {
        font-size: 14px;
    }
}

/* Touch Device Optimization */
@media (hover: none) and (pointer: coarse) {
    .mf-search-result-item {
        padding: 18px 20px;
    }
    
    .mf-search-result-item:active {
        background-color: #e3f2fd;
    }
}
