/* =============================================
   Global Search Styles
   ============================================= */

/* Search Modal */
.global-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

.global-search-modal.show {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

.search-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    animation: slideDown 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Header */
.search-header {
    padding: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 3.5rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1.1rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.search-icon {
    position: absolute;
    left: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    color: #64748b;
}

.search-close {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #64748b;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.search-close:hover {
    background: #f1f5f9;
    color: #1e293b;
}

/* Search Hints */
.search-hints {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.search-hint {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-radius: 20px;
    font-size: 0.85rem;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-hint:hover {
    background: #e0e7ff;
    color: #667eea;
}

.search-hint kbd {
    padding: 0.2rem 0.5rem;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
}

/* Search Results */
.search-results {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0;
}

.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.search-results::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.search-category {
    padding: 0.75rem 1.5rem;
    background: #f8fafc;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-top: 1px solid #e2e8f0;
}

.search-result-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-result-item:hover {
    background: #f8fafc;
    padding-left: 2rem;
}

.search-result-item.selected {
    background: #e0e7ff;
    border-left: 3px solid #667eea;
}

.result-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.result-icon.document {
    background: #dbeafe;
    color: #1e40af;
}

.result-icon.category {
    background: #fef3c7;
    color: #92400e;
}

.result-icon.keyword {
    background: #d1fae5;
    color: #065f46;
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-meta {
    font-size: 0.85rem;
    color: #64748b;
    display: flex;
    gap: 1rem;
}

.result-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.result-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Empty State */
.search-empty {
    padding: 3rem 1.5rem;
    text-align: center;
}

.search-empty i {
    font-size: 3rem;
    color: #cbd5e1;
    margin-bottom: 1rem;
}

.search-empty p {
    color: #64748b;
    margin: 0;
}

/* Loading State */
.search-loading {
    padding: 2rem;
    text-align: center;
}

.search-loading .spinner-border {
    color: #667eea;
}

/* Search Footer */
.search-footer {
    padding: 1rem 1.5rem;
    border-top: 2px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-footer-shortcuts {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #64748b;
}

.shortcut-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.shortcut-hint kbd {
    padding: 0.25rem 0.5rem;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.75rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Recent Searches */
.recent-searches {
    padding: 1rem 1.5rem;
}

.recent-search-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recent-search-item:hover {
    background: #f1f5f9;
}

.recent-search-text {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #475569;
}

.recent-search-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.recent-search-remove:hover {
    background: #e2e8f0;
    color: #475569;
}

/* Highlight matched text */
.highlight {
    background: #fef3c7;
    color: #92400e;
    padding: 0.1rem 0.2rem;
    border-radius: 2px;
    font-weight: 600;
}

/* =============================================
   QR Scanner Styles
   ============================================= */

/* Scan button next to search input close button */
.qr-scan-btn {
    position: absolute;
    right: 3.4rem;          /* sits left of the × close button */
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #667eea;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s ease, color 0.2s ease;
}

.qr-scan-btn:hover {
    background: #e0e7ff;
    color: #4338ca;
}

/* Adjust close button right so it doesn't overlap scan button */
.search-input {
    padding-right: 6rem;   /* room for both buttons */
}

/* Scanner container */
.qr-scanner-container {
    position: relative;
    margin-top: 1rem;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
}

/* Live camera feed */
.qr-video {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    display: block;
    border-radius: 10px 10px 0 0;
}

/* Aim frame overlay */
.qr-scan-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.qr-scan-frame {
    width: 140px;
    height: 140px;
    border: 3px solid #667eea;
    border-radius: 12px;
    box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);
    animation: qrPulse 1.8s ease-in-out infinite;
}

@keyframes qrPulse {
    0%, 100% { border-color: #667eea; box-shadow: 0 0 0 2000px rgba(0,0,0,0.35); }
    50%       { border-color: #34d399; box-shadow: 0 0 0 2000px rgba(0,0,0,0.45); }
}

.qr-scan-hint {
    margin-top: 0.75rem;
    color: rgba(255,255,255,0.9);
    font-size: 0.8rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    text-align: center;
}

/* Status text below scanner */
.qr-scan-status {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    min-height: 1.5rem;
    text-align: center;
    background: #f8fafc;
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .qr-scan-btn { color: #818cf8; }
    .qr-scan-btn:hover { background: #1e1b4b; }
    .qr-scan-status { background: #0f172a; }
}

/* Mobile — make scanner taller for easier scanning */
@media (max-width: 768px) {
    .qr-video { max-height: 260px; }
    .qr-scan-frame { width: 160px; height: 160px; }
}
