/* TED Video Rows Styles - Complete Fixed Version */
.ted-video-rows-section {
    padding: var(--ted-space-2xl) 0;
    background: var(--ted-gray-50);
    width: 100%;
    position: relative;
}

.ted-rows-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--ted-space-lg);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Row Header - Fixed: تراز وسط کامل */
.ted-video-row {
    background: var(--ted-white);
    border-radius: var(--ted-radius-xl);
    margin-bottom: var(--ted-space-2xl);
    box-shadow: var(--ted-shadow-lg);
    overflow: hidden;
    transition: all var(--ted-duration) var(--ted-ease);
    width: 100%;
}

.ted-video-row:hover {
    box-shadow: var(--ted-shadow-xl);
    transform: translateY(-2px);
}

/* هدر تراز وسط - کاملاً اصلاح شده */
.ted-row-header-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--ted-space-xl) var(--ted-space-xl) var(--ted-space-lg);
    border-bottom: 1px solid var(--ted-gray-100);
    background: linear-gradient(135deg, var(--ted-white) 0%, var(--ted-gray-50) 100%);
    width: 100%;
}

.ted-row-title-section {
    margin-bottom: var(--ted-space-md);
    width: 100%;
}

.ted-row-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ted-gray-900);
    margin: 0 0 var(--ted-space-xs);
    line-height: 1.2;
    text-align: center;
    width: 100%;
}

.ted-row-subtitle {
    font-size: 1rem;
    color: var(--ted-gray-600);
    margin: 0;
    line-height: 1.4;
    text-align: center;
    width: 100%;
}

.ted-row-actions {
    display: flex;
    align-items: center;
    gap: var(--ted-space-md);
    justify-content: center;
    width: 100%;
}

.ted-row-see-all {
    display: inline-flex;
    align-items: center;
    gap: var(--ted-space-xs);
    color: var(--ted-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--ted-duration) var(--ted-ease);
    padding: var(--ted-space-xs) var(--ted-space-sm);
    border-radius: var(--ted-radius-md);
    background: transparent;
    border: 1px solid transparent;
}

.ted-row-see-all:hover {
    background: var(--ted-gray-50);
    gap: var(--ted-space-sm);
    color: var(--ted-primary-dark);
    border-color: var(--ted-primary-light);
}

/* Row Content */
.ted-row-content {
    padding: var(--ted-space-xl);
    width: 100%;
}

/* Videos Grid - کاملاً اصلاح شده */
.ted-videos-grid {
    display: grid;
    gap: var(--ted-space-lg);
    transition: all var(--ted-duration) var(--ted-ease);
    width: 100%;
    justify-items: center;
}

/* Layouts - نمایش پویا بر اساس تنظیمات */
.ted-videos-grid[data-layout="grid"] {
    grid-template-columns: repeat(var(--columns, 4), 1fr);
}

.ted-videos-grid[data-layout="grid"][data-columns="1"] { 
    grid-template-columns: repeat(1, 1fr); 
}

.ted-videos-grid[data-layout="grid"][data-columns="2"] { 
    grid-template-columns: repeat(2, 1fr); 
}

.ted-videos-grid[data-layout="grid"][data-columns="3"] { 
    grid-template-columns: repeat(3, 1fr); 
}

.ted-videos-grid[data-layout="grid"][data-columns="4"] { 
    grid-template-columns: repeat(4, 1fr); 
}

.ted-videos-grid[data-layout="grid"][data-columns="5"] { 
    grid-template-columns: repeat(5, 1fr); 
}

.ted-videos-grid[data-layout="grid"][data-columns="6"] { 
    grid-template-columns: repeat(6, 1fr); 
}

/* طرح‌بندی لیست */
.ted-videos-grid[data-layout="list"] {
    grid-template-columns: 1fr;
    gap: var(--ted-space-md);
}

/* طرح‌بندی کاروسل */
.ted-videos-grid[data-layout="carousel"] {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--ted-primary) var(--ted-gray-100);
}

.ted-videos-grid[data-layout="carousel"]::-webkit-scrollbar {
    height: 8px;
}

.ted-videos-grid[data-layout="carousel"]::-webkit-scrollbar-track {
    background: var(--ted-gray-100);
    border-radius: 4px;
}

.ted-videos-grid[data-layout="carousel"]::-webkit-scrollbar-thumb {
    background: var(--ted-primary);
    border-radius: 4px;
}

/* Video Item */
.ted-video-item {
    background: var(--ted-white);
    border-radius: var(--ted-radius-lg);
    overflow: hidden;
    box-shadow: var(--ted-shadow-md);
    transition: all var(--ted-duration) var(--ted-ease);
    position: relative;
    scroll-snap-align: start;
    width: 100%;
    height: 100%;
}

.ted-video-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--ted-shadow-lg);
}

.ted-video-thumb {
    position: relative;
    overflow: hidden;
    width: 100%;
}

.ted-thumb-container {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    width: 100%;
}

.ted-thumb-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--ted-duration) var(--ted-ease);
}

.ted-video-item:hover .ted-thumb-image {
    transform: scale(1.05);
}

.ted-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--ted-primary-light) 0%, var(--ted-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ted-placeholder-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.ted-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--ted-duration) var(--ted-ease);
}

.ted-video-item:hover .ted-video-overlay {
    opacity: 1;
}

.ted-play-button {
    width: 50px;
    height: 50px;
    background: var(--ted-primary);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--ted-duration) var(--ted-ease);
    transform: scale(0.9);
}

.ted-video-item:hover .ted-play-button {
    transform: scale(1);
}

.ted-play-button:hover {
    background: var(--ted-primary-dark);
    transform: scale(1.1);
}

.ted-video-duration {
    position: absolute;
    bottom: var(--ted-space-sm);
    left: var(--ted-space-sm);
    background: rgba(0, 0, 0, 0.8);
    color: var(--ted-white);
    padding: 0.25rem 0.5rem;
    border-radius: var(--ted-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.ted-featured-badge {
    position: absolute;
    top: var(--ted-space-sm);
    right: var(--ted-space-sm);
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: var(--ted-gray-900);
    padding: 0.25rem 0.5rem;
    border-radius: var(--ted-radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Video Info */
.ted-video-info {
    padding: var(--ted-space-lg);
    display: flex;
    flex-direction: column;
    height: calc(100% - 200px);
}

.ted-video-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--ted-gray-900);
    margin: 0 0 var(--ted-space-sm);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ted-video-title a {
    color: inherit;
    text-decoration: none;
    transition: color var(--ted-duration) var(--ted-ease);
}

.ted-video-title a:hover {
    color: var(--ted-primary);
}

.ted-video-meta {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--ted-space-sm);
    gap: var(--ted-space-sm);
}

.ted-speaker-info {
    flex: 1;
}

.ted-speaker-name {
    display: block;
    font-weight: 600;
    color: var(--ted-primary);
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.ted-speaker-title {
    display: block;
    font-size: 0.75rem;
    color: var(--ted-gray-600);
}

.ted-video-stats {
    display: flex;
    gap: var(--ted-space-md);
    font-size: 0.75rem;
    color: var(--ted-gray-600);
}

.ted-views-count,
.ted-likes-count {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.ted-video-category {
    margin-bottom: var(--ted-space-sm);
}

.ted-category-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--ted-gray-100);
    color: var(--ted-gray-700);
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--ted-duration) var(--ted-ease);
    border: 1px solid transparent;
}

.ted-category-tag:hover {
    background: var(--ted-primary-light);
    color: var(--ted-white);
    border-color: var(--ted-primary);
}

.ted-video-description {
    color: var(--ted-gray-700);
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0 0 var(--ted-space-md);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

/* Video Actions */
.ted-video-actions {
    display: flex;
    gap: var(--ted-space-xs);
    border-top: 1px solid var(--ted-gray-100);
    padding-top: var(--ted-space-md);
    margin-top: auto;
}

.ted-action-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: none;
    color: var(--ted-gray-600);
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--ted-radius-md);
    font-size: 0.75rem;
    font-weight: 500;
    transition: all var(--ted-duration) var(--ted-ease);
    flex: 1;
    justify-content: center;
    border: 1px solid transparent;
}

.ted-action-btn:hover {
    background: var(--ted-gray-50);
    color: var(--ted-primary);
    transform: translateY(-1px);
    border-color: var(--ted-gray-200);
}

.ted-action-btn.ted-liked {
    color: var(--ted-primary);
    background: rgba(230, 43, 30, 0.1);
}

.ted-action-btn.ted-saved {
    color: var(--ted-primary);
    background: rgba(230, 43, 30, 0.1);
}

.ted-action-text {
    font-size: 0.7rem;
}

/* Empty States */
.ted-row-empty {
    text-align: center;
    padding: var(--ted-space-2xl);
    color: var(--ted-gray-600);
    grid-column: 1 / -1;
    width: 100%;
}

.ted-empty-icon {
    font-size: 3rem;
    margin-bottom: var(--ted-space-md);
    opacity: 0.5;
}

.ted-row-empty h3 {
    color: var(--ted-gray-700);
    margin-bottom: var(--ted-space-sm);
    font-size: 1.25rem;
}

.ted-row-empty p {
    margin-bottom: var(--ted-space-lg);
    font-size: 0.875rem;
}

.ted-no-rows {
    text-align: center;
    padding: var(--ted-space-2xl);
    background: var(--ted-white);
    border-radius: var(--ted-radius-xl);
    box-shadow: var(--ted-shadow-lg);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.ted-no-rows-content {
    max-width: 400px;
    margin: 0 auto;
}

.ted-no-rows-icon {
    font-size: 4rem;
    margin-bottom: var(--ted-space-lg);
    opacity: 0.7;
    display: block;
}

.ted-no-rows h3 {
    color: var(--ted-gray-800);
    margin-bottom: var(--ted-space-sm);
    font-size: 1.5rem;
}

.ted-no-rows p {
    color: var(--ted-gray-600);
    margin-bottom: var(--ted-space-xl);
    line-height: 1.6;
    font-size: 0.875rem;
}

/* Loading States */
.ted-row-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.ted-row-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid var(--ted-gray-300);
    border-top: 3px solid var(--ted-primary);
    border-radius: 50%;
    animation: tedSpin 1s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes tedSpin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Animation for new rows */
@keyframes tedSlideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ted-video-row {
    animation: tedSlideInUp 0.6s var(--ted-ease);
}

.ted-video-row:nth-child(1) { animation-delay: 0.1s; }
.ted-video-row:nth-child(2) { animation-delay: 0.2s; }
.ted-video-row:nth-child(3) { animation-delay: 0.3s; }
.ted-video-row:nth-child(4) { animation-delay: 0.4s; }
.ted-video-row:nth-child(5) { animation-delay: 0.5s; }

/* Responsive Design - کاملاً اصلاح شده */
@media (max-width: 1400px) {
    .ted-videos-grid[data-layout="grid"] {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .ted-rows-container {
        padding: 0 var(--ted-space-md);
    }
    
    .ted-videos-grid[data-layout="grid"] {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .ted-row-header-centered {
        flex-direction: column;
        align-items: center;
        gap: var(--ted-space-md);
        text-align: center;
    }
    
    .ted-row-actions {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .ted-video-rows-section {
        padding: var(--ted-space-xl) 0;
    }
    
    .ted-rows-container {
        padding: 0 var(--ted-space-sm);
    }
    
    .ted-video-row {
        margin-bottom: var(--ted-space-xl);
        border-radius: var(--ted-radius-lg);
    }
    
    .ted-row-header-centered {
        padding: var(--ted-space-lg);
    }
    
    .ted-row-title {
        font-size: 1.5rem;
    }
    
    .ted-row-content {
        padding: var(--ted-space-lg);
    }
    
    .ted-videos-grid[data-layout="grid"] {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--ted-space-md);
    }
    
    .ted-video-info {
        padding: var(--ted-space-md);
    }
    
    .ted-video-actions {
        flex-direction: column;
        gap: var(--ted-space-xs);
    }
    
    .ted-action-btn {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .ted-videos-grid[data-layout="grid"] {
        grid-template-columns: 1fr;
    }
    
    .ted-video-meta {
        flex-direction: column;
        gap: var(--ted-space-xs);
    }
    
    .ted-video-stats {
        align-self: flex-start;
        width: 100%;
        justify-content: space-between;
    }
    
    .ted-row-header-centered {
        padding: var(--ted-space-md);
    }
    
    .ted-row-content {
        padding: var(--ted-space-md);
    }
    
    .ted-row-title {
        font-size: 1.25rem;
    }
    
    .ted-video-title {
        font-size: 1rem;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .ted-video-rows-section {
        background: var(--ted-gray-900);
    }
    
    .ted-video-row {
        background: var(--ted-gray-800);
    }
    
    .ted-row-header-centered {
        background: linear-gradient(135deg, var(--ted-gray-800) 0%, var(--ted-gray-700) 100%);
        border-bottom-color: var(--ted-gray-700);
    }
    
    .ted-row-title {
        color: var(--ted-white);
    }
    
    .ted-row-subtitle {
        color: var(--ted-gray-300);
    }
    
    .ted-video-item {
        background: var(--ted-gray-800);
    }
    
    .ted-video-title {
        color: var(--ted-white);
    }
    
    .ted-video-title a:hover {
        color: var(--ted-primary-light);
    }
    
    .ted-speaker-title {
        color: var(--ted-gray-400);
    }
    
    .ted-video-stats {
        color: var(--ted-gray-400);
    }
    
    .ted-category-tag {
        background: var(--ted-gray-700);
        color: var(--ted-gray-300);
    }
    
    .ted-category-tag:hover {
        background: var(--ted-primary);
        color: var(--ted-white);
    }
    
    .ted-video-description {
        color: var(--ted-gray-300);
    }
    
    .ted-action-btn {
        color: var(--ted-gray-400);
    }
    
    .ted-action-btn:hover {
        background: var(--ted-gray-700);
        color: var(--ted-primary-light);
        border-color: var(--ted-gray-600);
    }
    
    .ted-no-rows {
        background: var(--ted-gray-800);
    }
    
    .ted-no-rows h3 {
        color: var(--ted-white);
    }
    
    .ted-no-rows p {
        color: var(--ted-gray-300);
    }
}

/* Print Styles */
@media print {
    .ted-video-rows-section {
        background: white !important;
        padding: 1cm 0;
    }
    
    .ted-video-row {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #ccc;
    }
    
    .ted-video-item {
        box-shadow: none !important;
        border: 1px solid #ddd;
    }
    
    .ted-video-overlay,
    .ted-play-button,
    .ted-action-btn {
        display: none !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .ted-video-item {
        border: 2px solid var(--ted-gray-900);
    }
    
    .ted-action-btn {
        border: 1px solid var(--ted-gray-700);
    }
    
    .ted-category-tag {
        border: 1px solid var(--ted-gray-600);
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .ted-video-row,
    .ted-video-item,
    .ted-action-btn,
    .ted-play-button,
    .ted-thumb-image,
    .ted-video-overlay {
        transition: none !important;
        animation: none !important;
    }
    
    .ted-video-item:hover {
        transform: none !important;
    }
}

.ted-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--ted-radius-md);
}