:root {
    --primary: #3b82f6;
    --gradient: linear-gradient(135deg, #0ea5e9, #6366f1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

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

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(2, 6, 23, 0.5);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.5);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 165, 233, 0.8);
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl; 
    background: linear-gradient(-45deg, #0f172a, #1e1b4b, #172554, #020617);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.glass-container {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 2.5rem;
    width: 100%;
    max-width: 1200px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

header {
    text-align: center;
    margin-bottom: 2.5rem;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    letter-spacing: 0px; 
}

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0px 4px 20px rgba(14, 165, 233, 0.3);
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    height: 65vh;
    min-height: 450px;
}

.panel {
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
}

.panel-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-weight: 600;
    font-size: 1.1rem;
}

.run-btn {
    background: var(--gradient);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    color: white;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.run-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(14, 165, 233, 0.6);
}

.run-btn:active {
    transform: translateY(1px);
}

.clear-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.4rem 1rem;
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

textarea {
    flex: 1;
    background: rgba(2, 6, 23, 0.5);
    color: #e2e8f0;
    padding: 1.5rem;
    border: 1px solid transparent;
    resize: none;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 1.1rem;
    line-height: 1.7;
    outline: none;
    direction: rtl;
    text-align: right; 
    transition: all 0.3s ease;
}

textarea:focus {
    background: rgba(2, 6, 23, 0.8);
    box-shadow: inset 0 0 20px rgba(14, 165, 233, 0.05);
}

textarea::placeholder {
    color: #475569;
}

pre {
    flex: 1;
    background: rgba(0, 0, 0, 0.7);
    padding: 1.5rem;
    margin: 0;
    overflow-y: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 1.1rem;
    color: #34d399; /* Emerald */
    line-height: 1.7;
    white-space: pre-wrap;
    direction: rtl; 
    text-align: right; 
}

.error-text {
    color: #ef4444 !important;
}

/* Spinner Animation */
.spinner {
    animation: rotate 2s linear infinite;
}
.spinner .path {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: dash 1.5s ease-in-out infinite;
}
@keyframes rotate { 100% { transform: rotate(360deg); } }
@keyframes dash {
    0% { stroke-dasharray: 1, 150; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 150; stroke-dashoffset: -35; }
    100% { stroke-dasharray: 90, 150; stroke-dashoffset: -124; }
}

@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    textarea, pre {
        height: 350px;
    }
    .glass-container {
        padding: 1.5rem;
    }
}
