/* تحسينات CSS لقسم إدارة المحتوى الإعلاني */

/* تخطيط القسم الرئيسي */
.ads-content-section {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-color);
    color: var(--text-color);
}

/* الشريط العلوي */
.top-section {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
}

.videos-sidebar {
    flex: 0 0 300px;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.playlists-compact {
    flex: 1;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 15px;
}

/* القسم السفلي */
.bottom-section {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px;
    transition: grid-template-columns 0.3s ease;
}

.bottom-section.with-preview {
    grid-template-columns: 1fr 1fr;
}

/* قائمة الفيديوهات */
.videos-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.video-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--hover-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.video-item:hover {
    background: var(--accent-color-light);
    border-color: var(--accent-color);
}

.video-item-info {
    flex: 1;
    min-width: 0;
}

.video-item-name {
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.video-item-company {
    font-size: 0.85em;
    color: var(--light-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-item-actions {
    display: flex;
    gap: 5px;
    margin-left: 10px;
}

.video-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
}

.video-action-btn.view {
    background: var(--accent-color);
    color: white;
}

.video-action-btn.view:hover {
    background: var(--accent-color-dark);
}

.video-action-btn.edit {
    background: var(--warning-color);
    color: white;
}

.video-action-btn.edit:hover {
    background: var(--warning-color-dark);
}

.video-action-btn.delete {
    background: var(--danger-color);
    color: white;
}

.video-action-btn.delete:hover {
    background: var(--danger-color-dark);
}

/* جدول قوائم التشغيل المدمج */
.playlists-compact-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.playlists-compact-table th,
.playlists-compact-table td {
    padding: 10px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.playlists-compact-table th {
    background: var(--hover-bg);
    font-weight: 600;
    color: var(--text-color);
}

.playlists-compact-table td {
    color: var(--light-text-color);
}

/* قسم معاينة الفيديو */
.video-preview-section {
    display: none;
    flex-direction: column;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.video-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.video-preview-title {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.close-preview-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.close-preview-btn:hover {
    background: var(--danger-color-dark);
}

.video-preview-player {
    width: 100%;
    height: 300px;
    background: #000;
    border-radius: 6px;
    margin-bottom: 15px;
}

.video-preview-description {
    color: var(--light-text-color);
    font-size: 0.9em;
    line-height: 1.4;
}

/* قسم مشغلات البث المباشر */
.live-players-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.live-players-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 15px;
}

.live-player-item {
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.live-player-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.live-player-container {
    position: relative;
    width: 100%;
    height: 200px;
    background: #000;
    border-radius: 6px;
    margin-bottom: 10px;
    overflow: hidden;
}

.live-player-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* تحسينات مشغل HLS */
.hls-status-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    z-index: 10;
    transition: all 0.3s ease;
}

.hls-status-connected {
    background: rgba(34, 197, 94, 0.9);
}

.hls-status-connecting {
    background: rgba(251, 191, 36, 0.9);
}

.hls-status-disconnected {
    background: rgba(239, 68, 68, 0.9);
}

.hls-error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    max-width: 80%;
    z-index: 20;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.hls-error-message i {
    font-size: 24px;
    margin-bottom: 5px;
}

.live-player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.live-player-name {
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.95em;
}

.live-player-status {
    font-size: 0.85em;
    color: var(--light-text-color);
    font-weight: 500;
}

/* حالات فارغة */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--light-text-color);
    min-height: 200px;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h4 {
    margin: 0 0 10px 0;
    color: var(--text-color);
    font-weight: 600;
}

.empty-state p {
    margin: 0;
    font-size: 0.9em;
    opacity: 0.8;
}

/* حالة التحميل */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: var(--light-text-color);
    font-style: italic;
}

/* أزرار الإجراءات */
.btn-group {
    display: flex;
    gap: 5px;
}

.btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 11px;
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--hover-bg);
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: var(--warning-color-dark);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-color-dark);
}

/* متغيرات CSS */
:root {
    --accent-color: #3b82f6;
    --accent-color-light: rgba(59, 130, 246, 0.1);
    --accent-color-dark: #2563eb;
    --warning-color: #f59e0b;
    --warning-color-dark: #d97706;
    --danger-color: #ef4444;
    --danger-color-dark: #dc2626;
    --success-color: #10b981;
    --success-color-dark: #059669;
}

/* تحسينات الاستجابة */
@media (max-width: 1200px) {
    .top-section {
        flex-direction: column;
    }
    
    .videos-sidebar {
        flex: none;
        max-height: 300px;
    }
    
    .live-players-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .bottom-section {
        grid-template-columns: 1fr !important;
        padding: 10px;
    }
    
    .top-section {
        padding: 10px;
        gap: 10px;
    }
    
    .live-players-grid {
        grid-template-columns: 1fr;
    }
    
    .video-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .video-item-actions {
        margin-left: 0;
        justify-content: center;
    }
}

/* تحسينات إضافية للمشغلات */
.live-player-container video {
    border-radius: 6px;
}

.live-player-container:hover .hls-status-overlay {
    opacity: 0.8;
}

/* تأثيرات التحميل */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading {
    animation: pulse 2s infinite;
}

/* تحسينات الجدول */
.playlists-compact-table tbody tr:hover {
    background: var(--hover-bg);
}

.text-muted {
    color: var(--light-text-color);
    font-style: italic;
}

/* تحسينات أزرار الفيديو */
.video-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.video-action-btn:disabled:hover {
    background: inherit;
}

/* تحسينات معاينة الفيديو */
.video-preview-section.active {
    display: flex;
}

.video-preview-player video {
    width: 100%;
    height: 100%;
    border-radius: 6px;
}

/* تحسينات حالة الخطأ */
.hls-error-message.show {
    display: flex;
}

/* تحسينات الشريط الجانبي */
.videos-sidebar::-webkit-scrollbar {
    width: 6px;
}

.videos-sidebar::-webkit-scrollbar-track {
    background: var(--hover-bg);
    border-radius: 3px;
}

.videos-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.videos-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-color);
}

