/**
 * Search Results Styling - UPDATED FOR GREEN HEADER
 * Perbaikan: Color scheme konsisten dengan header hijau, text size lebih besar
 */

/* Search Container */
.search-container {
    position: relative;
    z-index: 10;
}

.search-icon {
    pointer-events: none;
    z-index: 2;
}

/* Search Input - FIXED VERSION */
#global-search,
#mobile-search {
    position: relative;
    z-index: 1;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    background: #ffffff !important;
    /* UBAH: Full white, bukan rgba */
    padding: 0.7rem 2.75rem 0.7rem 3rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    color: #1f2937 !important;
    /* PERKUAT: Dark gray untuk text */
    font-weight: 500 !important;
    /* TAMBAH: Biar lebih tebal */
}

#global-search:focus,
#mobile-search:focus {
    border-color: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2) !important;
    outline: none;
    background: #ffffff !important;
    color: #111827 !important;
    /* PERKUAT: Hitam saat focus */
}

#global-search::placeholder,
#mobile-search::placeholder {
    color: #9ca3af !important;
    /* UBAH: Lebih gelap untuk placeholder */
    opacity: 1 !important;
}

/* TAMBAH: Force styling untuk input value */
#global-search:not(:placeholder-shown),
#mobile-search:not(:placeholder-shown) {
    color: #111827 !important;
    font-weight: 600 !important;
}

/* Search Icon Colors - Visible on Green Header */
.search-icon {
    color: #065f46 !important;
    /* Hijau gelap default - terlihat di background putih input */
    transition: color 0.3s ease;
}

/* Search Icon saat input focus - berubah jadi emas */
#global-search:focus~.search-icon,
#mobile-search:focus~.search-icon {
    color: #d97706 !important;
    /* Emas/orange saat focus */
}

/* ========================================
   SEARCH RESULTS DROPDOWN - FIXED POSITION
   ======================================== */
.search-results-dropdown {
    position: absolute;
    top: calc(100% + 0.75rem);
    /* FIX: Gunakan transform untuk center alignment yang lebih baik */
    transform: translateX(-50%) translateY(-10px);

    /* Width responsif */
    width: 540px;
    max-width: calc(100vw - 2rem);

    background: #ffffff;
    border: 1px solid #e1e3ea;
    border-radius: 0.875rem;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.12);
    max-height: 520px;
    overflow-y: auto;
    z-index: 1100;

    /* Animation */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-results-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Smooth scroll */
.search-results-dropdown {
    scroll-behavior: smooth;
}

/* Custom scrollbar - Metronic Style */
.search-results-dropdown::-webkit-scrollbar {
    width: 6px;
}

.search-results-dropdown::-webkit-scrollbar-track {
    background: #f5f8fa;
    border-radius: 0 0.875rem 0.875rem 0;
}

.search-results-dropdown::-webkit-scrollbar-thumb {
    background: #b5b5c3;
    border-radius: 3px;
}

.search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: #7e8299;
}

/* ========================================
   SEARCH SUGGESTION ITEM - BIGGER TEXT
   ======================================== */
.search-suggestion-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.35rem;
    text-decoration: none;
    color: #3f4254;
    border-bottom: 1px solid #eff2f5;
    transition: all 0.15s ease;
    cursor: pointer;
    position: relative;
}

.search-suggestion-item:last-of-type {
    border-bottom: none;
}

.search-suggestion-item:hover,
.search-suggestion-item.active {
    background: #ecfdf5;
    color: #059669;
}

.search-suggestion-item:hover .text-muted,
.search-suggestion-item.active .text-muted {
    color: #059669 !important;
}

.search-suggestion-item:hover .ki-arrow-right,
.search-suggestion-item.active .ki-arrow-right {
    transform: translateX(4px);
    color: #059669;
}

.search-suggestion-item .ki-arrow-right {
    transition: transform 0.2s ease;
    color: #a1a5b7;
}

/* Search Suggestion Symbol */
.search-suggestion-item .symbol {
    flex-shrink: 0;
    margin-right: 1rem;
}

.symbol {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.75rem;
    overflow: hidden;
}

.symbol-40px {
    width: 44px;
    height: 44px;
}

.symbol-label {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

/* Search Text - BIGGER SIZE */
.search-suggestion-item .fw-bold {
    font-size: 1rem;
    font-weight: 600;
}

.search-suggestion-item .text-muted {
    font-size: 0.9rem;
}

/* Highlight matched text */
.search-suggestion-item mark {
    background: rgba(5, 150, 105, 0.15);
    color: #047857;
    padding: 2px 5px;
    border-radius: 0.3rem;
    font-weight: 600;
}

/* ========================================
   SEARCH STATES
   ======================================== */

/* Search Loading State */
.search-loading {
    padding: 2.25rem 1.75rem;
    text-align: center;
    color: #7e8299;
}

.search-loading .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 2px;
    border-color: #059669;
    border-right-color: transparent;
    vertical-align: middle;
}

/* Search Error State */
.search-error {
    padding: 2.25rem 1.75rem;
    text-align: center;
    color: #7e8299;
}

.search-error .ki-information-5 {
    display: block;
    margin: 0 auto 0.875rem;
    color: #f59e0b;
    font-size: 2.5rem;
}

.search-error p {
    margin-bottom: 0.875rem;
    font-size: 1rem;
    color: #5e6278;
}

.search-error .btn {
    margin-top: 0.625rem;
}

/* No Results State */
.no-results {
    padding: 2.75rem 1.75rem;
    text-align: center;
    color: #7e8299;
}

.no-results .ki-file-deleted {
    display: block;
    margin: 0 auto 0.875rem;
    color: #a1a5b7;
    font-size: 2.5rem;
}

.no-results p {
    margin-bottom: 0.625rem;
    color: #5e6278;
    font-size: 1rem;
}

.no-results strong {
    color: #181c32;
}

/* ========================================
   SEARCH FOOTER
   ======================================== */
.search-footer {
    padding: 1rem 1.35rem;
    border-top: 1px solid #eff2f5;
    background: #f9fafb;
    border-radius: 0 0 0.875rem 0.875rem;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.search-footer .btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    padding: 0.6rem 1.15rem;
}

/* ========================================
   RESPONSIVE - MOBILE OPTIMIZATION
   ======================================== */

/* Tablet */
@media (max-width: 991.98px) {
    .search-results-dropdown {
        width: 500px;
        max-width: calc(100vw - 2rem);
        border-radius: 0.75rem;
    }

    #global-search,
    #mobile-search {
        font-size: 0.95rem;
        padding: 0.65rem 2.5rem 0.65rem 2.75rem;
    }
}

/* Mobile */
@media (max-width: 575.98px) {
    .search-results-dropdown {
        /* FIX: Mobile tetap center tapi dengan margin yang tepat */
        width: calc(100vw - 2rem);
        max-width: none;
        max-height: 65vh;
        border-radius: 0.75rem;

        /* Pastikan tidak keluar viewport */
        left: 50%;
        transform: translateX(-50%) translateY(-10px);
    }

    .search-results-dropdown.show {
        transform: translateX(-50%) translateY(0);
    }

    .search-suggestion-item {
        padding: 0.9rem 1.15rem;
    }

    .symbol-40px {
        width: 40px;
        height: 40px;
    }

    .symbol-label {
        font-size: 1rem;
    }

    .search-suggestion-item .fw-bold {
        font-size: 0.95rem;
    }

    .search-suggestion-item .text-muted {
        font-size: 0.85rem;
    }

    .search-footer {
        padding: 0.875rem 1.15rem;
    }

    .search-loading,
    .search-error,
    .no-results {
        padding: 1.75rem 1.15rem;
    }

    #global-search,
    #mobile-search {
        font-size: 0.9rem;
        padding: 0.6rem 2.25rem 0.6rem 2.5rem;
    }
}

/* Extra Small Mobile */
@media (max-width: 374.98px) {
    .search-results-dropdown {
        width: calc(100vw - 1rem);
        max-height: 60vh;
    }

    .search-suggestion-item {
        padding: 0.75rem 1rem;
    }

    .symbol-40px {
        width: 36px;
        height: 36px;
    }

    .search-suggestion-item .fw-bold {
        font-size: 0.9rem;
    }

    .search-suggestion-item .text-muted {
        font-size: 0.8rem;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.spinner-border {
    animation: spin 0.75s linear infinite;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.search-results-dropdown.show {
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   COLOR SCHEME - GREEN HOSPITAL THEME
   ======================================== */

/* Background Light Colors */
.bg-light-primary {
    background-color: #ecfdf5 !important;
}

.bg-light-success {
    background-color: #d1fae5 !important;
}

.bg-light-info {
    background-color: #f8f5ff !important;
}

.bg-light-warning {
    background-color: #fff8dd !important;
}

.bg-light-danger {
    background-color: #fff5f8 !important;
}

/* Text Colors - Updated for Green Theme */
.text-primary {
    color: #059669 !important;
}

.text-success {
    color: #10b981 !important;
}

.text-info {
    color: #8b5cf6 !important;
}

.text-warning {
    color: #f59e0b !important;
}

.text-danger {
    color: #ef4444 !important;
}

.text-gray-800 {
    color: #3f4254 !important;
}

.text-gray-700 {
    color: #5e6278 !important;
}

.text-gray-400 {
    color: #a1a5b7 !important;
}

.text-muted {
    color: #7e8299 !important;
}

/* Font Weights */
.fw-bold {
    font-weight: 600 !important;
}

.fw-semibold {
    font-weight: 500 !important;
}

/* Font Sizes */
.fs-7 {
    font-size: 0.95rem !important;
}

.fs-8 {
    font-size: 0.875rem !important;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus States */
.search-suggestion-item:focus {
    outline: 2px solid #059669;
    outline-offset: -2px;
    background: #ecfdf5;
    z-index: 1;
}

#global-search:focus,
#mobile-search:focus {
    outline: none;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .search-results-dropdown {
        border: 2px solid #000;
    }

    .search-suggestion-item:hover,
    .search-suggestion-item.active {
        background: #000 !important;
        color: #fff !important;
    }

    .search-suggestion-item mark {
        background: #ff0 !important;
        color: #000 !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    .search-results-dropdown,
    .search-suggestion-item,
    .search-suggestion-item .ki-arrow-right,
    #global-search,
    #mobile-search {
        transition: none !important;
        animation: none !important;
    }

    .spinner-border {
        animation: none !important;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */
@media (prefers-color-scheme: dark) {
    .search-results-dropdown {
        background: #1e1e2d;
        border-color: #2b2b40;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
    }

    #global-search,
    #mobile-search {
        background: rgba(30, 30, 45, 0.95) !important;
        border-color: rgba(255, 255, 255, 0.2) !important;
        color: #ffffff !important;
    }

    #global-search:focus,
    #mobile-search:focus {
        background: #1e1e2d !important;
        border-color: rgba(255, 255, 255, 0.4) !important;
    }

    #global-search::placeholder,
    #mobile-search::placeholder {
        color: #7e8299 !important;
    }

    .search-suggestion-item {
        color: #ffffff;
        border-bottom-color: #2b2b40;
    }

    .search-suggestion-item:hover,
    .search-suggestion-item.active {
        background: #1b1b29;
        color: #10b981;
    }

    .search-suggestion-item .text-muted {
        color: #7e8299 !important;
    }

    .search-footer {
        background: #151521;
        border-top-color: #2b2b40;
    }

    .no-results,
    .search-loading,
    .search-error {
        color: #7e8299;
    }

    .no-results strong {
        color: #ffffff;
    }
}

/* ========================================
   UTILITY & HELPERS
   ======================================== */

/* Print Styles */
@media print {

    .search-container,
    .search-results-dropdown {
        display: none !important;
    }
}

/* Empty state */
.search-results-dropdown:empty {
    display: none !important;
}

/* Prevent text selection in icons */
.search-suggestion-item .symbol,
.search-suggestion-item .ki-arrow-right {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Overflow handling */
.search-suggestion-item .fw-bold {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.search-suggestion-item .text-muted {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
