/* css/shadowing.css */

/* YouTube Shadowing Specific Styles */
.level-filter {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: var(--lighter-bg);
    border-radius: var(--border-radius-sm);
}

.level-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--medium-text);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 0.875rem;
    font-weight: 500;
}

.level-btn:hover {
    background: var(--light-bg);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.level-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.search-container {
    display: flex;
    gap: 1rem; /* Increased gap for better spacing */
    margin-bottom: 1.5rem; /* More margin at the bottom */
    align-items: center; /* Vertically align items */
}

#video-search, #content-search { /* Apply to both old and new ID */
    flex: 1;
    padding: 0.85rem 1.2rem; /* Adjusted padding */
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius); /* Larger border-radius */
    font-size: 0.9rem; /* Slightly larger font size */
    transition: all var(--transition-speed) ease;
    box-shadow: var(--shadow-sm); /* Added subtle shadow */
}

#video-search:focus, #content-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); /* Stronger focus shadow */
}

#search-btn, #search-content-btn { /* Apply to both old and new ID */
    padding: 0.7rem 1rem; /* Smaller padding for icon-only button */
    background: var(--gradient-primary); /* Use primary gradient */
    color: white;
    border: none;
    border-radius: var(--border-radius); /* Larger border-radius */
    cursor: pointer;
    font-weight: 600; /* Bolder font weight */
    transition: all var(--transition-speed) var(--transition-bounce); /* Enhanced transition */
    box-shadow: var(--shadow-md); /* Added shadow */
    font-size: 1.1rem; /* Adjust font size for icon */
    width: 45px; /* Fixed width for a square button */
    height: 45px; /* Fixed height for a square button */
    display: flex; /* Use flexbox to center icon */
    align-items: center;
    justify-content: center;
}

#search-btn:hover, #search-content-btn:hover {
    transform: translateY(-2px) scale(1.05); /* Subtle lift and scale on hover */
    box-shadow: var(--shadow-lg); /* Stronger shadow on hover */
    filter: brightness(1.1); /* Slightly brighter on hover */
}

.item-list {
    max-height: 600px; /* Adjust as needed */
    overflow-y: auto;
    padding: 15px; /* Adjusted padding */
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    list-style: none;
    margin: 0;
}

/* Custom Scrollbar for Webkit browsers */
.item-list::-webkit-scrollbar {
    width: 8px;
}

.item-list::-webkit-scrollbar-track {
    background: var(--light-bg);
    border-radius: 10px;
}

.item-list::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 10px;
    border: 2px solid var(--light-bg);
}

.item-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.content-item { /* Renamed from .video-item */
    display: flex;
    gap: 15px; /* Increased gap for better spacing */
    align-items: center; /* Vertically align items */
    padding: 15px; /* Generous padding for each item */
    margin-bottom: 10px; /* Space between items */
    background: white; /* White background for each item */
    border-radius: var(--border-radius); /* Rounded corners */
    box-shadow: var(--shadow-sm); /* Subtle shadow for card effect */
    transition: all var(--transition-speed) ease;
    cursor: pointer;
    border: 1px solid var(--border-color); /* Added a subtle border */
}

.content-item:last-child { /* Renamed from .video-item */
    margin-bottom: 0;
}

.content-item:hover { /* Renamed from .video-item */
    background: var(--primary-light); /* Highlight with primary light color */
    transform: translateY(-3px); /* More pronounced lift on hover */
    box-shadow: var(--shadow-lg); /* Stronger shadow on hover */
    border-color: var(--primary-color); /* Highlight border */
}

.content-thumbnail { /* Renamed from .video-thumbnail */
    width: 100px; /* Larger thumbnail */
    height: 75px; /* Maintain 4:3 aspect ratio */
    object-fit: cover;
    border-radius: 8px; /* Rounded corners */
    flex-shrink: 0; /* Prevent shrinking */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow */
}

.content-details { /* Renamed from .video-details */
    flex: 1;
    min-width: 0;
}

.content-details h4 { /* Renamed from .video-details h4 */
    font-size: 1.05rem; /* Slightly larger font for title */
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 5px; /* Small margin below title */
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.content-details p { /* Renamed from .video-details p */
    font-size: 0.85rem; /* Slightly larger font for description */
    color: var(--medium-text);
    margin: 0;
    line-height: 1.4;
}

.loading-item, .error-item {
    padding: 1rem; /* Adjusted padding */
    text-align: center;
    color: var(--medium-text);
    font-style: italic;
}

.error-item {
    color: var(--danger-color);
}

/* Video Player Container Enhancements */
.video-player-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    width: 100%;
    max-width: 950px;
    margin-left: auto;
    margin-right: auto;
}

#youtube-player {
    width: 100%;
    max-width: 800px;
    height: 450px;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin: 0 auto;
    display: block;
}

.video-info {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.video-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.sentence-progress {
    font-size: 0.875rem;
    color: var(--medium-text);
    font-weight: 500;
    margin: 0;
}

.current-sentence {
    background: var(--light-bg);
    padding: 1rem;
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--primary-color);
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--dark-text);
    margin: 1rem 0;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

/* Enhanced Controls Panel for Shadowing */
.shadowing-layout .controls-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin: 1.5rem 0;
    padding: 1rem;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.shadowing-layout .controls-panel .btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--border-radius-sm);
    transition: all var(--transition-speed) ease;
    border: none;
    cursor: pointer;
    text-decoration: none;
    min-width: auto;
}

/* Adjustments for mode selector buttons */
.mode-selector .btn {
    padding: 0.6rem 1rem; /* Smaller padding */
    font-size: 0.8rem; /* Smaller font size */
    min-width: unset; /* Remove minimum width constraint */
}

.shadowing-layout .controls-panel .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.shadowing-layout .controls-panel .btn:active {
    transform: translateY(0);
}

.shadowing-layout .controls-panel .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.shadowing-layout .controls-panel .btn i {
    font-size: 1rem;
}

/* Recording Status Indicators */
.shadowing-layout .controls-panel .btn.recording {
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Loading Animation for Video List */
.loading-item::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design for YouTube Features */
@media (max-width: 768px) {
    .shadowing-layout {
        flex-direction: column;
    }
    
.video-selection-sidebar {
    order: 2;
    width: 100%;
    margin-top: 2rem;
    padding: 1.5rem; /* Added padding to the sidebar */
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}
    
    .practice-zone {
        order: 1;
        width: 100%;
    }
    
    #youtube-player {
        width: 100%;
        height: 250px;
    }
    
    .shadowing-layout .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-top-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .video-controls-row,
    .recording-controls-row,
    .navigation-controls-row {
        min-width: auto;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .shadowing-layout .controls-panel .btn {
        justify-content: center;
        flex: 1;
        min-width: 120px;
        max-width: 150px;
    }
    
    .level-filter {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .level-btn {
        flex: 1;
        min-width: 80px;
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }
    
    .search-container {
        flex-direction: row;
        gap: 0.5rem;
    }
    
    #content-search {
        flex: 1;
        min-width: 0;
    }
    
    #search-content-btn {
        width: 40px;
        height: 40px;
        flex-shrink: 0;
    }
    
.content-item { /* Renamed from .video-item */
    flex-direction: column;
    text-align: center;
    align-items: center; /* Center items in column layout */
    padding: 15px; /* Consistent padding */
}
    
.content-thumbnail { /* Renamed from .video-thumbnail */
    width: 100%;
    height: 150px; /* Adjusted height for mobile */
    align-self: center;
    margin-bottom: 10px; /* Space below thumbnail */
}
}

/* Tablet responsive design */
@media (max-width: 768px) {
    #youtube-player {
        max-width: 100%;
        height: 350px;
    }
}

@media (max-width: 480px) {
    .video-player-container {
        padding: 1rem;
    }
    
    #youtube-player {
        height: 250px;
    }
    
    .current-sentence {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .shadowing-layout .controls-panel .btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }
}

/* Accessibility Improvements */
.shadowing-layout .controls-panel .btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

#video-search:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.level-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Add Video Button Hover Effect */
#add-video-btn:hover {
    background: linear-gradient(135deg, #45a049, #3d8b40) !important;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.4) !important;
    transform: translateY(-1px);
}

#add-video-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3) !important;
}

#add-video-btn:focus {
    outline: 2px solid #4CAF50;
    outline-offset: 2px;
}

/* Controls Panel Layout */
.controls-panel {
    display: flex;
    flex-direction: column; /* 保持主容器为列方向 */
    gap: 15px;
    margin: 20px 0;
}

.controls-top-row { /* 新增的容器，用于放置视频和录音控制 */
    display: flex;
    flex-wrap: wrap; /* 允许换行 */
    gap: 15px; /* 内部行之间的间距 */
    justify-content: center; /* 居中对齐 */
    width: 100%; /* 占据父容器的全部宽度 */
}

.video-controls-row,
.recording-controls-row,
.navigation-controls-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex: 1; /* 让这些行在 controls-top-row 中平分空间 */
    min-width: 300px; /* 确保在小屏幕上也能有足够的宽度 */
}

.video-controls-row {
    padding: 10px;
    background: linear-gradient(135deg, var(--primary-light) 0%, #a7b4f8 100%); /* 调整为更浅的紫色渐变 */
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(129, 140, 248, 0.3); /* 调整阴影颜色 */
}

.recording-controls-row {
    padding: 10px;
    background: linear-gradient(135deg, #81b4f8 0%, #5c9bf6 100%); /* 调整为更浅的蓝色渐变 */
    border-radius: 12px;
    box-shadow: 0 4px 8px rgba(129, 180, 248, 0.3); /* 调整阴影颜色 */
}

.navigation-controls-row {
    padding: 10px;
    /* background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); */ /* 移除蓝色底纹 */
    background: none; /* 确保背景被移除 */
    border-radius: 12px;
    /* box-shadow: 0 4px 8px rgba(79, 172, 254, 0.3); */ /* 移除阴影 */
    box-shadow: none; /* 确保阴影被移除 */
}

/* Recording Cache Section */
.recording-cache-section {
    margin-top: 20px;
    padding: 20px;
    background: var(--gradient-card);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
}

.recording-cache-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cache-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.no-recordings {
    color: var(--medium-text);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.cache-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.cache-item:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.cache-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cache-item-title {
    font-weight: 500;
    color: var(--dark-text);
}

.cache-item-duration {
    font-size: 12px;
    color: var(--medium-text);
}

.cache-item-controls {
    display: flex;
    gap: 8px;
}

.cache-play-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.cache-play-btn:hover {
    background: #0d9488;
    transform: scale(1.05);
}

.cache-delete-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.cache-delete-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

/* Merged Recording Section */
.merged-recording-section {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    color: white;
}

.merged-recording-section h3 {
    color: white;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.merged-recording-player {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.merged-recording-info {
    text-align: center;
}

.merged-recording-details {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 15px;
    font-size: 14px;
}

.merged-recording-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

#download-merged-audio-btn {
    background: var(--success-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

#download-merged-audio-btn:hover {
    background: #0d9488;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

#clear-merged-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

#clear-merged-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

#merged-audio-player {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
}

/* New styles for podcast categories */
.podcast-category {
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    background-color: var(--light-bg);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--lighter-bg);
    cursor: pointer;
    font-weight: 600;
    color: var(--dark-text);
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.category-header:hover {
    background-color: #e2e8f0;
}

.category-header h4 {
    margin: 0;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-toggle-icon {
    transition: transform 0.3s ease;
}

.category-toggle-icon.fa-chevron-up {
    transform: rotate(180deg);
}

.category-podcast-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-podcast-list .item-list-link {
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    padding-left: 30px; /* Indent podcast items */
    background-color: transparent;
}

.category-podcast-list .item-list-link:hover,
.category-podcast-list .item-list-link.active-item {
    background-color: #f0f8ff; /* Lighter hover for sub-items */
    border-left: 0.3rem solid var(--primary-light); /* Lighter border for sub-items */
    box-shadow: none;
}

.podcast-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px; /* Add padding to podcast items */
    background-color: white; /* White background for podcast items */
    border-bottom: 1px solid var(--border-color); /* Separator */
}

.podcast-item:last-child {
    border-bottom: none; /* No border for the last podcast item */
}

.podcast-item:hover {
    background-color: var(--light-bg); /* Hover effect for podcast items */
}

.podcast-item i {
    color: var(--primary-color);
    font-size: 1.1em;
}

/* Dropdown Navigation */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: rgba(255, 255, 255, 0.95);
    min-width: 160px;
    box-shadow: var(--shadow-lg);
    z-index: 1;
    border-radius: var(--border-radius-sm);
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    top: 100%; /* Position below the parent link */
    left: 50%; /* Center horizontally */
    transform: translateX(-50%); /* Adjust for centering */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}

.dropdown-content a {
    color: var(--dark-text);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-weight: 500;
}

.dropdown-content a:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
    text-decoration: none;
}

.dropdown:hover .dropdown-content {
    display: block;
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(5px); /* Slight lift on hover */
}

/* Adjust active state for dropdown parent */
.dropdown > a.active {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

/* Ensure dropdown icon is styled */
.dropdown > a i {
    margin-left: 0.5rem;
    transition: transform 0.3s ease;
}

.dropdown:hover > a i {
    transform: rotate(180deg);
}

/* Mobile specific adjustments for dropdown */
@media (max-width: 768px) {
    header nav ul li.dropdown {
        width: 100%;
    }
    .dropdown-content {
        position: static; /* Allow dropdown to flow naturally in mobile */
        width: 100%;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background-color: rgba(248, 250, 252, 0.95); /* More opaque background for mobile dropdown */
        transform: none;
        opacity: 0; /* Hidden by default */
        visibility: hidden;
        max-height: 0;
        overflow: hidden;
        transition: all 0.3s ease-in-out;
        padding: 0;
    }
    
    .dropdown.open .dropdown-content {
        opacity: 1;
        visibility: visible;
        max-height: 200px;
        padding-left: 20px; /* Indent dropdown items when open */
    }
    .dropdown-content a {
        padding: 10px 15px;
        font-size: 0.95rem;
    }
    .dropdown:hover .dropdown-content {
        transform: none; /* Remove transform on hover for mobile */
    }
    .dropdown > a i {
        display: none; /* Hide caret on mobile as it's not a hover dropdown */
    }
}
