/* Global Styles for Navigation and Floating Buttons */

/* Top Navigation Bar */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: rgba(79, 70, 229, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

@media (min-width: 768px) {
    .top-nav {
        padding: 0 2rem;
    }
}

/* Top Nav Left Section */
.top-nav-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Top Nav Right Section */
.top-nav-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Mobile Navigation Toggle Button */
.mobile-nav-toggle {
    display: none;
    background-color: transparent;
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.mobile-nav-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 767px) {
    .mobile-nav-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Top Navigation Buttons */
.top-nav .nav-home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
    text-decoration: none;
    font-size: 1.25rem;
}

.top-nav .nav-home-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.top-nav .nav-units-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9);
    color: rgb(79, 70, 229);
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.875rem;
}

.top-nav .nav-units-btn:hover {
    background-color: rgb(238, 242, 255); /* hover:bg-indigo-100 */
}

/* Touch device optimizations */
.top-nav .nav-units-btn:active,
.top-nav .nav-units-btn:focus {
    background-color: rgb(238, 242, 255);
    outline: none;
}

/* Improve touch target size for mobile */
@media (max-width: 767px) {
    .mobile-nav-toggle {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }
}

/* Units Button Container for Dropdown Positioning */
.units-btn-container {
    position: relative;
    display: inline-block;
}

/* Responsive Navigation Display */
@media (min-width: 768px) {
    .mobile-nav-toggle {
        display: none !important;
    }
    
    .mobile-nav-menu {
        display: none !important;
    }
}

@media (max-width: 767px) {
    .top-nav-right .units-btn-container {
        display: none !important;
    }
}

/* Mobile Navigation Menu */
.mobile-nav-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background-color: rgba(79, 70, 229, 0.95);
    backdrop-filter: blur(8px);
    padding: 1rem;
    z-index: 55;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-nav-menu.show {
    display: block;
}

.mobile-nav-menu .nav-item {
    display: block;
    color: white;
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s;
}

.mobile-nav-menu .nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.mobile-nav-menu .nav-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

/* Touch optimizations for mobile nav items */
.mobile-nav-menu .nav-item {
    min-height: 44px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
}

.mobile-nav-menu .nav-item:active {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Units Dropdown for Top Navigation */
.units-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    width: 12rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid rgb(229, 231, 235);
    padding: 0.5rem 0;
    display: none;
    z-index: 60;
}

/* Mobile dropdown adjustments */
@media (max-width: 767px) {
    .units-dropdown {
        position: fixed;
        top: 60px;
        left: 1rem;
        right: 1rem;
        width: auto;
        max-height: calc(100vh - 80px);
        overflow-y: auto;
    }
}

.units-dropdown.show {
    display: block;
}

.units-dropdown .dropdown-header {
    font-weight: 500;
    color: rgb(107, 114, 128);
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.units-dropdown .dropdown-item {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: rgb(55, 65, 81);
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}

.units-dropdown .dropdown-item:hover {
    background-color: rgb(238, 242, 255);
    color: rgb(79, 70, 229);
}

.units-dropdown .dropdown-item.active {
    background-color: rgb(238, 242, 255);
    color: rgb(79, 70, 229);
    font-weight: 500;
}

/* Touch optimizations for dropdown items */
.units-dropdown .dropdown-item {
    min-height: 44px;
    display: flex;
    align-items: center;
    touch-action: manipulation;
}

.units-dropdown .dropdown-item:active {
    background-color: rgb(224, 231, 255);
    color: rgb(79, 70, 229);
}

/* Floating Buttons */
.circle-button {
    background-color: rgba(79, 70, 229, 0.7); /* indigo-600 with 70% opacity */
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
    backdrop-filter: blur(4px);
    position: fixed;
    z-index: 1000;
}

.circle-button:hover {
    background-color: rgba(67, 56, 202, 0.8); /* indigo-700 with 80% opacity */
}

/* Vocabulary Button */
#vocab-btn {
    bottom: 180px;
    right: 20px;
    cursor: grab;
}

#vocab-btn:active {
    cursor: grabbing;
}

/* Mobile adjustments for vocab button */
@media (max-width: 768px) {
    #vocab-btn {
        bottom: 180px;
        right: 10px;
    }
}

/* Table of Contents Button */
#toc-btn {
    bottom: 120px;
    right: 20px;
}

/* Back to Top Button */
#back-to-top-btn {
    bottom: 60px;
    right: 20px;
    display: none;
    background-color: rgba(80, 80, 80, 0.7);
}

#back-to-top-btn:hover {
    background-color: rgba(48, 48, 48, 0.8);
}

/* Content Layout Adjustment for Top Navigation */
.main-content {
    margin-top: 60px; /* Space for top navigation */
    transition: margin-top 0.3s ease;
}

/* Ensure body has no margin conflicts */
body {
    margin: 0;
    padding: 0;
}

/* Modal Styles */
#vocab-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

#vocab-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

#vocab-modal-content {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Enhanced smooth scrolling */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.5) transparent;
}

/* Custom scrollbar styles for webkit browsers */
#vocab-modal-content::-webkit-scrollbar {
    width: 8px;
}

#vocab-modal-content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

#vocab-modal-content::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 4px;
    transition: background 0.2s ease;
}

#vocab-modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.7);
}

#vocab-modal-content::-webkit-scrollbar-thumb:active {
    background: rgba(75, 85, 99, 0.8);
}

/* Enhanced scrolling for transcript containers */
#transcript-container {
    scroll-behavior: smooth !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(156, 163, 175, 0.5) transparent !important;
}

#transcript-container::-webkit-scrollbar {
    width: 6px;
}

#transcript-container::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

#transcript-container::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.4);
    border-radius: 3px;
    transition: background 0.2s ease;
}

#transcript-container::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.6);
}

/* Enhanced scrolling for general scrollable containers */
.overflow-y-auto, [class*="overflow-y-auto"] {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.overflow-x-auto, [class*="overflow-x-auto"] {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Enhanced scrolling for any overflow auto elements */
.overflow-auto, [class*="overflow-auto"] {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.vocab-category {
    background: #f0f9ff;
    color: #0369a1;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-left: 8px;
    border: 1px solid #bae6fd;
}

#close-vocab-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

#close-vocab-btn:hover {
    color: #000;
}

/* Vocabulary Search and Alphabet Index */
.vocab-search-container {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding-bottom: 10px;
}

#vocab-search {
    font-size: 14px;
    transition: border-color 0.3s ease;
}

#vocab-search:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.vocab-alphabet-index {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

.alphabet-btn {
    padding: 6px 12px;
    margin: 2px;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
}

.alphabet-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.alphabet-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Vocabulary category filter styles */
.vocab-category-filter {
    position: sticky;
    top: 60px;
    background: white;
    z-index: 9;
    padding: 10px 0;
    border-bottom: 1px solid #e5e7eb;
}

.category-btn {
    padding: 6px 12px;
    margin: 2px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.category-btn.active {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.category-select {
    padding: 8px 16px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    transition: all 0.2s ease;
    min-width: 200px;
    outline: none;
}

.category-select:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.category-select:focus {
    background: #e2e8f0;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.vocab-item.hidden {
    display: none;
}

/* Table of Contents Dropdown */
.toc-dropdown-container {
    position: fixed;
    display: inline-block;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

#toc-dropdown {
    display: none;
    position: absolute;
    top: 0;
    right: calc(100% + 8px);
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    min-width: 200px;
    max-width: 250px;
    padding: 8px 0;
}

#toc-dropdown.show {
    display: block;
}

#toc-dropdown a {
    display: block;
    padding: 12px 16px;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.2s;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#toc-dropdown a:hover {
    background-color: #f3f4f6;
    color: #4f46e5;
}

/* ===== 词汇表组件主题变量 ===== */
:root {
    --vocab-primary-color: #3B82F6;
    --vocab-secondary-color: #1E40AF;
    --vocab-accent-color: #60A5FA;
    --vocab-background-color: #F8FAFC;
    --vocab-text-color: #374151;
    --vocab-border-color: #E5E7EB;
    --vocab-hover-color: #F3F4F6;
}

/* ===== 增强的词汇表组件样式 ===== */
.vocabulary-component {
    background: var(--vocab-background-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.vocabulary-component .vocab-search-container input {
    border-color: var(--vocab-border-color);
    transition: all 0.3s ease;
}

.vocabulary-component .vocab-search-container input:focus {
    border-color: var(--vocab-primary-color);
    box-shadow: 0 0 0 3px rgba(var(--vocab-primary-color), 0.1);
}

.vocabulary-component .category-select {
    border-color: var(--vocab-border-color);
    background: white;
}

.vocabulary-component .category-select:focus {
    border-color: var(--vocab-primary-color);
    box-shadow: 0 0 0 3px rgba(var(--vocab-primary-color), 0.1);
}

.vocabulary-component .vocab-item {
    background: white;
    border: 1px solid var(--vocab-border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.vocabulary-component .vocab-item:hover {
    border-color: var(--vocab-accent-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.vocabulary-component .vocab-term {
    color: var(--vocab-primary-color);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.vocabulary-component .vocab-phonetic {
    color: var(--vocab-secondary-color);
    font-style: italic;
    font-size: 14px;
    background: rgba(var(--vocab-primary-color), 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.vocabulary-component .vocab-type {
    background: var(--vocab-accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-right: 8px;
}

.vocabulary-component .vocab-category {
    background: rgba(var(--vocab-primary-color), 0.1);
    color: var(--vocab-primary-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(var(--vocab-primary-color), 0.2);
}

.vocabulary-component .vocab-meaning {
    color: var(--vocab-text-color);
    font-size: 15px;
    line-height: 1.5;
    font-weight: 500;
}

.vocabulary-component .vocab-example {
    color: #6B7280;
    font-style: italic;
    font-size: 14px;
    line-height: 1.4;
    padding: 8px 12px;
    background: #F9FAFB;
    border-left: 3px solid var(--vocab-accent-color);
    border-radius: 0 4px 4px 0;
}

.vocabulary-component .vocab-extended {
    color: #6B7280;
    font-size: 13px;
    line-height: 1.4;
    padding: 8px 12px;
    background: #FFFBEB;
    border-radius: 4px;
    border: 1px solid #FDE68A;
}

/* ===== 网格布局样式 ===== */
.vocabulary-component.layout-grid .vocab-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.vocabulary-component.layout-grid .vocab-item {
    margin-bottom: 0;
}

/* ===== 主题变体 ===== */
.vocabulary-component.theme-tech-business {
    --vocab-primary-color: #3B82F6;
    --vocab-secondary-color: #1E40AF;
    --vocab-accent-color: #60A5FA;
    --vocab-background-color: #F8FAFC;
}

.vocabulary-component.theme-daily-conversation {
    --vocab-primary-color: #10B981;
    --vocab-secondary-color: #047857;
    --vocab-accent-color: #34D399;
    --vocab-background-color: #F0FDF4;
}

.vocabulary-component.theme-home-kitchen {
    --vocab-primary-color: #F59E0B;
    --vocab-secondary-color: #D97706;
    --vocab-accent-color: #FBBF24;
    --vocab-background-color: #FFFBEB;
}

.vocabulary-component.theme-business-analysis {
    --vocab-primary-color: #8B5CF6;
    --vocab-secondary-color: #7C3AED;
    --vocab-accent-color: #A78BFA;
    --vocab-background-color: #FAF5FF;
}

.vocabulary-component.theme-service-industry {
    --vocab-primary-color: #EF4444;
    --vocab-secondary-color: #DC2626;
    --vocab-accent-color: #F87171;
    --vocab-background-color: #FEF2F2;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .vocabulary-component.layout-grid .vocab-list-container {
        grid-template-columns: 1fr;
    }
    
    .vocabulary-component .vocab-item {
        padding: 12px;
    }
    
    .vocabulary-component .vocab-term {
        font-size: 16px;
    }
}

/* ===== 加载状态 ===== */
.vocabulary-component .loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--vocab-text-color);
}

.vocabulary-component .loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--vocab-border-color);
    border-top: 2px solid var(--vocab-primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== 空状态 ===== */
.vocabulary-component .empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6B7280;
}

.vocabulary-component .empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--vocab-text-color);
}

.vocabulary-component .empty-state p {
    font-size: 14px;
    margin: 0;
}