/* ========================================
   GLASSMORPHISM UI - Frosted Glass Design
   15% transparency with backdrop blur
======================================== */

:root {
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: rgba(0, 0, 0, 0.1);
    --glass-hover-bg: rgba(255, 255, 255, 0.25);
}

/* ========================================
   COMPACT SEARCH (Theory Pages)
======================================== */

.compact-search-wrapper {
    position: fixed;
    top: 80px;
    right: 40px;
    z-index: 1000;
}

.compact-search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 100px;
    color: #111827;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.compact-search-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(194, 234, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    z-index: 0;
}

.compact-search-btn:hover::before {
    width: 300px;
    height: 300px;
}

.compact-search-btn:hover {
    border-color: #c2eaff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(194, 234, 255, 0.4);
}

.compact-search-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    position: relative;
    z-index: 1;
}

.compact-search-btn span {
    position: relative;
    z-index: 1;
}

.compact-search-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: 380px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.compact-search-form {
    position: relative;
    margin-bottom: 16px;
}

.compact-search-input {
    width: 100%;
    padding: 14px 52px 14px 20px;
    border: 2px solid #e5e7eb;
    border-radius: 100px;
    font-size: 0.9375rem;
    color: #111827;
    outline: none;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.compact-search-input:focus {
    border-color: #c2eaff;
    box-shadow: 0 4px 16px rgba(194, 234, 255, 0.3);
    background: #fff;
}

.compact-search-submit {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #c2eaff 0%, #a8dcff 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(194, 234, 255, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.compact-search-submit:hover {
    background: linear-gradient(135deg, #a8dcff 0%, #8dd0ff 100%);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 4px 12px rgba(194, 234, 255, 0.6);
}

.compact-search-submit:active {
    transform: translateY(-50%) scale(0.95);
}

.compact-search-submit svg {
    width: 18px;
    height: 18px;
    stroke: #111827;
    stroke-width: 2.5;
}

.compact-search-results {
    font-size: 0.875rem;
    padding: 12px 16px;
    border-radius: 16px;
    display: none;
    animation: fadeInResult 0.3s ease-out;
}

@keyframes fadeInResult {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.compact-search-results.show {
    display: block;
}

.compact-search-results.success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 2px solid #6ee7b7;
    font-weight: 500;
}

.compact-search-results.error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 2px solid #fca5a5;
    font-weight: 500;
}

.compact-search-results.info {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    border: 2px solid #93c5fd;
    font-weight: 500;
}

/* Navigation Buttons */
.compact-search-navigation {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid #f3f4f6;
}

.search-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 100px;
    color: #111827;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.search-nav-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(194, 234, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    z-index: 0;
}

.search-nav-btn:hover::before {
    width: 200px;
    height: 200px;
}

.search-nav-btn:hover {
    border-color: #c2eaff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(194, 234, 255, 0.4);
}

.search-nav-btn:active {
    transform: translateY(0);
}

.search-nav-btn svg,
.search-nav-btn span {
    position: relative;
    z-index: 1;
}

.search-nav-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    flex-shrink: 0;
}

.search-match-counter {
    font-size: 0.7rem;
    font-weight: 600;
    color: #111827;
    padding: 8px 8px;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 100px;
    min-width: 60px;
    text-align: center;
    border: 2px solid #e5e7eb;
}

/* Glassmorphism Search Button */
.glass-search-btn {
    position: fixed;
    top: 80px;
    right: 40px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    color: var(--text-dark);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    box-shadow: 0 8px 32px 0 var(--glass-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.glass-search-btn:hover {
    background: var(--glass-hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.15);
}

.glass-search-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* Glassmorphism Search Modal */
.glass-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

.glass-search-modal.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.glass-search-container {
    width: 90%;
    max-width: 640px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.glass-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.glass-search-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.glass-search-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.glass-search-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.glass-search-close svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-dark);
}

.glass-search-form {
    position: relative;
    margin-bottom: 24px;
}

.glass-search-input {
    width: 100%;
    padding: 16px 56px 16px 24px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 100px;
    font-size: 1rem;
    color: var(--text-dark);
    outline: none;
    transition: all 0.3s ease;
}

.glass-search-input::placeholder {
    color: rgba(0, 0, 0, 0.4);
}

.glass-search-input:focus {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

.glass-search-submit {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--text-dark);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.glass-search-submit:hover {
    background: #2A2A2A;
    transform: translateY(-50%) scale(1.05);
}

.glass-search-submit svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

.glass-search-hint {
    font-size: 0.875rem;
    color: rgba(0, 0, 0, 0.6);
    text-align: center;
    margin-top: 12px;
}

.glass-search-results {
    margin-top: 16px;
    font-size: 0.9375rem;
    text-align: center;
    padding: 12px 16px;
    border-radius: 12px;
    display: none;
}

.glass-search-results.show {
    display: block;
}

.glass-search-results.success {
    background: rgba(16, 185, 129, 0.15);
    color: #047857;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.glass-search-results.error {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.glass-search-results.info {
    background: rgba(59, 130, 246, 0.15);
    color: #1d4ed8;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Highlight matched text */
.search-highlight {
    background: linear-gradient(135deg, rgba(194, 234, 255, 0.5) 0%, rgba(168, 220, 255, 0.5) 100%);
    padding: 3px 6px;
    border-radius: 6px;
    font-weight: 600;
    color: #111827;
    border: 2px solid rgba(194, 234, 255, 0.6);
    animation: highlightPulse 1.5s ease-in-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes highlightPulse {
    0%, 100% {
        background: linear-gradient(135deg, rgba(194, 234, 255, 0.5) 0%, rgba(168, 220, 255, 0.5) 100%);
    }
    50% {
        background: linear-gradient(135deg, rgba(194, 234, 255, 0.7) 0%, rgba(168, 220, 255, 0.7) 100%);
    }
}

.search-highlight.current {
    background: linear-gradient(135deg, #c2eaff 0%, #a8dcff 100%);
    box-shadow: 0 0 0 4px rgba(194, 234, 255, 0.4);
    color: #111827;
    border-color: #a8dcff;
    transform: scale(1.05);
}

/* Glassmorphism Card */
.glass-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.glass-card:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
}

/* Responsive Design */
@media (max-width: 768px) {
    .compact-search-wrapper {
        top: 70px;
        right: 20px;
    }

    .compact-search-dropdown {
        width: 320px;
    }

    .search-nav-btn span {
        display: none;
    }

    .search-nav-btn {
        padding: 8px 12px;
    }

    .glass-search-btn {
        top: 70px;
        right: 20px;
        padding: 10px 20px;
        font-size: 0.875rem;
    }

    .glass-search-btn svg {
        width: 18px;
        height: 18px;
    }

    .glass-search-container {
        width: 95%;
        padding: 24px;
        border-radius: 20px;
    }

    .glass-search-title {
        font-size: 1.25rem;
    }

    .glass-search-input {
        padding: 14px 52px 14px 20px;
        font-size: 0.9375rem;
    }
}

@media (max-width: 480px) {
    .compact-search-wrapper {
        right: 12px;
    }

    .compact-search-dropdown {
        width: calc(100vw - 24px);
        right: -12px;
    }

    .compact-search-navigation {
        flex-direction: column;
        gap: 8px;
    }

    .search-nav-btn {
        width: 100%;
        justify-content: center;
    }

    .search-match-counter {
        width: 100%;
    }

    .glass-search-btn {
        gap: 8px;
        padding: 8px 16px;
    }

    .glass-search-btn span {
        display: none;
    }

    .glass-search-container {
        padding: 20px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .glass-search-btn,
    .glass-search-modal,
    .glass-search-container,
    .glass-search-close,
    .glass-card {
        animation: none;
        transition: none;
    }
}

/* ========================================
   DARK MODE SUPPORT
======================================== */
[data-theme="dark"] .compact-search-btn {
    background: #1e293b;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .compact-search-btn::before {
    background: rgba(96, 165, 250, 0.2);
}

[data-theme="dark"] .compact-search-btn:hover {
    border-color: #60a5fa;
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

[data-theme="dark"] .compact-search-dropdown {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .compact-search-input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .compact-search-input::placeholder {
    color: #64748b;
}

[data-theme="dark"] .compact-search-input:focus {
    border-color: #60a5fa;
    box-shadow: 0 4px 16px rgba(96, 165, 250, 0.2);
    background: #0f172a;
}

[data-theme="dark"] .compact-search-submit {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
}

[data-theme="dark"] .compact-search-submit:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.5);
}

[data-theme="dark"] .compact-search-submit svg {
    stroke: #0f172a;
}

[data-theme="dark"] .compact-search-results.success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(16, 185, 129, 0.1) 100%);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.3);
}

[data-theme="dark"] .compact-search-results.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.1) 100%);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .compact-search-results.info {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15) 0%, rgba(96, 165, 250, 0.1) 100%);
    color: #60a5fa;
    border-color: rgba(96, 165, 250, 0.3);
}

[data-theme="dark"] .compact-search-navigation {
    border-top-color: #334155;
}

[data-theme="dark"] .search-nav-btn {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .search-nav-btn::before {
    background: rgba(96, 165, 250, 0.2);
}

[data-theme="dark"] .search-nav-btn:hover {
    border-color: #60a5fa;
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

[data-theme="dark"] .search-match-counter {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-color: #334155;
    color: #f1f5f9;
}

[data-theme="dark"] .search-highlight {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.3) 0%, rgba(59, 130, 246, 0.3) 100%);
    color: #f1f5f9;
    border-color: rgba(96, 165, 250, 0.5);
}

[data-theme="dark"] .search-highlight.current {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.3);
    color: #0f172a;
    border-color: #3b82f6;
}
