/* === my_dictionary.css === */
.dictionary-item {
    padding: 12px;
    border-radius: 8px;
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--book-transition);
}

.dictionary-item:hover {
    border-color: var(--book-accent);
    transform: translateX(4px);
}

.dictionary-item.selected {
    background: var(--book-accent-glow);
    border-color: var(--book-accent);
    box-shadow: 0 4px 12px var(--book-accent-glow);
}

.dictionary-item-word {
    font-weight: 700;
    font-size: 1rem;
    color: var(--book-text);
}

.dictionary-item-trans {
    font-size: 0.8rem;
    color: var(--book-text-muted);
}

.dictionary-field {
    margin-bottom: 25px;
}

.dictionary-field label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--book-text-dim);
    margin-bottom: 8px;
    font-weight: 600;
}

.dictionary-field input,
.dictionary-field textarea {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--book-border);
    background: var(--book-surface-2);
    color: var(--book-text);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--book-transition);
}

.dictionary-field input:focus,
.dictionary-field textarea:focus {
    border-color: var(--book-accent);
    background: var(--book-surface);
    box-shadow: 0 0 0 3px var(--book-accent-glow);
}

.dictionary-edit-word-input {
    font-family: 'Playfair Display', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--book-accent);
    background: transparent;
    border: none;
    border-bottom: 2px dashed transparent;
    width: 100%;
    outline: none;
    padding: 0;
    margin: 0;
    transition: var(--book-transition);
}

.dictionary-edit-word-input:hover,
.dictionary-edit-word-input:focus {
    border-bottom-color: var(--book-accent-glow);
}

.dictionary-description-textarea {
    min-height: 240px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

#edit-dict-note {
    min-height: 120px;
    resize: vertical;
}

/* Selection Menu */
.dictionary-selection-menu {
    position: absolute;
    z-index: 10000;
    display: none;
    background: #333;
    color: white;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    animation: menu-fade-in 0.2s ease-out;
}

.dictionary-selection-menu button {
    background: transparent;
    border: none;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    font-family: inherit;
}

.dictionary-selection-menu button:hover {
    background: var(--book-accent);
}

@keyframes menu-fade-in {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

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

/* Mobile specific */
.is-mobile-device .dictionary-body {
    flex-direction: column;
}

.is-mobile-device .dictionary-list {
    width: 100% !important;
    border-right: none !important;
    max-height: 300px;
}

/* Catalogs Sidebar Styles */
.dictionary-sidebar-section {
    margin-bottom: 20px;
}

.dictionary-sidebar-title-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--book-text-dim);
    margin-bottom: 12px;
    padding: 0 5px;
    font-weight: 700;
}

.catalog-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
    font-size: 0.85rem;
    color: var(--book-text);
    border: 1px solid transparent;
}

.catalog-item:hover {
    background: var(--book-surface-2);
}

.catalog-item.active {
    background: var(--book-accent-glow);
    color: var(--book-accent);
    font-weight: 600;
    border-color: var(--book-accent-glow);
}

.catalog-icon {
    margin-right: 10px;
    font-size: 1.1rem;
    opacity: 0.8;
    width: 20px;
    text-align: center;
}

.catalog-count {
    margin-left: auto;
    font-size: 0.7rem;
    opacity: 0.5;
    background: var(--book-surface-3);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Context Menu */
.dict-context-menu {
    position: fixed;
    z-index: 11000;
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 6px 0;
    min-width: 200px;
    animation: menu-fade-in 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.dict-context-item {
    padding: 8px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    color: var(--book-text);
}

.dict-context-item:hover {
    background: var(--book-accent-glow);
    color: var(--book-accent);
}

.dict-context-item.mini {
    padding: 6px 10px;
    font-size: 0.75rem;
    cursor: pointer;
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    transition: all 0.2s;
    text-align: center;
}

.dict-context-item.mini:hover {
    background: var(--book-accent);
    color: #fff;
    border-color: var(--book-accent);
}

.dict-context-divider {
    height: 1px;
    background: var(--book-border);
    margin: 6px 0;
    opacity: 0.6;
}

.dict-context-submenu-parent {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dict-context-submenu {
    position: absolute;
    left: 100%;
    top: -6px;
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    padding: 6px 0;
    min-width: 180px;
    display: none;
    max-height: 300px;
    overflow-y: auto;
}

.dict-context-submenu-parent:hover>.dict-context-submenu {
    display: block;
}

/* Scrollbar for submenu */
.dict-context-submenu::-webkit-scrollbar {
    width: 4px;
}

.dict-context-submenu::-webkit-scrollbar-thumb {
    background: var(--book-border);
    border-radius: 2px;
}

@keyframes menu-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(5px);
    }
}

/* Sidebar Header Fix */
.is-dictionary-mode .book-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
}

.is-dictionary-mode .book-btn-add {
    width: auto;
    height: 32px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
    background: var(--book-accent-glow);
    color: var(--book-accent);
    border: 1px solid var(--book-accent);
    border-radius: 8px;
    white-space: nowrap;
}

/* Selection Indicator */
.dictionary-item {
    position: relative;
}

.dict-selection-index {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--book-accent);
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.dict-ext-link {
    font-size: 0.75rem;
    color: var(--book-text-dim);
    text-decoration: none;
    padding: 0 10px;
    border-radius: 6px;
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    height: 32px;
    box-sizing: border-box;
}

.dict-ext-link:hover {
    background: var(--book-accent-glow);
    color: var(--book-accent);
    border-color: var(--book-accent);
    transform: translateY(-1px);
}
@keyframes spin-refresh { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.rotating { animation: spin-refresh 0.6s linear infinite; display: inline-block; }

/* TTS Buttons */
.dict-tts-btn {
    cursor: pointer;
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-accent);
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 6px;
    transition: all 0.2s;
    height: 24px;
}

.dict-tts-btn:hover {
    background: var(--book-accent-glow);
    border-color: var(--book-accent);
    transform: translateY(-1px);
}

.dict-tts-btn.active {
    background: var(--book-accent);
    color: #fff;
    border-color: var(--book-accent);
    box-shadow: 0 2px 8px var(--book-accent-glow);
}

.dict-tts-btn.active .tts-engine-label {
    color: #fff;
    opacity: 1;
}

.dict-tts-btn .tts-icon {
    font-size: 0.8rem;
}

.dict-tts-btn .tts-engine-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-size: 0.6rem;
    opacity: 0.9;
}

.translation-row .book-page-action-btn:hover {
    color: var(--book-accent-hover) !important;
    transform: scale(1.2);
}

.dict-tts-help-btn {
    cursor: pointer;
    background: none;
    border: none;
    color: var(--book-text-dim);
    font-size: 0.85rem;
    padding: 0 2px;
    opacity: 0.6;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.dict-tts-help-btn:hover {
    opacity: 1;
    color: var(--book-accent);
    transform: scale(1.1);
}

.dict-tts-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.dict-tts-group {
    border: 1px solid var(--book-border);
    border-radius: 8px;
    padding: 2px 8px 0 8px;
    position: relative;
    display: inline-flex;
    background: var(--book-surface-1);
    height: 32px;
    align-items: center;
    box-sizing: border-box;
}

.dict-tts-group-label {
    position: absolute;
    top: -7px;
    left: 8px;
    background: var(--book-surface);
    padding: 0 4px;
    font-size: 0.55rem;
    color: var(--book-accent);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    opacity: 0.9;
}
