/* =============================================
   Alhosary Educational Platform - Main Styles
   ============================================= */

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

:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e3a53;
    --accent: #f39c12;
    --accent-hover: #e67e22;
    --bg: #0f1923;
    --bg-card: #1a2737;
    --bg-input: #0d1b2a;
    --text: #ecf0f1;
    --text-muted: #7f8c8d;
    --border: #2c3e50;
    --success: #27ae60;
    --danger: #e74c3c;
    --radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

html {
    font-size: 16px;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* --- Login Page --- */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(26, 82, 118, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(243, 156, 18, 0.08) 0%, transparent 50%),
        var(--bg);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-light), var(--accent));
}

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

.login-logo .icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 32px;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

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

.input-wrapper {
    position: relative;
}

.input-wrapper .input-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
}

.form-control {
    width: 100%;
    padding: 14px 44px 14px 14px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(41, 128, 185, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 10px 20px;
    width: auto;
    font-size: 0.85rem;
}

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

/* --- Alert Messages --- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: none;
    text-align: center;
}

.alert-error {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

.alert-success {
    background: rgba(39, 174, 96, 0.15);
    border: 1px solid rgba(39, 174, 96, 0.3);
    color: #27ae60;
}

/* --- Spinner --- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =============================================
   Player Page
   ============================================= */

.player-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.header-brand h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-user .user-info {
    text-align: left;
    font-size: 0.85rem;
}

.header-user .user-info .name {
    font-weight: 600;
}

.header-user .user-info .code {
    color: var(--accent);
    font-size: 0.8rem;
}

/* --- Main Layout --- */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: 320px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.video-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.video-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.video-item:hover {
    background: rgba(41, 128, 185, 0.1);
}

.video-item.active {
    background: rgba(41, 128, 185, 0.2);
    border: 1px solid rgba(41, 128, 185, 0.3);
}

.video-item .item-number {
    width: 32px;
    height: 32px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.video-item.active .item-number {
    background: var(--primary-light);
    color: white;
}

.video-item .item-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.video-item .item-info p {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Video Area --- */
.video-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.video-wrapper {
    position: relative;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.video-wrapper .ratio-box {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
}

.video-wrapper .ratio-box iframe,
.video-wrapper .ratio-box .video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-card);
    color: var(--text-muted);
    font-size: 1.1rem;
}

.video-placeholder .play-icon {
    font-size: 3rem;
    opacity: 0.4;
}

.video-title-bar {
    max-width: 960px;
    margin: 16px auto 0;
    width: 100%;
}

.video-title-bar h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.video-title-bar p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Watermark Overlay --- */
.watermark-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.watermark-text {
    position: absolute;
    color: rgba(255, 255, 255, 0.04);
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    transform: rotate(-30deg);
    pointer-events: none;
}

/* --- Loading State --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    z-index: 10000;
    transition: opacity 0.3s;
}

.loading-overlay .loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column-reverse;
    }

    .sidebar {
        width: 100%;
        max-height: 250px;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .video-area {
        padding: 16px;
    }

    .login-card {
        padding: 32px 24px;
    }

    .header {
        padding: 10px 16px;
    }

    .header-brand h2 {
        font-size: 0.95rem;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* --- No-print --- */
@media print {
    body {
        display: none !important;
    }
}
