@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;500;600;700;800;900&display=swap');

:root {
    --primary: hsl(210, 80%, 55%);
    --primary-glow: hsla(210, 80%, 55%, 0.3);
    --success: hsl(150, 80%, 45%);
    --success-glow: hsla(150, 80%, 45%, 0.3);
    --error: hsl(0, 80%, 60%);
    --error-glow: hsla(0, 80%, 60%, 0.3);
    --accent: hsl(38, 100%, 55%);
    --accent-glow: hsla(38, 100%, 55%, 0.3);
    --background: hsl(222, 47%, 11%);
    --card: hsla(222, 47%, 18%, 0.7);
    --card-border: hsla(0, 0%, 100%, 0.1);
    --text: hsl(0, 0%, 100%);
    --text-muted: hsl(215, 20%, 75%);

    --glass: blur(20px);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    --transition: 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--background);
    background-image:
        radial-gradient(at 0% 0%, hsla(210, 80%, 55%, 0.1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, hsla(150, 80%, 45%, 0.1) 0px, transparent 50%);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

#app {
    display: none;
    /* Hidden by default until login */
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

#app.active {
    display: grid;
}

/* Landing Page & Auth */
.landing-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-image:
        radial-gradient(circle at 10% 20%, hsla(210, 80%, 55%, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, hsla(150, 80%, 45%, 0.15) 0%, transparent 40%);
}

.hero-section {
    max-width: 1200px;
    text-align: center;
    margin-bottom: 4rem;
}

.hero-title {
    font-size: clamp(2.5rem, 8vw, 4.5rem);
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    background: linear-gradient(to bottom, #fff 30%, hsla(0, 0%, 100%, 0.5));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 700px;
    margin: 0 auto 2.5rem;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    padding: 3rem;
    background: hsla(222, 47%, 18%, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 32px;
    backdrop-filter: blur(40px);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.4);
    animation: authAppear 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes authAppear {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: var(--primary-glow);
    color: var(--primary);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.auth-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 16px;
}

.auth-tab {
    flex: 1;
    padding: 0.8rem;
    border-radius: 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 700;
    color: var(--text-muted);
}

.auth-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper i {
    position: absolute;
    right: 1.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
}

.auth-input {
    width: 100%;
    padding: 1.2rem 3.5rem 1.2rem 1.2rem;
    background: hsla(0, 0%, 0%, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    color: white;
    font-family: inherit;
    transition: var(--transition);
}

.auth-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 1200px;
    margin-top: 6rem;
    width: 100%;
}

.feat-item {
    padding: 2.5rem;
    border-radius: 24px;
    background: hsla(0, 0%, 100%, 0.03);
    border: 1px solid var(--card-border);
    text-align: center;
    transition: var(--transition);
}

.feat-item:hover {
    background: hsla(0, 0%, 100%, 0.07);
    transform: translateY(-10px);
}

.feat-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.5rem;
    color: var(--primary);
}

/* Sidebar */
.sidebar {
    background: var(--card);
    backdrop-filter: var(--glass);
    border-left: 1px solid var(--card-border);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 100;
}

/* Landing Page & Auth - Reorganized as a Full Website */
.landing-page {
    min-height: 100vh;
    background-color: var(--background);
    color: var(--text);
}

/* Landing Navbar */
.l-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(20px);
    z-index: 1000;
    border-bottom: 1px solid var(--card-border);
}

.l-nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
}

.l-nav-links {
    display: flex;
    gap: 2.5rem;
    list-style: none;
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
    }

    .nav-cta {
        display: none;
    }

    .l-nav-links {
        position: fixed;
        top: 70px;
        left: 0;
        width: 100%;
        height: 0;
        background: rgba(15, 23, 42, 0.98);
        flex-direction: column;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        transition: 0.5s ease;
        opacity: 0;
        pointer-events: none;
    }

    .l-nav-links.active {
        height: calc(100vh - 70px);
        opacity: 1;
        pointer-events: all;
    }
}

.l-nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.l-nav-links a:hover {
    color: var(--primary);
}

/* Main Website Sections */
.site-section {
    padding: 8rem 6% 4rem;
}

.hero-wrap {
    min-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4rem;
}

.hero-content {
    flex: 1;
}

.hero-auth {
    flex: 0 0 450px;
}

.hero-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 900;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: white;
}

.hero-title span {
    color: var(--primary);
    display: block;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    max-width: 600px;
}

/* Auth Card Tweak */
.auth-card {
    padding: 2.5rem;
    background: hsla(222, 47%, 18%, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    backdrop-filter: blur(40px);
    box-shadow: var(--shadow-lg);
}

/* Stats Section */
.stats-strip {
    background: hsla(210, 80%, 55%, 0.05);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    padding: 4rem 6%;
    text-align: center;
    border-top: 1px solid var(--card-border);
    border-bottom: 1px solid var(--card-border);
}

@media (max-width: 768px) {
    .stats-strip {
        grid-template-columns: repeat(2, 1fr);
        gap: 3rem 1rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }
}

.stat-box h4 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-box p {
    color: var(--text-muted);
    font-weight: 600;
}

/* Featured Section */
.section-title {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 3rem;
}

.platform-benefits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
    margin-top: 4rem;
}

.benefit-card {
    padding: 3rem;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    transition: var(--transition);
}

.benefit-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary);
}

.benefit-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-glow);
    color: var(--primary);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

/* Footer */
.site-footer {
    background: hsla(222, 47%, 12%, 1);
    padding: 6rem 6% 3rem;
    border-top: 1px solid var(--card-border);
    margin-top: 5rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1.5fr;
    gap: 4rem;
    margin-bottom: 4rem;
}

.footer-col h5 {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: white;
}

.footer-col ul {
    list-style: none;
}

.footer-col ul li {
    margin-bottom: 0.8rem;
}

.footer-col ul a {
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
}

.footer-col ul a:hover {
    color: var(--primary);
}

.copyright {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 0.9rem;
}

@media (max-width: 992px) {
    .hero-wrap {
        flex-direction: column;
        text-align: center;
        padding-top: 6rem;
    }

    .hero-auth {
        width: 100%;
        max-width: 450px;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Dashboard Mobile Sidebar */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 280px;
        transition: 0.4s ease;
    }

    .sidebar.mobile-active {
        left: 0;
    }

    #app {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 2rem;
    }

    .site-section {
        padding: 4rem 5%;
    }
}

/* App Header & Responsive Nav */
.app-header {
    display: none;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--card-border);
}

.sidebar-toggle {
    background: var(--card);
    border: 1px solid var(--card-border);
    color: white;
    padding: 0.7rem;
    border-radius: 12px;
    cursor: pointer;
}

.user-profile-mini {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

@media (max-width: 992px) {
    .app-header {
        display: flex;
    }
}

/* Material Management Page - Inline Editor */
.editor-section {
    margin-bottom: 4rem;
    border-bottom: 2px solid hsla(0, 0%, 100%, 0.05);
    padding-bottom: 3rem;
}

.editor-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.list-section {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

.material-card {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.material-card h3 {
    font-size: 1.4rem;
    color: var(--primary);
}

.material-card p {
    font-size: 1rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.8;
}

.material-actions {
    display: flex;
    gap: 0.8rem;
    margin-top: auto;
    border-top: 1px solid var(--card-border);
    padding-top: 1.5rem;
}

.action-btn {
    flex: 1;
    padding: 0.8rem 0.5rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: hsla(0, 0%, 100%, 0.05);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
}

.action-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-sm);
}

.action-btn.edit {
    background: hsla(210, 80%, 55%, 0.1);
    color: var(--primary);
    border-color: hsla(210, 80%, 55%, 0.3);
}

.action-btn.view {
    background: hsla(150, 80%, 45%, 0.1);
    color: var(--success);
    border-color: hsla(150, 80%, 45%, 0.3);
}

.action-btn.delete {
    background: hsla(0, 80%, 60%, 0.1);
    color: var(--error);
    border-color: hsla(0, 80%, 60%, 0.3);
}

.action-btn.edit:hover {
    background: var(--primary);
    color: white;
}

.action-btn.view:hover {
    background: var(--success);
    color: white;
}

.action-btn.delete:hover {
    background: var(--error);
    color: white;
}

/* Modal */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.overlay.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 700px;
    animation: modalIn 0.4s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Quiz UI */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
    margin-top: 2rem;
}

.option-btn {
    background: hsla(0, 0%, 100%, 0.05);
    border: 1px solid var(--card-border);
    padding: 1.5rem;
    border-radius: 18px;
    cursor: pointer;
    transition: var(--transition);
    text-align: right;
    color: var(--text);
    font-size: 1.1rem;
    position: relative;
}

.option-btn:hover {
    background: hsla(0, 0%, 100%, 0.1);
}

.option-btn.selected {
    border-color: var(--primary);
    background: hsla(210, 80%, 55%, 0.1);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

.option-btn.correct {
    border-color: var(--success) !important;
    background: hsla(150, 80%, 45%, 0.2) !important;
}

.option-btn.wrong {
    border-color: var(--error) !important;
    background: hsla(0, 80%, 60%, 0.2) !important;
}

/* Progress & Toast */
.progress-container {
    width: 100%;
    height: 8px;
    background: hsla(0, 0%, 100%, 0.05);
    border-radius: 4px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to left, var(--primary), var(--success));
    width: 0%;
    transition: width 0.5s ease;
}

#toast-container {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    padding: 1.2rem 2.5rem;
    border-radius: 16px;
    background: var(--card);
    backdrop-filter: var(--glass);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-lg);
    color: white;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideInLeft 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-right: 6px solid var(--success);
}

.toast.error {
    border-right: 6px solid var(--error);
}

/* Flashcards */
.flashcard-scene {
    width: 100%;
    height: 450px;
    perspective: 1500px;
}

.flashcard {
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
    cursor: pointer;
    position: relative;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem;
    border-radius: 32px;
    font-size: 2rem;
    font-weight: 700;
    box-shadow: var(--shadow-lg);
}

.flashcard-front {
    background: var(--card);
    border: 1px solid var(--card-border);
}

.flashcard-back {
    background: linear-gradient(135deg, hsla(210, 80%, 55%, 0.2), hsla(150, 80%, 45%, 0.2));
    border: 2px solid var(--primary);
    transform: rotateY(180deg);
    color: var(--text);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn {
    padding: 1rem 2rem;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 20px var(--primary-glow);
}

.btn-primary:hover {
    background: hsl(210, 80%, 65%);
    transform: translateY(-2px);
    box-shadow: 0 15px 30px var(--primary-glow);
}

/* Custom Inputs */
.title-input,
.material-input {
    width: 100%;
    background: hsla(0, 0%, 0%, 0.3);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.2rem;
    color: white;
    font-family: inherit;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}

.title-input:focus,
.material-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: hsla(0, 0%, 100%, 0.1);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsla(0, 0%, 100%, 0.2);
}