/**
 * Video Portal - Main Stylesheet
 */

/* CSS Variables */
:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --sidebar-color: #1e272e;
    --sidebar-hover: #2d3a45;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #17a2b8;
    --light-bg: #f8f9fa;
    --dark-text: #2c3e50;
    --border-color: #dee2e6;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.6;
}

body.rtl,
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

/* RTL Support */
html[dir="rtl"] .sidebar,
body.rtl .sidebar {
    left: auto;
    right: 0;
}

html[dir="rtl"] .main-content,
body.rtl .main-content {
    margin-left: 0;
    margin-right: 260px;
}

html[dir="rtl"] .sidebar-nav a,
body.rtl .sidebar-nav a {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .sidebar-menu a,
body.rtl .sidebar-menu a {
    flex-direction: row-reverse;
    text-align: right;
}

html[dir="rtl"] .top-bar,
body.rtl .top-bar {
    flex-direction: row-reverse;
}

html[dir="rtl"] .user-info,
body.rtl .user-info {
    flex-direction: row-reverse;
}

html[dir="rtl"] .btn,
body.rtl .btn {
    flex-direction: row-reverse;
}

html[dir="rtl"] .alert,
body.rtl .alert {
    flex-direction: row-reverse;
}

html[dir="rtl"] .stat-card,
body.rtl .stat-card {
    flex-direction: row-reverse;
}

html[dir="rtl"] .card-header,
body.rtl .card-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-header,
body.rtl .modal-header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .modal-footer,
body.rtl .modal-footer {
    flex-direction: row-reverse;
}

html[dir="rtl"] .form-switch,
body.rtl .form-switch {
    flex-direction: row-reverse;
}

html[dir="rtl"] .color-input-wrapper,
body.rtl .color-input-wrapper {
    flex-direction: row-reverse;
}

html[dir="rtl"] .current-image,
body.rtl .current-image {
    flex-direction: row-reverse;
}

html[dir="rtl"] .table .actions,
body.rtl .table .actions {
    flex-direction: row-reverse;
}

html[dir="rtl"] .video-meta,
body.rtl .video-meta {
    flex-direction: row-reverse;
}

html[dir="rtl"] .mobile-toggle,
body.rtl .mobile-toggle {
    right: auto;
    left: 20px;
}

@media (max-width: 992px) {
    html[dir="rtl"] .sidebar,
    body.rtl .sidebar {
        transform: translateX(100%);
    }
    
    html[dir="rtl"] .sidebar.active,
    body.rtl .sidebar.active {
        transform: translateX(0);
    }
    
    html[dir="rtl"] .main-content,
    body.rtl .main-content {
        margin-right: 0;
    }
}

a {
    text-decoration: none;
    color: var(--primary-color);
}

a:hover {
    text-decoration: underline;
}

/* Login Page Styles */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    padding: 20px;
}

.login-page.has-bg {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.login-container {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 420px;
    padding: 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo img {
    max-width: 180px;
    max-height: 80px;
}

.login-logo h1 {
    color: var(--secondary-color);
    font-size: 28px;
    margin-top: 10px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary-color);
}

.login-form input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.login-form .btn {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

.login-form .btn:hover {
    background: var(--secondary-color);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

/* Portal Layout */
.portal-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-color);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s;
    z-index: 1000;
    left: 0;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header img {
    max-width: 150px;
    max-height: 60px;
}

.sidebar-header h2 {
    font-size: 18px;
    margin-top: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
}

.sidebar-menu li {
    margin: 0;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255,255,255,0.8);
    transition: all 0.3s;
    gap: 12px;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    background: var(--sidebar-hover);
    color: white;
    text-decoration: none;
    border-left: 4px solid var(--primary-color);
}

html[dir="rtl"] .sidebar-menu a:hover,
html[dir="rtl"] .sidebar-menu a.active {
    border-left: none;
    border-right: 4px solid var(--primary-color);
}

.sidebar-menu i {
    width: 20px;
    text-align: center;
}

.menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 15px 0;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 20px;
}

/* Top Bar */
.top-bar {
    background: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.top-bar h1 {
    font-size: 24px;
    color: var(--secondary-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 18px;
    color: var(--secondary-color);
}

.card-body {
    padding: 25px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.stat-icon.blue { background: var(--primary-color); }
.stat-icon.green { background: var(--success-color); }
.stat-icon.orange { background: var(--warning-color); }
.stat-icon.red { background: var(--danger-color); }

.stat-info h3 {
    font-size: 28px;
    color: var(--secondary-color);
}

.stat-info p {
    color: #666;
    font-size: 14px;
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.video-card {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s;
}

.video-card:hover {
    transform: translateY(-5px);
}

.video-thumbnail {
    height: 180px;
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 50px;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-info {
    padding: 20px;
}

.video-info h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--secondary-color);
}

.video-info p {
    color: #666;
    font-size: 14px;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #888;
}

.video-category {
    background: var(--light-bg);
    padding: 4px 10px;
    border-radius: 15px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: #2980b9;
    text-decoration: none;
    color: white;
}

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

.btn-success:hover {
    background: #219a52;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--secondary-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

html[dir="rtl"] .table th,
html[dir="rtl"] .table td {
    text-align: right;
}

.table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--secondary-color);
}

.table tr:hover {
    background: var(--light-bg);
}

.table .actions {
    display: flex;
    gap: 8px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-primary {
    background: #cce5ff;
    color: #004085;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    color: var(--secondary-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 25px;
}

.settings-tabs .tab {
    padding: 15px 25px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    color: #666;
    transition: all 0.3s;
}

.settings-tabs .tab:hover {
    color: var(--primary-color);
}

.settings-tabs .tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Logo Preview */
.logo-preview {
    margin-top: 10px;
    padding: 15px;
    background: var(--light-bg);
    border-radius: 8px;
    text-align: center;
}

.logo-preview img {
    max-width: 200px;
    max-height: 80px;
}

/* Color Preview */
.color-preview {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-preview input[type="color"] {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

/* Download Button */
.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 25px;
    background: var(--success-color);
    color: white;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.3s;
}

.download-btn:hover {
    background: #219a52;
    text-decoration: none;
    color: white;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state i {
    font-size: 60px;
    color: #ccc;
    margin-bottom: 20px;
}

.empty-state h3 {
    margin-bottom: 10px;
}

/* Mobile Toggle */
.mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 999;
}

/* Admin Wrapper */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation (Admin) */
.sidebar-nav {
    padding: 20px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255,255,255,0.8);
    transition: all 0.3s;
    gap: 12px;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--sidebar-hover);
    color: white;
    text-decoration: none;
    border-left: 4px solid var(--primary-color);
}

html[dir="rtl"] .sidebar-nav a:hover,
html[dir="rtl"] .sidebar-nav a.active {
    border-left: none;
    border-right: 4px solid var(--primary-color);
}

.sidebar-nav i {
    width: 20px;
    text-align: center;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 15px 0;
}

/* Content Header */
.content-header {
    margin-bottom: 25px;
}

.content-header h1 {
    font-size: 28px;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

.content-header p {
    color: #666;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .video-grid {
        grid-template-columns: 1fr;
    }
    
    .table th,
    .table td {
        padding: 10px;
        font-size: 14px;
    }
}
