:root {
    --primary-color: #1e3a8a;
    --secondary-color: #64748b;
    --accent-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --light-text-color: #64748b;
    --sidebar-bg: #1e293b;
    --sidebar-text: #f1f5f9;
    --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    direction: rtl;
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: bold;
}

.sidebar-menu {
    list-style: none;
}

.menu-item {
    margin-bottom: 5px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.3s ease;
    border-right: 3px solid transparent;
}

.menu-link:hover,
.menu-link.active {
    background: rgba(255, 255, 255, 0.1);
    border-right-color: var(--accent-color);
}

.menu-icon {
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-right: 280px;
    flex: 1;
    padding: 20px;
}

.content-header {
    background: var(--card-background);
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1e40af;
    transform: translateY(-2px);
}

.btn-success {
    background: var(--accent-color);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

/* Dashboard Overview */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-background);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    border-left: 4px solid var(--primary-color);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.stat-title {
    color: var(--light-text-color);
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
}

.stat-change {
    font-size: 0.8rem;
    margin-top: 5px;
}

.stat-change.positive {
    color: var(--accent-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* Tables */
.table-container {
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: var(--shadow-light);
    overflow: hidden;
}

.table-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-size: 1.2rem;
    font-weight: bold;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--background-color);
    font-weight: 600;
    color: var(--text-color);
}

.table tbody tr:hover {
    background: var(--background-color);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-color);
}

.status-offline {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

/* Forms */
.form-container {
    background: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1; /* Make this group span all columns */
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* Map */
.map-container {
    height: 400px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-light);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.modal-content {
    background: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    max-width: 800px; /* Increased max-width for more content */
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.3rem;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--light-text-color);
}

.dynamic-fields-section {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
    margin-bottom: 20px;
    background-color: var(--background-color);
}

.dynamic-fields-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--light-text-color);
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Checkbox specific styling for better alignment/appearance */
.form-group input[type="checkbox"] {
    width: auto; /* Override 100% width */
    margin-left: 5px; /* Space between checkbox and label */
    vertical-align: middle; /* Align with middle of text */
}

.form-group .form-label[for="isActive"] {
    display: inline-block; /* Allow label to sit next to checkbox */
    margin-bottom: 0; /* Remove bottom margin */
    vertical-align: middle;
}


        .api-keys-container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        .tabs {
            display: flex;
            border-bottom: 2px solid #ddd;
            margin-bottom: 30px;
        }

        .tab-btn {
            padding: 12px 24px;
            border: none;
            background: none;
            cursor: pointer;
            font-size: 16px;
            border-bottom: 3px solid transparent;
            transition: all 0.3s;
        }

        .tab-btn.active {
            border-bottom-color: #007bff;
            color: #007bff;
            font-weight: bold;
        }

        .tab-content {
            display: none;
        }

        .tab-content.active {
            display: block;
        }

        .form-section {
            background: white;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            margin-bottom: 30px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
            color: #333;
        }

        .form-input {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
        }

        .form-input:focus {
            outline: none;
            border-color: #007bff;
            box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
        }

        .btn-primary {
            background-color: #007bff;
            color: white;
        }

        .btn-primary:hover {
            background-color: #0056b3;
        }

        .btn-secondary {
            background-color: #6c757d;
            color: white;
        }

        .btn-warning {
            background-color: #ffc107;
            color: #212529;
        }

        .btn-danger {
            background-color: #dc3545;
            color: white;
        }

        .btn-sm {
            padding: 6px 12px;
            font-size: 12px;
        }

        .key-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 8px;
            margin-bottom: 15px;
            background: white;
        }

        .key-info h4 {
            margin: 0 0 8px 0;
            color: #333;
        }

        .key-info p {
            margin: 0 0 5px 0;
            color: #666;
        }

        .key-info small {
            color: #999;
        }

        .key-actions {
            display: flex;
            gap: 10px;
        }

        .no-data {
            text-align: center;
            color: #666;
            font-style: italic;
            padding: 40px;
        }

        .checkbox-group {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .checkbox-group input[type="checkbox"] {
            width: auto;
        }

        .key-modal {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.5);
            display: flex;
            justify-content: center;
            align-items: center;
            z-index: 10000;
        }

        .key-modal-content {
            background: white;
            padding: 30px;
            border-radius: 8px;
            max-width: 500px;
            width: 90%;
        }

        .key-value {
            display: flex;
            gap: 10px;
            margin: 20px 0;
        }

        .key-value input {
            flex: 1;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-family: monospace;
        }

        .back-btn {
            display: inline-flex;
            align-items: center;
            gap: 8px;
            color: #007bff;
            text-decoration: none;
            margin-bottom: 20px;
            font-weight: bold;
        }

        .back-btn:hover {
            color: #0056b3;
        }

        /* إضافة في نهاية ملف style.css */
@media (max-width: 992px) {
    .sidebar {
        width: 80px;
        overflow: hidden;
        transition: width 0.3s ease;
    }
    
    .sidebar:hover, .sidebar.mobile-open {
        width: 280px;
    }
    
    .sidebar-logo span {
        display: none;
    }
    
    .sidebar:hover .sidebar-logo span,
    .sidebar.mobile-open .sidebar-logo span {
        display: inline;
    }
    
    .menu-link span {
        display: none;
    }
    
    .sidebar:hover .menu-link span,
    .sidebar.mobile-open .menu-link span {
        display: inline;
    }
    
    .menu-icon {
        font-size: 1.2rem;
        width: 30px;
    }
    
    .main-content {
        margin-right: 80px;
    }
    
    .sidebar:hover ~ .main-content,
    .sidebar.mobile-open ~ .main-content {
        margin-right: 280px;
    }
    
    /* زر القائمة للجوال */
    .mobile-menu-btn {
        display: block;
        position: fixed;
        top: 15px;
        right: 15px;
        z-index: 2000;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
        cursor: pointer;
    }
}

#dashboardMap {
    width: 100%;
    height: 60vh;
    min-height: 400px;
    border-radius: 12px;
    box-shadow: var(--shadow-light);
}


@media (max-width: 768px) {
    .sidebar {
        width: 0;
        transform: translateX(100%);
    }
    
    .sidebar.mobile-open {
        width: 280px;
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }

     #dashboardMap {
        height: 50vh;
        min-height: 300px;
    }
    
    .map-legend {
        flex-direction: column;
        gap: 8px;
    }
}

/* أنماط قائمة الفيديوهات في نافذة التعديل */
.videos-sortable-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.videos-sortable-list ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.videos-sortable-list li {
    display: flex;
    align-items: center;
    padding: 8px;
    background-color: #fff;
    border: 1px solid #eee;
    margin-bottom: 5px;
    border-radius: 4px;
}

.videos-sortable-list li:hover {
    background-color: #f0f0f0;
}

.videos-sortable-list input[type="checkbox"] {
    margin-right: 10px;
}

.videos-sortable-list .drag-handle {
    margin-left: auto;
    cursor: grab;
    color: #aaa;
}


/* أنماط قسم إدارة المحتوى الإعلاني الجديد */
.ads-content-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
    min-height: 600px;
}

/* القسم الراسي للفيديوهات */
.videos-sidebar {
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.videos-sidebar .sidebar-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    margin: 0;
    border-bottom: none;
}

.videos-sidebar .sidebar-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.videos-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.video-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    margin-bottom: 8px;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.video-item:hover {
    background: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

.video-item-info {
    flex: 1;
    min-width: 0;
}

.video-item-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-item-company {
    font-size: 0.8rem;
    color: var(--light-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-item-actions {
    display: flex;
    gap: 5px;
    margin-right: 8px;
}

.video-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.video-action-btn.view {
    background: var(--accent-color);
    color: white;
}

.video-action-btn.edit {
    background: var(--warning-color);
    color: white;
}

.video-action-btn.delete {
    background: var(--danger-color);
    color: white;
}

.video-action-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-light);
}

/* المنطقة الرئيسية */
.main-content-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
}

/* قسم قوائم التشغيل */
.playlists-section {
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    flex: 0 0 auto;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.section-header {
    background: var(--primary-color);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px 8px 0 0;
}

.section-header h3 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.playlists-table-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.compact-table {
    margin: 0;
}

.compact-table th,
.compact-table td {
    padding: 10px 15px;
    font-size: 0.9rem;
}

.compact-table th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border-color);
}

/* القسم السفلي */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

/* مشغلات البث المباشر */
.live-players-section {
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.live-players-grid {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    align-content: start;
}

.live-player-item {
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.live-player-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-medium);
}

.live-player-video {
    width: 100%;
    height: 160px;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
}

.live-player-info {
    padding: 10px;
    background: white;
    text-align: center;
}

.live-player-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9rem;
    margin: 0;
}

.live-player-status {
    font-size: 0.8rem;
    color: var(--accent-color);
    margin-top: 4px;
}

/* مشغل معاينة الفيديوهات */
.video-preview-section {
    background: var(--card-background);
    border-radius: 8px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-preview-container {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.video-info h4 {
    margin: 0 0 8px 0;
    color: var(--text-color);
    font-size: 1.1rem;
}

.video-info p {
    margin: 0;
    color: var(--light-text-color);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* تحسينات للشاشات الصغيرة */
@media (max-width: 1200px) {
    .ads-content-layout {
        grid-template-columns: 250px 1fr;
    }
    
    .bottom-section {
        grid-template-columns: 1fr;
    }
    
    .live-players-grid {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .ads-content-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .videos-sidebar {
        max-height: 200px;
    }
    
    .bottom-section {
        grid-template-columns: 1fr;
    }
    
    .live-players-grid {
        grid-template-columns: 1fr;
    }
}

/* أنماط إضافية للأزرار الصغيرة */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 4px;
}

/* تحسينات للجداول المدمجة */
.data-table.compact-table tbody tr:hover {
    background-color: #f1f5f9;
}

/* أنماط للحالات الفارغة */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--light-text-color);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-state h4 {
    margin-bottom: 8px;
    color: var(--text-color);
}

.empty-state p {
    font-size: 0.9rem;
}
