/**
 * 即時線上字典樣式
 * Dictionary Modal Styles - Enhanced for Mobile
 */

/* ========================================
   MODAL CONTAINER
   ======================================== */
.dict-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 8vh;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.dict-modal.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   BACKDROP
   ======================================== */
.dict-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ========================================
   CONTENT CONTAINER
   ======================================== */
.dict-modal-content {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    margin: 0 16px;
    background: var(--color-surface, #ffffff);
    border-radius: 24px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    overflow: hidden;
    transform: scale(0.92) translateY(-20px);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
}

.dict-modal.active .dict-modal-content {
    transform: scale(1) translateY(0);
}

/* ========================================
   SEARCH BOX - ENHANCED
   ======================================== */
.dict-search-box {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    gap: 14px;
    background: linear-gradient(180deg, var(--color-surface, #fff) 0%, var(--color-background, #f8fafc) 100%);
    flex-shrink: 0;
}

.dict-search-icon {
    font-size: 1.4rem;
    opacity: 0.6;
    flex-shrink: 0;
}

.dict-search-box input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    font-size: 1.15rem;
    font-weight: 500;
    background: transparent;
    color: var(--color-text, #0f172a);
    font-family: var(--font-body, 'Nunito', sans-serif);
}

.dict-search-box input::placeholder {
    color: var(--color-text-muted, #94a3b8);
    font-weight: 400;
}

.dict-kbd {
    padding: 5px 10px;
    font-size: 0.7rem;
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-weight: 600;
    background: var(--color-background, #f1f5f9);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
    color: var(--color-text-muted, #64748b);
    flex-shrink: 0;
}

/* Close Button */
.dict-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--color-background, #f1f5f9);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 10px;
    color: var(--color-text-muted, #64748b);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.dict-close-btn:hover {
    background: var(--color-error-light, #fee2e2);
    border-color: var(--color-error, #ef4444);
    color: var(--color-error, #ef4444);
}

.dict-close-btn:active {
    transform: scale(0.92);
}

.dict-close-btn svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   RESULTS AREA
   ======================================== */
.dict-results {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar */
.dict-results::-webkit-scrollbar {
    width: 6px;
}

.dict-results::-webkit-scrollbar-track {
    background: transparent;
}

.dict-results::-webkit-scrollbar-thumb {
    background: var(--color-border, #cbd5e1);
    border-radius: 3px;
}

.dict-results::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, #94a3b8);
}

/* ========================================
   EMPTY STATE
   ======================================== */
.dict-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 32px;
    text-align: center;
    color: var(--color-text-muted, #64748b);
}

.dict-empty span {
    font-size: 3rem;
    margin-bottom: 16px;
    filter: grayscale(0.2);
}

.dict-empty p {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 8px;
    color: var(--color-text, #334155);
}

.dict-empty small {
    font-size: 0.9rem;
    opacity: 0.8;
}

.dict-empty.dict-error {
    color: var(--color-error, #ef4444);
}

.dict-empty.dict-error span {
    filter: none;
}

/* ========================================
   LOADING STATE
   ======================================== */
.dict-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    gap: 14px;
    color: var(--color-text-muted, #64748b);
    font-weight: 500;
}

.dict-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border, #e2e8f0);
    border-top-color: var(--color-primary, #3b82f6);
    border-radius: 50%;
    animation: dict-spin 0.7s linear infinite;
}

@keyframes dict-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   RESULT ITEM - ENHANCED
   ======================================== */
.dict-result-item {
    padding: 16px 18px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    margin-bottom: 8px;
}

.dict-result-item:last-child {
    margin-bottom: 0;
}

.dict-result-item:hover {
    background: var(--color-primary-light, #dbeafe);
    border-color: var(--color-primary, #3b82f6);
    transform: translateX(4px);
}

.dict-result-item:active {
    transform: scale(0.98) translateX(4px);
}

.dict-word-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.dict-word {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-heading, 'Fredoka', sans-serif);
    color: var(--color-text, #0f172a);
    letter-spacing: -0.5px;
}

.dict-phonetic {
    font-size: 0.9rem;
    color: var(--color-primary, #3b82f6);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    background: var(--color-primary-light, #dbeafe);
    padding: 2px 8px;
    border-radius: 6px;
}

.dict-badge {
    padding: 3px 8px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dict-badge.oxford {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}

.dict-badge.collins {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    letter-spacing: -1px;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}

.dict-translation {
    font-size: 1rem;
    color: var(--color-text-muted, #475569);
    line-height: 1.6;
}

.dict-tags {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.dict-tag {
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--color-background, #f1f5f9);
    color: var(--color-text-muted, #64748b);
    border-radius: 6px;
    border: 1px solid var(--color-border, #e2e8f0);
}

/* ========================================
   HEADER SEARCH BUTTON
   ======================================== */
.dict-search-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--color-background, #f1f5f9);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 12px;
    color: var(--color-text-muted, #64748b);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dict-search-btn:hover {
    background: var(--color-surface, #ffffff);
    border-color: var(--color-primary, #3b82f6);
    color: var(--color-primary, #3b82f6);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.dict-search-btn .search-icon {
    font-size: 1.1rem;
}

.dict-search-btn .search-hint {
    display: none;
}

@media (min-width: 768px) {
    .dict-search-btn .search-hint {
        display: block;
        padding: 3px 8px;
        font-size: 0.7rem;
        font-family: var(--font-mono, monospace);
        font-weight: 600;
        background: var(--color-surface, #ffffff);
        border: 1px solid var(--color-border, #e2e8f0);
        border-radius: 6px;
    }
}

/* ========================================
   MOBILE RESPONSIVENESS
   ======================================== */
@media (max-width: 640px) {
    .dict-modal {
        padding-top: 0;
        align-items: stretch;
    }

    .dict-modal-content {
        margin: 0;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        max-width: 100%;
    }

    .dict-modal.active .dict-modal-content {
        transform: scale(1) translateY(0);
    }

    .dict-search-box {
        padding: 16px 20px;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .dict-search-box input {
        font-size: 1.1rem;
    }

    .dict-kbd {
        display: none;
    }

    .dict-results {
        padding: 12px 16px;
        max-height: none;
        flex: 1;
    }

    .dict-result-item {
        padding: 18px 16px;
        margin-bottom: 10px;
        border: 1px solid var(--color-border, #e2e8f0);
        background: var(--color-surface, #fff);
    }

    .dict-result-item:hover {
        transform: none;
    }

    .dict-result-item:active {
        transform: scale(0.98);
        background: var(--color-primary-light, #dbeafe);
    }

    .dict-word {
        font-size: 1.3rem;
    }

    .dict-translation {
        font-size: 1.05rem;
    }

    .dict-empty {
        padding: 80px 24px;
    }
}

/* ========================================
   DARK MODE SUPPORT
   ======================================== */
/* Theme attribute dark mode */
[data-theme="dark"] .dict-modal-content {
    background: #1e293b;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .dict-search-box {
    border-bottom-color: #334155;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

[data-theme="dark"] .dict-search-box input {
    color: #f1f5f9;
}

[data-theme="dark"] .dict-result-item:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] .dict-word {
    color: #f1f5f9;
}

[data-theme="dark"] .dict-translation {
    color: #94a3b8;
}

[data-theme="dark"] .dict-kbd {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

[data-theme="dark"] .dict-tag {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

[data-theme="dark"] .dict-phonetic {
    background: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .dict-result-item {
    border-color: #334155;
    background: #1e293b;
}

/* System preference dark mode */
@media (prefers-color-scheme: dark) {
    .dict-modal-content {
        background: #1e293b;
        box-shadow:
            0 25px 50px -12px rgba(0, 0, 0, 0.5),
            0 0 0 1px rgba(255, 255, 255, 0.05);
    }

    .dict-search-box {
        border-bottom-color: #334155;
        background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    }

    .dict-search-box input {
        color: #f1f5f9;
    }

    .dict-result-item:hover {
        background: rgba(59, 130, 246, 0.15);
        border-color: rgba(59, 130, 246, 0.4);
    }

    .dict-word {
        color: #f1f5f9;
    }

    .dict-translation {
        color: #94a3b8;
    }

    .dict-kbd {
        background: #334155;
        border-color: #475569;
        color: #94a3b8;
    }

    .dict-tag {
        background: #334155;
        border-color: #475569;
        color: #94a3b8;
    }

    .dict-phonetic {
        background: rgba(59, 130, 246, 0.2);
    }

    .dict-result-item {
        border-color: #334155;
        background: #1e293b;
    }
}