:root {
    /* Color Palette - Dark Theme (Default) */
    --bg-primary: #0f1115;
    --bg-secondary: #1a1d24;
    --card-bg: #222630;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --primary: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    --accent: #f43f5e;
    /* Rose 500 */
    --success: #10b981;
    --border-color: #3f3f46;
    --glass-bg: rgba(15, 17, 21, 0.8);
    --primary-rgb: 99, 102, 241;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
}

/* Cart Icon & Badge */
.header-cart-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: rgba(var(--primary-rgb), 0.1);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.header-cart-container:hover {
    background: rgba(var(--primary-rgb), 0.15);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.cart-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--bg-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.cart-price-display {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 768px) {

    /* We allow price display on mobile now, but can hide it in very tight headers if needed */
    .guest-nav-container .cart-price-display {
        display: none;
        /* Keep hidden in public top nav to avoid overflow */
    }

    .sidebar .cart-price-display {
        display: inline-block;
        /* Show in mobile sidebar menu as requested */
    }

    .guest-nav-links.mobile-open .cart-price-display {
        display: inline-block;
        /* Consistency for guest mobile menu */
    }
}

/* Sidebar Collapsed State Fixes */
.dashboard-layout.sidebar-collapsed .sidebar-header {
    padding: 16px 0;
    flex-direction: column;
    height: auto;
    gap: 12px;
}

.dashboard-layout.sidebar-collapsed .collapse-btn {
    margin: 0 auto;
    order: 1;
}

.dashboard-layout.sidebar-collapsed .header-cart-container {
    padding: 8px;
    margin: 0 auto !important;
    width: 44px;
    height: 44px;
    justify-content: center;
    border-radius: 12px;
    order: 2;
}

.dashboard-layout.sidebar-collapsed .cart-price-display {
    display: none !important;
}

.dashboard-layout.sidebar-collapsed .sidebar-logo {
    display: none;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --accent: #e11d48;
    --success: #059669;
    --border-color: #e5e7eb;
    --glass-bg: rgba(255, 255, 255, 0.8);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
    max-width: 100%;
}

html {
    overflow-x: hidden;
    max-width: 100%;
    background-color: var(--bg-primary);
}

[dir="rtl"] body,
[dir="rtl"] {
    font-family: 'Cairo', sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
}

/* Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 8px;
}

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

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

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

.btn-secondary:hover {
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

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

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

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

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

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

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 12px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

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

.table th {
    text-align: left;
    padding: 16px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.table tr:last-child td {
    border-bottom: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.spinner-border {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    vertical-align: text-bottom;
    border: .2em solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

.delay-100 {
    animation-delay: 0.1s;
}

.delay-200 {
    animation-delay: 0.2s;
}

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

.course-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.2s;
}

.course-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.course-thumbnail {
    height: 180px;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    position: relative;
}

.course-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.course-content {
    padding: 20px;
}

.course-category {
    font-size: 0.8rem;
    color: var(--primary);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 8px;
}

.course-title {
    font-size: 1.1rem;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 4.2em;
}

.course-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.course-price {
    font-weight: 700;
    font-size: 1.1rem;
}

/* Dashboard Layout */
:root {
    --sidebar-width: 260px;
    --main-padding: 32px 48px;
}

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    width: var(--sidebar-width);
    height: 100vh;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
    z-index: 1000;
}

.dashboard-layout.sidebar-collapsed {
    --sidebar-width: 80px;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.dashboard-layout.sidebar-collapsed .sidebar-logo {
    opacity: 0;
    pointer-events: none;
    width: 0;
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.collapse-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-left: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.dashboard-layout.sidebar-collapsed .nav-section-title {
    opacity: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.dashboard-layout.sidebar-collapsed .nav-link {
    padding: 12px 0;
    justify-content: center;
}

.nav-link:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.nav-link span {
    transition: opacity 0.2s;
}

.dashboard-layout.sidebar-collapsed .nav-link span {
    display: none;
    opacity: 0;
}

.nav-link svg {
    width: 22px;
    height: 22px;
    min-width: 22px;
}

.sidebar-user {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.dashboard-layout.sidebar-collapsed .sidebar-user-info {
    justify-content: center;
}

.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-secondary);
    min-width: 40px;
}

.sidebar-user-details {
    transition: opacity 0.2s;
    overflow: hidden;
}

.dashboard-layout.sidebar-collapsed .sidebar-user-details {
    display: none;
    opacity: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--main-padding);
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
    /* Important for grid/flex items to not overflow */
}

/* RTL Support for Sidebar */
[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--border-color);
    left: auto;
    right: 0;
}

[dir="rtl"] .main-content {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

/* Hero Section */
.hero {
    padding: 100px 32px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero-content {
    position: relative;
    z-index: 10;
    max-width: 800px;
    margin: 0 auto;
}

.hero-title {
    font-size: clamp(2rem, 8vw, 3.5rem);
    margin-bottom: 24px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="light"] .hero-title {
    background: linear-gradient(135deg, #111827 0%, #4b5563 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.hero-float {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.2;
    animation: float 10s infinite ease-in-out;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(20px, -20px);
    }
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

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

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.badge-danger {
    background: rgba(244, 63, 94, 0.2);
    color: #fb7185;
}

/* Mobile Nav Toggle */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    background: var(--primary);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

[dir="rtl"] .mobile-nav-toggle {
    right: auto;
    left: 16px;
}

/* Media Queries */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 260px;
        --main-padding: 24px;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.3);
    }

    [dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 80px 24px 24px 24px !important;
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }

    .mobile-nav-toggle {
        display: flex;
    }

    .collapse-btn {
        display: none;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .course-grid {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 16px;
    }

    .main-content {
        padding: 80px 16px 24px 16px !important;
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: break-word;
    }

    /* Player Specific */
    .player-container {
        grid-template-columns: 1fr !important;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .btn {
        width: 100%;
    }

    .sidebar-logo {
        font-size: 1.25rem;
    }
}

/* Guest Nav & Responsive Content */
@media (max-width: 768px) {
    .guest-nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        padding: 20px;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    }

    .guest-nav-links.mobile-open {
        display: block;
    }

    .guest-links-inner {
        flex-direction: column;
        align-items: stretch !important;
        gap: 16px !important;
    }

    .guest-nav-container #guest-menu-btn {
        display: flex !important;
    }

    .main-responsive-container {
        padding: 0 16px;
    }

    .alert-container {
        padding: 0 !important;
    }
}

.main-responsive-container {
    width: 100%;
    margin: 0 auto;
}

/* Course Landing Page Styles */
.course-detail-hero {
    padding: 60px 0;
}

.course-hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 48px;
    align-items: start;
}

.course-visuals {
    position: relative;
    padding-bottom: 40px;
}

.featured-thumbnail {
    width: 100%;
    aspect-ratio: 16/9;
    border-radius: 40px;
    object-fit: cover;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
}

.instructor-avatar-overlap {
    position: absolute;
    bottom: 0;
    left: 40px;
    width: 100px;
    height: 100px;
    border-radius: 20px;
    border: 6px solid var(--bg-primary);
    object-fit: cover;
    z-index: 10;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.course-meta-info {
    padding: 24px 0;
}

.course-price-large {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 24px;
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.course-price-currency {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.meta-box-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 32px;
}

.meta-box {
    background: var(--bg-secondary);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.meta-box-icon {
    width: 40px;
    height: 40px;
    background: var(--bg-primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.meta-box-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.05em;
}

.meta-box-value {
    font-weight: 600;
    font-size: 1rem;
}

.course-specs-list {
    list-style: none;
    padding: 0;
    margin-bottom: 32px;
}

.course-spec-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    color: var(--text-secondary);
}

.course-spec-item svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.course-actions-group {
    display: flex;
    gap: 16px;
}

.course-content-sections {
    margin-top: 60px;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 48px;
}

.section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 12px;
    display: block;
}

.premium-description {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.outcomes-list {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.outcome-item {
    display: flex;
    gap: 12px;
    color: var(--text-secondary);
}

.outcome-item::before {
    content: "✓";
    color: var(--success);
    font-weight: 800;
}

/* RTL Specific Landing Page Adjustments */
[dir="rtl"] .meta-box-icon {
    margin-left: 0;
}

[dir="rtl"] .instructor-avatar-overlap {
    left: auto;
    right: 40px;
}

@media (max-width: 1024px) {
    .course-hero-grid {
        grid-template-columns: 1fr;
        gap: 32px;
    }

    .course-content-sections {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .course-detail-hero {
        padding: 40px 0;
    }

    .bundle-footer-responsive {
        flex-direction: column;
        align-items: stretch !important;
        gap: 20px;
        text-align: center;
    }

    .bundle-footer-responsive>div {
        text-align: center !important;
        justify-content: center !important;
    }

    .bundle-card-wide img {
        height: 150px !important;
    }

    .course-price-large {
        font-size: 2.5rem;
        justify-content: center;
    }

    .course-hero-grid {
        gap: 24px;
    }
}

@media (max-width: 480px) {
    .hero-title {
        font-size: 1.8rem !important;
    }

    .premium-description {
        font-size: 1rem;
        line-height: 1.6;
    }

    .container {
        padding: 0 16px;
    }
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-info {
    background-color: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.alert-danger {
    background-color: rgba(244, 63, 94, 0.1);
    border-color: rgba(244, 63, 94, 0.2);
    color: var(--accent);
}