/* Ultra-Premium SaaS CSS - Educreate */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;800&family=Outfit:wght@300;400;500;700;900&display=swap');

:root {
    /* Deep Space Palette */
    --bg-space: #05050a;
    --bg-surface: rgba(15, 15, 20, 0.6);
    --bg-surface-light: rgba(25, 25, 35, 0.8);
    
    /* Neon Accents */
    --neon-blue: #00f0ff;
    --neon-purple: #8a2be2;
    --neon-pink: #ff00c8;
    
    /* Text */
    --text-pure: #ffffff;
    --text-bright: #f8fafc;
    --text-muted: #94a3b8;
    --text-dark: #1e293b;
    
    /* System */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #f43f5e;
    
    /* Effects */
    --glass-blur: blur(24px);
    --glass-border: 1px solid rgba(255, 255, 255, 0.08);
    --neon-glow: 0 0 20px rgba(0, 240, 255, 0.3), 0 0 40px rgba(138, 43, 226, 0.2);
    
    /* Geometry */
    --radius-xl: 32px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    
    /* Animation */
    --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-space);
    color: var(--text-bright);
    min-height: 100vh;
    overflow-x: hidden;
    /* Animated Gradient Background */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(138, 43, 226, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(0, 240, 255, 0.15), transparent 25%);
    background-attachment: fixed;
}

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

/* Grid Layout */
.app-wrapper {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
}

/* -------------------
   Sidebar (Glass)
   ------------------- */
.sidebar {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: var(--glass-border);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

[dir="rtl"] .sidebar {
    border-right: none;
    border-left: var(--glass-border);
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    margin-bottom: 3rem;
    cursor: pointer;
    transition: transform 0.3s var(--ease-spring);
}
.brand:hover { transform: scale(1.02); }

.brand-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--neon-blue), var(--neon-purple));
    border-radius: 14px;
    display: grid;
    place-items: center;
    box-shadow: var(--neon-glow);
    position: relative;
}
.brand-icon::before {
    content: '';
    position: absolute;
    inset: 2px;
    background: var(--bg-space);
    border-radius: 12px;
    z-index: 1;
}
.brand-icon svg {
    position: relative;
    z-index: 2;
    color: var(--text-pure);
    width: 24px;
    height: 24px;
}

.brand h1 {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(to right, #fff, var(--neon-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

/* History List */
.history-container {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
}
.history-container::-webkit-scrollbar { display: none; } /* Chrome */

.section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 700;
}

.history-item {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.3s var(--ease-smooth);
    position: relative;
    overflow: hidden;
}

.history-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0; width: 3px;
    background: linear-gradient(to bottom, var(--neon-blue), var(--neon-purple));
    transform: scaleY(0);
    transition: transform 0.3s var(--ease-spring);
    transform-origin: center;
}

.history-item:hover, .history-item.active {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}
[dir="rtl"] .history-item:hover, [dir="rtl"] .history-item.active {
    transform: translateX(-5px);
}

.history-item:hover::before, .history-item.active::before {
    transform: scaleY(1);
}

.history-item h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item p {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* User Status */
.user-status {
    margin-top: 2rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-lg);
    border: var(--glass-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 10px var(--warning);
}
.status-dot.connected { background: var(--success); box-shadow: 0 0 10px var(--success); }

/* -------------------
   Main Workspace
   ------------------- */
.workspace {
    padding: 3rem 4rem;
    height: 100vh;
    overflow-y: auto;
    position: relative;
    scroll-behavior: smooth;
}

/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.title-area h2 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}
.title-area p { color: var(--text-muted); font-size: 1.1rem; }

.theme-selector {
    background: var(--bg-surface);
    border: var(--glass-border);
    color: var(--text-bright);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    backdrop-filter: var(--glass-blur);
    transition: all 0.3s ease;
}
.theme-selector:hover { border-color: var(--neon-purple); }
.theme-selector option { background: var(--bg-space); color: var(--text-bright); }

/* Input Cards (Glass Panel) */
.glass-card {
    background: linear-gradient(145deg, rgba(25, 25, 35, 0.6), rgba(15, 15, 20, 0.4));
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-xl);
    padding: 3rem;
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.7);
    margin-bottom: 3rem;
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-group.full-width { grid-column: 1 / -1; }

.input-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modern-input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-pure);
    padding: 1.2rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1.05rem;
    transition: all 0.3s var(--ease-smooth);
    width: 100%;
}

textarea.modern-input { min-height: 120px; resize: vertical; line-height: 1.6; }

.modern-input:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.5);
    border-color: var(--neon-blue);
    box-shadow: 0 0 0 4px rgba(0, 240, 255, 0.1);
}

/* Magic Button */
.btn-magic {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-blue));
    color: var(--text-pure);
    border: none;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s var(--ease-spring), box-shadow 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(138, 43, 226, 0.4);
}

.btn-magic::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 60%);
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.3s, transform 0.5s;
}

.btn-magic:hover {
    transform: translateY(-3px) scale(1.01);
    box-shadow: 0 15px 40px rgba(0, 240, 255, 0.5);
}

.btn-magic:hover::after {
    opacity: 1;
    transform: scale(1);
}

.btn-magic:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* -------------------
   Output & Editor
   ------------------- */
.output-wrapper {
    display: none;
    animation: fadeIn 0.8s var(--ease-smooth) forwards;
}
.output-wrapper.visible { display: block; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.save-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
}
.save-indicator.show { opacity: 1; }

.action-buttons { display: flex; gap: 0.75rem; }

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    border: var(--glass-border);
    color: var(--text-bright);
    padding: 0.75rem 1.25rem;
    border-radius: 20px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn-action:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--text-bright); }
.btn-action.primary { background: var(--success); border-color: var(--success); color: #fff;}

/* Editor Surface */
.editor-container {
    background: var(--bg-surface-light);
    border-radius: var(--radius-xl);
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-height: 500px;
    padding: 4rem;
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5);
    position: relative;
    transition: all 0.5s ease;
}

.content-editable {
    outline: none;
    line-height: 1.9;
    font-size: 1.15rem;
    color: var(--text-bright);
    position: relative;
    z-index: 2;
}

/* Typing Effect Cursors */
.typing-cursor::after {
    content: '|';
    animation: blink 1s step-end infinite;
    color: var(--neon-blue);
    font-weight: bold;
}

/* Editor Typography Styles */
.content-editable h1 { font-size: 3rem; margin-bottom: 2rem; color: var(--neon-blue); font-weight: 900; letter-spacing: -0.02em;}
.content-editable h2 { font-size: 2rem; margin: 3rem 0 1.5rem; color: var(--neon-purple); font-weight: 800;}
.content-editable h3 { font-size: 1.5rem; margin: 2rem 0 1rem; color: var(--text-bright); }
.content-editable p { margin-bottom: 1.5rem; color: #cbd5e1; }
.content-editable ul, .content-editable ol { margin-bottom: 2rem; padding-inline-start: 2rem; color: #cbd5e1;}
.content-editable li { margin-bottom: 0.75rem; }
.content-editable strong { color: var(--text-pure); font-weight: 700; background: rgba(255,255,255,0.1); padding: 0 4px; border-radius: 4px;}

.generated-image-wrapper {
    margin: 3rem 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.1);
}
.generated-image-wrapper img {
    width: 100%;
    display: block;
    transition: transform 0.5s ease;
}
.generated-image-wrapper:hover img { transform: scale(1.03); }

/* -------------------
   Themes
   ------------------- */
.theme-academic .editor-container { background: #ffffff; box-shadow: 0 10px 30px rgba(0,0,0,0.05); border-color: #e2e8f0; }
.theme-academic .content-editable { color: #0f172a; font-family: 'Georgia', serif; }
.theme-academic .content-editable h1, .theme-academic .content-editable h2 { color: #1e293b; }
.theme-academic .content-editable p { color: #334155; }
.theme-academic .content-editable strong { background: #f1f5f9; color: #000; }

.theme-minimal .editor-container { background: #fafaf9; border: none; box-shadow: none; padding: 2rem 0; }
.theme-minimal .content-editable { color: #292524; }
.theme-minimal .content-editable h1, .theme-minimal .content-editable h2 { color: #1c1917; }
.theme-minimal .content-editable p { color: #44403c; }
.theme-minimal .generated-image-wrapper { box-shadow: none; border-radius: 0; }

/* -------------------
   Mesmerizing Loader
   ------------------- */
.ai-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 0;
    gap: 2rem;
}

.orb-container {
    position: relative;
    width: 100px;
    height: 100px;
}

.orb {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--neon-blue), var(--neon-purple), var(--neon-pink), var(--neon-blue));
    animation: rotate 2s linear infinite;
    filter: blur(10px);
}
.orb-core {
    position: absolute;
    inset: 10px;
    background: var(--bg-space);
    border-radius: 50%;
    z-index: 2;
}

.ai-loader p {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-bright);
    animation: pulseText 1.5s ease-in-out infinite;
}

/* -------------------
   Premium Toasts
   ------------------- */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem; /* LTR default */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 9999;
}
[dir="rtl"] .toast-container { right: auto; left: 2rem; }

.toast {
    background: var(--bg-surface-light);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(100%);
    opacity: 0;
    animation: slideInToast 0.4s var(--ease-spring) forwards;
}
[dir="rtl"] .toast { transform: translateX(-100%); }

.toast.hiding { animation: slideOutToast 0.3s ease-in forwards; }

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
[dir="rtl"] .toast-success { border-left: none; border-right: 4px solid var(--success); }
[dir="rtl"] .toast-error { border-left: none; border-right: 4px solid var(--danger); }

/* Animations */
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes pulseText { 50% { opacity: 0.5; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInToast { to { transform: translateX(0); opacity: 1; } }
@keyframes slideOutToast { to { transform: translateX(100%); opacity: 0; } }
[dir="rtl"] @keyframes slideOutToast { to { transform: translateX(-100%); opacity: 0; } }

/* Print Media */
@media print {
    body { background: white !important; color: black !important; }
    .sidebar, .top-bar, .glass-card, .toolbar { display: none !important; }
    .workspace { padding: 0 !important; margin: 0 !important; height: auto !important; overflow: visible !important; }
    .editor-container { border: none !important; box-shadow: none !important; padding: 0 !important; }
    .generated-image-wrapper { break-inside: avoid; box-shadow: none !important; border: none !important; }
}

/* Responsive */
@media (max-width: 1024px) {
    .app-wrapper { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .workspace { padding: 2rem; }
    .input-grid { grid-template-columns: 1fr; }
    .editor-container { padding: 2rem; }
}
