/* Variables */
:root {
    --primary-color: #3b82f6; /* Blue */
    --primary-hover: #2563eb;
    --secondary-color: #fbd38d; /* Python yellow-ish */
    --bg-color: #f8fafc;
    --nav-bg: #ffffff;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --header-height: 70px;
    --editor-header: #e2e8f0;
    --editor-bg: #1e1e1e; /* VS Code dark */
    --transition: all 0.3s ease;
}

/* Dark Theme Variables */
body.dark-theme {
    --bg-color: #0f172a;
    --nav-bg: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: #1e293b;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3);
    --editor-header: #2d2d2d;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: var(--transition);
}

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

ul {
    list-style: none;
}

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

.highlight {
    color: var(--primary-color);
}

.section {
    padding: 40px 0;
}

/* Typography */
h1, h2, h3, h4 {
    margin-bottom: 0.5em;
    font-weight: 800;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background-color: rgba(var(--nav-bg), 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    transition: var(--transition);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-color);
}

.logo-img {
    height: 45px;
    width: auto;
    object-fit: contain;
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    font-size: 1.1rem;
    font-weight: 600;
    transition: var(--transition);
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary-color);
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

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

/* Hero Section */
.hero {
    margin-top: var(--header-height);
    padding: 45px 0 25px;
    display: flex;
    align-items: center;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
}

.hero-text h1 {
    font-size: 3rem;
    line-height: 1.2;
}

.hero-text p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.hero-brand-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-color);
    font-weight: 800;
    font-size: 1.25rem;
    padding: 0 4px;
}

.hero-brand-inline i {
    font-size: 1.35rem;
    color: var(--primary-color);
}

.hero-buttons {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background-color: #ef4444; /* YouTube Red */
    color: white;
}

.btn-primary:hover {
    background-color: #dc2626;
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Lessons Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
    gap: 20px;
}

.section-header h2 {
    font-size: 2.2rem;
    margin: 0;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    font-family: 'Cairo', sans-serif;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

/* Show More Lessons Button & Wide Downward Arrow */
.show-more-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 35px;
}

.show-more-wrapper.hidden {
    display: none;
}

.show-more-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 480px;
    padding: 16px 28px;
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--primary-color);
    border-radius: 14px;
    font-family: 'Cairo', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.show-more-btn:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    transform: translateY(3px);
}

.wide-arrow-down {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    animation: bounceArrowDown 1.6s infinite ease-in-out;
    transition: var(--transition);
}

.show-more-btn:hover .wide-arrow-down {
    color: #ffffff;
}

@keyframes bounceArrowDown {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(6px);
    }
}

.lesson-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.lesson-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.lesson-thumb {
    width: 100%;
    height: 180px;
    background-color: var(--editor-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 3rem;
    position: relative;
}

.lesson-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lesson-thumb .play-icon {
    position: absolute;
    background: rgba(0,0,0,0.6);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    color: white;
    transition: var(--transition);
}

.lesson-card:hover .play-icon {
    background: var(--primary-color);
    transform: scale(1.1);
}

.lesson-info {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.lesson-info h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.lesson-info p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 20px;
    flex-grow: 1;
}

.lesson-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.9rem;
}

/* Modal / Lesson Detail Viewer */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--bg-color);
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    border-radius: 12px;
    position: relative;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.15s ease;
}

@keyframes modalSlideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.modal-back-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--primary-color);
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    padding: 4px 8px;
    border-radius: 6px;
}

.modal-back-home-btn:hover {
    background-color: rgba(59, 130, 246, 0.1);
    transform: translateX(-4px);
}

.close-modal {
    position: static;
    color: var(--text-color);
    font-size: 28px;
    line-height: 1;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.close-modal:hover {
    color: #ef4444;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.modal-video {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-right: 10px;
}

.modal-video::-webkit-scrollbar {
    width: 8px;
}
.modal-video::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-video h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.modal-desc {
    margin-top: 20px;
    color: var(--text-muted);
}

.playlist-order-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    color: var(--primary-color);
    font-size: 0.95rem;
    font-weight: 600;
    transition: var(--transition);
}

.playlist-order-link i {
    color: #ef4444;
    font-size: 1.1rem;
}

.playlist-order-link:hover {
    text-decoration: underline;
    opacity: 0.9;
}

.code-column-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    overflow: hidden;
}

.code-section {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    background-color: var(--editor-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #333;
}

.infographic-download-btn {
    width: 100%;
    padding: 11px 18px;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: #ffffff;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    flex-shrink: 0;
}

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

.editor-header {
    background-color: var(--editor-header);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-color);
}

body.dark-theme .editor-header {
    color: #ccc;
}

.editor-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

.editor-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

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

.editor-body {
    flex-grow: 1;
    overflow: auto;
    padding: 15px;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.5;
    direction: ltr;
    text-align: left;
}

.editor-body::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.editor-body::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.editor-body::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
}

.editor-body::-webkit-scrollbar-thumb:hover {
    background: #4f4f4f;
}

/* Override Prism background to fit VS Code style */
pre[class*="language-"] {
    margin: 0;
    padding: 0;
    background: transparent !important;
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: embed;
}
code[class*="language-"] {
    color: #d4d4d4 !important; /* VS code text color */
    direction: ltr !important;
    text-align: left !important;
    unicode-bidi: embed;
}

/* Footer */
footer {
    background-color: rgba(0,0,0,0.02);
    border-top: 1px solid var(--border-color);
    padding: 60px 0 20px;
    margin-top: 60px;
}

body.dark-theme footer {
    background-color: var(--nav-bg);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-logo h3 {
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-logo p {
    color: var(--text-muted);
}

.social-links {
    display: flex;
    gap: 15px;
}

.social-links a {
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.social-links a:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-3px);
}

.copyright {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* Admin Mode Controls (Hidden for normal visitors, visible only when body.admin-mode is active) */
.hidden {
    display: none !important;
}

.admin-lock-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    opacity: 0.35;
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 6px;
    transition: var(--transition);
}

.admin-lock-btn:hover,
body.admin-mode .admin-lock-btn {
    opacity: 1;
    color: var(--primary-color);
}

.admin-only-btn,
.admin-infographic-bar {
    display: none;
}

body.admin-mode .admin-only-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 6px;
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    font-family: 'Cairo', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

body.admin-mode .admin-only-btn:hover {
    background-color: var(--primary-hover);
}

body.admin-mode .admin-save-btn {
    background-color: #10b981;
}

body.admin-mode .admin-save-btn:hover {
    background-color: #059669;
}

body.admin-mode .admin-format-btn {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
}

body.admin-mode .admin-format-btn:hover {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
}

.admin-code-textarea {
    width: 100%;
    height: 100%;
    min-height: 280px;
    background-color: transparent;
    color: #f8fafc;
    border: 1px dashed var(--primary-color);
    border-radius: 6px;
    padding: 12px;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    direction: ltr;
    text-align: left;
    resize: none;
    outline: none;
}

body.admin-mode .admin-infographic-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    flex-shrink: 0;
}

.admin-bar-btn {
    padding: 9px 12px;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition);
}

.admin-bar-btn.prompt-btn {
    background-color: var(--card-bg);
    color: var(--text-color);
    border-color: var(--primary-color);
}

.admin-bar-btn.prompt-btn:hover {
    background-color: var(--primary-color);
    color: #ffffff;
}

.admin-bar-btn.upload-btn {
    background-color: #10b981;
    color: #ffffff;
    border-color: #10b981;
}

.admin-bar-btn.upload-btn:hover {
    background-color: #059669;
}

.admin-modal-box {
    background-color: var(--card-bg);
    color: var(--text-color);
    width: 92%;
    max-width: 520px;
    border-radius: 12px;
    padding: 22px;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

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

.admin-modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.admin-status-toggle {
    margin-bottom: 16px;
    padding: 12px;
    background-color: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.admin-switch-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    cursor: pointer;
}

.admin-switch-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
}

.admin-token-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.admin-token-group label {
    font-size: 0.9rem;
    font-weight: 700;
}

.admin-token-group input {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Fira Code', monospace;
    direction: ltr;
    text-align: left;
}

.admin-token-group small {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.admin-modal-actions {
    display: flex;
    justify-content: flex-end;
}

/* Animations (Fast & Snappy) */
.fade-in {
    animation: fadeIn 0.2s ease both;
}

.fade-in-up {
    animation: fadeInUp 0.2s ease both;
}

.fade-in-left {
    animation: fadeInLeft 0.2s ease both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(20px); } /* RTL context, translates differently visually sometimes, but we keep it simple */
    to { opacity: 1; transform: translateX(0); }
}

/* Responsive */
@media (max-width: 992px) {
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-buttons {
        justify-content: center;
    }

    .modal-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .modal-video {
        max-height: 40vh;
    }
}

@media (max-width: 768px) {
    .nav-links {
        display: none; /* In a real project, we add a hamburger menu */
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .search-box {
        max-width: 100%;
    }
}
