@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
    color-scheme: light;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --primary: #2f80ed;
    --primary-dark: #1b4fb0;
    --secondary: #7f8fa6;
    --danger: #e74c3c;
    --success: #1abc9c;
    --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    --radius: 16px;
    --text: #0f172a;
    --muted: #6b7280;
    --border: #e5e7eb;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #111827;
    color: #f8fafc;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.character-list li {
    border-radius: 12px;
    margin-bottom: 8px;
    transition: background 0.2s ease;
}

.character-list li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    color: inherit;
}

.character-list li.active,
.character-list li:hover {
    background: rgba(255, 255, 255, 0.08);
}

.character-list .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.2);
}

.content {
    padding: 32px;
}

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

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.video-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-thumb {
    position: relative;
    width: 100%;
    padding-top: calc(16 / 9 * 100%);
    border-radius: 14px;
    overflow: hidden;
    background: #0f172a;
}

.video-thumb img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.video-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.video-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    text-align: center;
    background: #e5e7eb;
    color: #111827;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f0f4ff;
    color: #1c3c87;
}

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

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

.btn-light {
    background: #f3f4f6;
    color: #111827;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    padding-inline: 8px;
}

.btn.copied {
    background: #22c55e;
    color: #fff;
}

.empty-box {
    padding: 32px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow);
    text-align: center;
    color: var(--muted);
}

.form-page {
    max-width: 600px;
    margin: 50px auto;
    padding: 24px;
}

.form-card {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 600;
    color: var(--text);
}

input[type="text"],
input[type="file"],
textarea {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 15px;
    background: #fff;
}

textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.alert {
    border-radius: 12px;
    padding: 12px;
    font-weight: 600;
}

.alert.error {
    background: #fdecea;
    color: #611a15;
}

.alert.success {
    background: #e8f7e9;
    color: #256029;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal[hidden] {
    display: none !important;
}

.modal-dialog {
    background: var(--surface);
    border-radius: var(--radius);
    width: min(520px, 90vw);
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow);
}

.modal-header,
.modal-footer {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.modal-open {
    overflow: hidden;
}

.details-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.details-image {
    border-radius: 12px;
    overflow: hidden;
}

.details-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.detail-row {
    background: #f8fafc;
    padding: 12px;
    border-radius: 10px;
}

.detail-row dt {
    font-weight: 700;
    margin-bottom: 4px;
}

.detail-row dd {
    margin: 0;
    color: var(--muted);
    white-space: pre-line;
}

.detail-link {
    background: #fff7ed;
    padding: 12px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.details-image img {
    width: 100%;
    display: block;
}

.progress-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 32px;
}

.progress-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.progress-bar {
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    height: 16px;
}

.progress-bar-fill {
    background: linear-gradient(270deg, #22d3ee, #3b82f6);
    height: 100%;
    width: 0;
    transition: width 0.5s ease;
}

.progress-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.badge {
    border-radius: 999px;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
}

.badge.success {
    background: #dcfce7;
    color: #166534;
}

.badge.failed {
    background: #fee2e2;
    color: #991b1b;
}

.logs ul {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-top: 16px;
}

.logs li {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.logs li:last-child {
    border-bottom: none;
}

.logs .meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--muted);
}

.logs .message {
    margin-top: 6px;
    line-height: 1.6;
}

.message-box {
    border-radius: 10px;
    padding: 12px;
    font-weight: 600;
    display: none;
}

.message-box.success {
    background: #ecfdf5;
    color: #065f46;
}

.message-box.error {
    background: #fef2f2;
    color: #991b1b;
}

.video-show {
    max-width: 1000px;
    margin: 0 auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.video-player {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.video-meta {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: grid;
    gap: 16px;
}

.meta-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.meta-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.meta-row span {
    color: var(--muted);
    font-size: 13px;
}

.meta-row strong {
    font-size: 16px;
}

.primary-image {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 600;
}

@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 240px 1fr;
    }
}

@media (max-width: 768px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        grid-row: 2;
        flex-direction: row;
        overflow-x: auto;
    }

    .content {
        padding: 20px;
    }

    .video-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
