/* استایل‌های عمومی افزونه مدیا کتاب */
.media-book-dashboard,
.media-book-settings,
.media-book-reports {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    color: white;
    margin: 20px 0;
}

.media-book-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    color: #1e3c72;
    margin: 0 0 10px 0;
    font-size: 14px;
}

.stat-number {
    font-size: 24px;
    font-weight: bold;
    color: #2a5298;
}

.quick-actions {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.quick-actions h2 {
    color: #1e3c72;
    margin-top: 0;
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* استایل متاباکس‌ها */
.media-book-metabox {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.files-section {
    border: 1px solid #ddd;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 5px;
}

.files-section h3 {
    margin-top: 0;
    color: #1e3c72;
    border-bottom: 2px solid #1e3c72;
    padding-bottom: 10px;
}

.file-row,
.image-row,
.sample-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.file-row input,
.image-row input,
.sample-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.add-file-btn,
.add-image-btn,
.add-sample-btn,
.upload-image-btn {
    background: #1e3c72;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.add-file-btn:hover,
.add-image-btn:hover,
.add-sample-btn:hover,
.upload-image-btn:hover {
    background: #2a5298;
}

.remove-file-btn,
.remove-image-btn,
.remove-sample-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
}

.remove-file-btn:hover,
.remove-image-btn:hover,
.remove-sample-btn:hover {
    background: #c0392b;
}

/* استایل تب محصول - سازگار با هر قالبی */
.media-book-product-tab {
    padding: 0;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

.media-book-section {
    background: var(--card-bg, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    padding: 0;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.media-book-section:hover {
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.media-book-section-header {
    background: linear-gradient(135deg, var(--accent-color, #667eea) 0%, var(--secondary-color, #764ba2) 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.media-book-section-header h3 {
    margin: 0;
    font-size: 1.25em;
    font-weight: 700 !important;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
}

.section-icon {
    font-size: 1.2em;
    filter: grayscale(1) brightness(2);
}

.media-book-section-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.875em;
    font-weight: 600;
    backdrop-filter: blur(10px);
    font-family: inherit;
}

/* استایل سربرگ تب - سبز چشمک زن */
.media-book-tab-header {
    background: linear-gradient(45deg, #10b981, #34d399, #10b981);
    background-size: 200% 200%;
    color: white !important;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    position: relative;
    overflow: hidden;
    animation: mediaBookPulse 2s ease-in-out infinite, mediaBookGradient 3s ease infinite;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    border: 2px solid #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: inherit;
}

.media-book-tab-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: mediaBookShine 2s ease-in-out infinite;
}

@keyframes mediaBookPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(16, 185, 129, 0.6);
    }
}

@keyframes mediaBookGradient {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes mediaBookShine {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* گرید فایل‌ها */
.media-book-files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 0;
    padding: 0;
}

.media-book-file-category {
    padding: 24px;
    border-bottom: 1px solid var(--border-light, #f1f5f9);
    transition: background-color 0.3s ease;
}

.media-book-file-category:last-of-type {
    border-bottom: none;
}

.media-book-file-category:hover {
    background: var(--hover-color, #f8fafc);
}

.media-book-file-category h4 {
    color: var(--text-color, #1e293b);
    margin: 0 0 16px 0;
    font-size: 1.1em;
    font-weight: 700 !important;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-light, #f1f5f9);
    font-family: inherit;
}

.file-icon {
    filter: grayscale(1);
}

/* لیست فایل‌ها */
.media-book-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.media-book-file-list li {
    margin-bottom: 8px;
}

.media-book-file-list li:last-child {
    margin-bottom: 0;
}

.media-book-file-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--background-color, #ffffff);
    border: 1px solid var(--border-light, #f1f5f9);
    border-radius: 8px;
    color: var(--text-color, #374151);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    font-family: inherit;
    font-size: inherit;
}

.media-book-file-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
    transition: left 0.5s ease;
}

.media-book-file-link:hover::before {
    left: 100%;
}

.media-book-file-link:hover {
    border-color: var(--accent-color, #3b82f6);
    background: var(--hover-color, #f8fafc);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.file-format {
    background: var(--accent-color, #3b82f6);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75em;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
    font-family: inherit;
}

.file-title {
    flex: 1;
    font-weight: 500;
    font-size: 0.95em;
    font-family: inherit;
}

.file-download {
    color: var(--accent-color, #3b82f6);
    font-size: 1.2em;
    font-weight: 600;
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.3s ease;
    filter: grayscale(1);
}

.media-book-file-link:hover .file-download {
    opacity: 1;
    transform: translateX(0);
}

/* گالری عکس‌ها - طراحی جدید */
.media-book-gallery-section {
    padding: 0;
}

.media-book-gallery-container {
    padding: 24px;
}

.media-book-gallery-main {
    margin-bottom: 20px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background: var(--background-color, #f8fafc);
    position: relative;
}

.gallery-main-image {
    width: 100%;
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.gallery-main-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease;
}

.gallery-main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--card-bg, #ffffff);
    border-top: 1px solid var(--border-light, #f1f5f9);
}

.gallery-main-prev,
.gallery-main-next {
    background: var(--accent-color, #3b82f6);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 20px;
    font-weight: bold;
    font-family: inherit;
}

.gallery-main-prev:hover:not(:disabled),
.gallery-main-next:hover:not(:disabled) {
    background: var(--secondary-color, #1d4ed8);
    transform: scale(1.1);
}

.gallery-main-prev:disabled,
.gallery-main-next:disabled {
    background: var(--border-color, #cbd5e1);
    cursor: not-allowed;
    transform: scale(1);
    opacity: 0.5;
}

.gallery-counter {
    font-weight: 600;
    color: var(--text-color, #1e293b);
    font-size: 0.95em;
    font-family: inherit;
}

/* Thumbnails */
.media-book-gallery-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
    max-height: 120px;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color, #3b82f6) var(--border-light, #f1f5f9);
}

.gallery-thumbnail {
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    aspect-ratio: 1;
    opacity: 0.7;
    position: relative;
}

.gallery-thumbnail:hover {
    opacity: 1;
    transform: scale(1.05);
}

.gallery-thumbnail.active {
    border-color: var(--accent-color, #3b82f6);
    opacity: 1;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-thumbnail:hover img {
    transform: scale(1.1);
}

/* پخش کننده صوتی - طراحی جدید */
.media-book-audio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    padding: 24px;
}

.media-book-audio-player {
    background: var(--background-color, #ffffff);
    border: 1px solid var(--border-light, #f1f5f9);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
}

.media-book-audio-player:hover {
    border-color: var(--accent-color, #3b82f6);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.audio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.audio-header h4 {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-color, #1e293b);
    font-family: inherit;
}

.audio-duration {
    font-size: 0.875em;
    color: var(--text-muted, #64748b);
    font-weight: 500;
    font-family: inherit;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.audio-play-btn {
    background: var(--accent-color, #3b82f6);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    filter: grayscale(1) brightness(2);
    flex-shrink: 0;
}

.audio-play-btn:hover {
    background: var(--secondary-color, #1d4ed8);
    transform: scale(1.1);
}

.audio-play-btn.playing {
    background: var(--secondary-color, #1d4ed8);
}

.audio-progress {
    flex: 1;
    min-width: 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border-light, #e2e8f0);
    border-radius: 3px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: height 0.2s ease;
}

.progress-bar:hover {
    height: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color, #3b82f6);
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 3px;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--accent-color, #3b82f6);
    border-radius: 50%;
    transform: translate(50%, -50%) scale(0);
    transition: transform 0.2s ease;
}

.progress-bar:hover .progress-fill::after {
    transform: translate(50%, -50%) scale(1);
}

.audio-time {
    font-size: 0.875em;
    color: var(--text-muted, #64748b);
    font-weight: 500;
    min-width: 45px;
    text-align: center;
    font-family: inherit;
    flex-shrink: 0;
}

/* وضعیت خالی */
.media-book-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--background-color, #f8fafc);
    border-radius: 12px;
    border: 2px dashed var(--border-color, #cbd5e1);
    margin: 20px;
}

.media-book-empty-state p {
    color: var(--text-muted, #64748b);
    font-size: 1em;
    margin: 0;
    font-weight: 500;
    font-family: inherit;
}

/* اسکرول بار برای thumbnails */
.media-book-gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.media-book-gallery-thumbnails::-webkit-scrollbar-track {
    background: var(--border-light, #f1f5f9);
    border-radius: 3px;
}

.media-book-gallery-thumbnails::-webkit-scrollbar-thumb {
    background: var(--accent-color, #3b82f6);
    border-radius: 3px;
}

.media-book-gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color, #1d4ed8);
}

/* واکنش‌گرایی پیشرفته */
@media (max-width: 1200px) {
    .media-book-files-grid {
        grid-template-columns: 1fr;
    }
    
    .media-book-audio-grid {
        grid-template-columns: 1fr;
    }
    
    .gallery-main-image {
        height: 350px;
    }
}

@media (max-width: 768px) {
    .media-book-section-header {
        padding: 16px 20px;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .media-book-section-header h3 {
        font-size: 1.1em;
    }
    
    .media-book-file-category {
        padding: 20px;
    }
    
    .media-book-gallery-container {
        padding: 20px;
    }
    
    .gallery-main-image {
        height: 300px;
    }
    
    .gallery-main-nav {
        padding: 12px 20px;
    }
    
    .gallery-main-prev,
    .gallery-main-next {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .media-book-audio-grid {
        padding: 20px;
        gap: 16px;
    }
    
    .media-book-file-link {
        padding: 10px 14px;
    }
    
    .file-title {
        font-size: 0.9em;
    }
    
    .media-book-tab-header {
        padding: 8px 16px;
        font-size: 0.9em;
    }
    
    .media-book-gallery-thumbnails {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 10px;
        max-height: 100px;
    }
}

@media (max-width: 480px) {
    .media-book-gallery-main {
        margin-bottom: 16px;
    }
    
    .gallery-main-image {
        height: 250px;
    }
    
    .media-book-file-category {
        padding: 16px;
    }
    
    .media-book-gallery-container {
        padding: 16px;
    }
    
    .media-book-audio-grid {
        padding: 16px;
        gap: 12px;
    }
    
    .media-book-file-link {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 16px;
    }
    
    .file-download {
        opacity: 1;
        transform: translateX(0);
    }
    
    .media-book-gallery-thumbnails {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        max-height: 90px;
    }
    
    .gallery-thumbnail {
        border-width: 1px;
    }
    
    .audio-controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .audio-progress {
        order: 3;
        flex: 0 0 100%;
        margin-top: 8px;
    }
    
    .media-book-section-header {
        padding: 14px 16px;
    }
    
    .media-book-section-header h3 {
        font-size: 1em;
    }
    
    .media-book-section-badge {
        font-size: 0.8em;
        padding: 4px 10px;
    }
    
    .audio-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
    
    .audio-header h4 {
        font-size: 1em;
    }
}

@media (max-width: 360px) {
    .gallery-main-image {
        height: 200px;
    }
    
    .media-book-gallery-thumbnails {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .media-book-file-link {
        padding: 12px;
    }
    
    .file-format {
        min-width: 45px;
        padding: 4px 8px;
        font-size: 0.7em;
    }
    
    .audio-controls {
        gap: 8px;
    }
    
    .audio-play-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* انیمیشن‌ها */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.media-book-section {
    animation: fadeInUp 0.6s ease-out;
}

.media-book-file-category {
    animation: fadeInUp 0.8s ease-out;
}

.gallery-thumbnail {
    animation: fadeInUp 1s ease-out;
}

/* پشتیبانی از تم‌های مختلف */
.theme-twentytwentyone .media-book-section,
.theme-twentytwentythree .media-book-section,
.theme-twentytwentyfour .media-book-section {
    --card-bg: var(--wp--preset--color--base);
    --border-color: var(--wp--preset--color--contrast);
    --border-light: var(--wp--preset--color--secondary);
    --background-color: var(--wp--preset--color--base);
    --hover-color: var(--wp--preset--color--secondary);
    --text-color: var(--wp--preset--color--contrast);
    --text-muted: var(--wp--preset--color--tertiary);
    --accent-color: var(--wp--preset--color--primary);
    --secondary-color: var(--wp--preset--color--secondary);
}

/* اطمینان از نمایش صحیح در تب‌های ووکامرس */
.woocommerce-Tabs-panel--media_book_tab {
    padding: 0;
    background: transparent;
}

.woocommerce-Tabs-panel--media_book_tab .media-book-product-tab {
    max-width: 100%;
}

/* تنظیمات صفحه */
.media-book-settings {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.settings-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-top: 30px;
    border-right: 4px solid #3498db;
}

.settings-info h3 {
    color: #2c3e50;
    margin-top: 0;
    font-family: inherit;
}

.settings-info ul {
    margin: 10px 0;
    padding-right: 20px;
}

.settings-info li {
    margin-bottom: 8px;
    line-height: 1.5;
    color: #555;
    font-family: inherit;
}

/* لودینگ برای گالری */
.gallery-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light, #f1f5f9);
    border-top: 3px solid var(--accent-color, #3b82f6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* هایلایت برای المنت‌های فعال */
.media-book-file-link:focus,
.gallery-thumbnail:focus,
.audio-play-btn:focus,
.gallery-main-prev:focus,
.gallery-main-next:focus {
    outline: 2px solid var(--accent-color, #3b82f6);
    outline-offset: 2px;
}

/* کاهش motion برای کاربران حساس به حرکت */
@media (prefers-reduced-motion: reduce) {
    .media-book-section,
    .media-book-file-category,
    .gallery-thumbnail,
    .media-book-file-link,
    .audio-play-btn,
    .gallery-main-prev,
    .gallery-main-next {
        animation: none;
        transition: none;
    }
    
    .media-book-tab-header {
        animation: none;
    }
}