@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --dict-primary: #2271b1;
    --dict-primary-dark: #135e96;
    --dict-bg: #f8fafc;
    --dict-card-bg: rgba(255, 255, 255, 0.8);
    --dict-text: #1e293b;
    --dict-text-muted: #64748b;
    --dict-accent: #f43f5e;
    --dict-success: #10b981;
    --dict-glass: rgba(255, 255, 255, 0.1);
    --dict-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

.dict-premium-ui {
    font-family: 'Outfit', sans-serif;
    color: var(--dict-text);
    max-width: 900px;
    margin: 40px auto;
    background: var(--dict-bg);
    padding: 20px;
    border-radius: 24px;
}

/* Search Bar */
.dict-search-wrap {
    position: relative;
    margin-bottom: 30px;
}

#dict-search-input {
    width: 100%;
    padding: 18px 25px;
    font-size: 1.1rem;
    border: 2px solid transparent;
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--dict-shadow);
    transition: all 0.3s ease;
    outline: none;
}

#dict-search-input:focus {
    border-color: var(--dict-primary);
    box-shadow: 0 0 0 4px rgba(34, 113, 177, 0.15);
}

#dict-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 18px;
    margin-top: 10px;
    box-shadow: var(--dict-shadow);
    z-index: 100;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.dict-search-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.dict-search-item:last-child {
    border-bottom: none;
}

.dict-search-item:hover {
    background: #f1f5f9;
    color: var(--dict-primary);
}

/* Word Detail View */
.dict-detail-view {
    background: var(--dict-card-bg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 24px;
    padding: 40px;
    box-shadow: var(--dict-shadow);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dict-word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 20px;
}

.dict-word-header h2 {
    font-size: 3rem;
    margin: 0;
    color: var(--dict-primary-dark);
    text-transform: capitalize;
}

/* Mastered Button */
.dict-master-btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    background: #e2e8f0;
    color: var(--dict-text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dict-master-btn.is-learned {
    background: var(--dict-success);
    color: #fff;
}

.dict-master-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

/* Definitions */
.dict-definition-item {
    margin-bottom: 40px;
}

.dict-def-num {
    font-size: 0.9rem;
    background: var(--dict-primary);
    color: #fff;
    padding: 2px 8px;
    border-radius: 6px;
    margin-right: 10px;
}

.dict-meaning {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 15px;
}

.dict-examples {
    list-style: none;
    padding-left: 20px;
    border-left: 3px solid #e2e8f0;
    margin-bottom: 20px;
}

.dict-examples li {
    font-style: italic;
    color: var(--dict-text-muted);
    margin-bottom: 10px;
    position: relative;
}

/* Synonyms */
.dict-thesaurus {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.dict-synonym {
    background: rgba(34, 113, 177, 0.1);
    color: var(--dict-primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Flashcard Mode */
.dict-flashcard-mode {
    max-width: 900px;
    margin: 0 auto;
    background: #fff;
    border-radius: 30px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
}

.dict-progress-wrapper {
    background: #f8fafc;
    padding: 20px 40px;
    border-bottom: 1px solid #f1f5f9;
}

.dict-progress-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dict-primary-dark);
    margin-bottom: 10px;
}

.dict-progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

#dict-progress-fill {
    height: 100%;
    background: var(--dict-primary);
    width: 0%;
    transition: width 0.4s ease;
}

.dict-flashcard-mode .dict-detail-view {
    padding: 60px;
    min-height: 400px;
}

.dict-nav-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 30px 60px;
    background: #fcfdfe;
    border-top: 1px solid #f1f5f9;
}

.dict-nav-btn {
    background: var(--dict-primary);
    color: #fff;
    border: none;
    padding: 12px 25px;
    border-radius: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dict-nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(34, 113, 177, 0.3);
}

.dict-nav-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Nav Center Fixes */
.dict-nav-center {
    display: flex;
    gap: 10px;
    align-items: center;
}

#dict-level-filter {
    padding: 8px 15px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: var(--dict-primary-dark);
    background: #fff;
    cursor: pointer;
}

/* Dashboard Enhancements */
.dict-vocab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.dict-vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.learned-word-card {
    background: #fff;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    font-weight: 600;
    border: 1px solid #f1f5f9;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.learned-word-card:hover {
    border-color: var(--dict-primary);
    transform: translateY(-2px);
}

.learned-word-card::after {
    content: "✕";
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.learned-word-card:hover::after {
    opacity: 1;
}

.dict-danger-btn {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dict-danger-btn:hover {
    background: #ef4444;
    color: #fff;
}

.dict-level-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--dict-primary);
    color: #fff;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    margin-left: 10px;
    vertical-align: middle;
}

#dict-search-toggle {
    background: #fff;
    border: 1px solid #e2e8f0;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
}

#dict-search-mini-wrap {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    background: #fff;
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
    z-index: 10000;
}

#dict-search-mini-wrap input {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

#dict-search-results {
    max-height: 200px;
    overflow-y: auto;
}

/* Login Prompt Link */
.dict-login-link {
    font-size: 0.9rem;
    color: var(--dict-primary);
    text-decoration: none;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 12px;
    background: rgba(34, 113, 177, 0.08);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.dict-login-link:hover {
    background: rgba(34, 113, 177, 0.15);
    transform: translateY(-1px);
}

/* Responsive Overrides */
@media (max-width: 600px) {
    .dict-premium-ui {
        margin: 10px auto;
        padding: 10px;
        border-radius: 16px;
    }

    .dict-progress-wrapper {
        padding: 15px 20px;
    }

    .dict-flashcard-mode .dict-detail-view {
        padding: 20px;
        min-height: auto;
    }

    .dict-word-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
        padding-bottom: 15px;
        margin-bottom: 20px;
    }

    .dict-word-header h2 {
        font-size: 2.2rem;
    }

    .dict-nav-controls {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "center center"
            "prev next";
        gap: 15px;
        padding: 20px;
        align-items: center;
    }

    .dict-nav-center {
        grid-area: center;
        width: 100%;
        justify-content: center;
        margin: 0 auto;
    }

    #dict-prev-btn {
        grid-area: prev;
        width: 100%;
    }

    #dict-next-btn {
        grid-area: next;
        width: 100%;
    }

    #dict-search-mini-wrap {
        max-width: 90vw;
        bottom: 90px;
    }
}

/* --- Level Selector Screen --- */
.dict-selector-screen {
    padding: 60px 40px;
    background: #fff;
    text-align: center;
}

.dict-selector-header h2 {
    font-size: 2.2rem;
    color: var(--dict-primary-dark);
    margin-bottom: 12px;
    font-weight: 700;
}

.dict-selector-header p {
    color: var(--dict-text-muted);
    font-size: 1.05rem;
    margin-bottom: 40px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

.dict-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.dict-selector-card {
    background: #f8fafc;
    border: 2px solid #f1f5f9;
    border-radius: 20px;
    padding: 35px 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.dict-selector-card:hover {
    transform: translateY(-6px);
    border-color: var(--dict-primary);
    background: #fff;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.dict-card-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.dict-selector-card h3 {
    font-size: 1.5rem;
    margin: 5px 0;
    font-weight: 700;
    color: #1e293b;
}

.dict-card-badge {
    background: rgba(34, 113, 177, 0.1);
    color: var(--dict-primary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 15px;
}

.dict-selector-card p {
    font-size: 0.9rem;
    color: var(--dict-text-muted);
    line-height: 1.5;
    margin-bottom: 25px;
    flex-grow: 1;
}

.dict-card-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: #e2e8f0;
    color: var(--dict-text);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dict-selector-card:hover .dict-card-btn {
    background: var(--dict-primary);
    color: #fff;
}

.dict-selector-footer .dict-all-btn {
    background: transparent;
    border: 1px dashed var(--dict-primary);
    color: var(--dict-primary);
    padding: 12px 30px;
    border-radius: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.dict-selector-footer .dict-all-btn:hover {
    background: rgba(34, 113, 177, 0.05);
}

/* --- Progress Header Controls --- */
.dict-progress-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.dict-back-btn {
    background: transparent;
    border: 1px solid #e2e8f0;
    padding: 8px 15px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dict-text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.dict-back-btn:hover {
    background: #f1f5f9;
    color: var(--dict-text);
    border-color: #cbd5e1;
}

#dict-active-level-label {
    font-weight: 600;
    color: var(--dict-primary);
    background: rgba(34, 113, 177, 0.1);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .dict-selector-screen {
        padding: 30px 15px;
    }
    .dict-selector-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    .dict-progress-info-row {
        flex-direction: row;
        align-items: center;
    }
}