:root {
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.4);
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.4);
    --bg-dark: #0f172a;
    --sidebar-dark: #1e293b;
    --text-dark: #f8fafc;
    --border-dark: rgba(255, 255, 255, 0.08);
    --bg-light: #f1f5f9;
    --sidebar-light: #ffffff;
    --text-light: #1e293b;
    --border-light: rgba(0, 0, 0, 0.08);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Light Mode Overrides */
body.light-mode {
    --bg-dark: var(--bg-light);
    --sidebar-dark: var(--sidebar-light);
    --text-dark: var(--text-light);
    --border-dark: var(--border-light);
}

* {
    margin: 0; padding: 0; box-sizing: border-box;
    font-family: 'Noto Sans Arabic', 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-dark);
    overflow: hidden; 
    transition: background-color 0.5s ease, color 0.5s ease;
}

.main-wrapper {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Preview Stage (Main Canvas Area) */
.preview-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    position: relative;
    background-image: radial-gradient(circle at center, rgba(255,255,255,0.03) 0%, transparent 70%);
}

.canvas-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border-radius: 15px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: crosshair;
    transition: opacity 0.3s ease;
    outline: 2px dashed var(--primary);
    outline-offset: -2px; 
}

.empty-msg {
    position: absolute;
    text-align: center;
    color: var(--text-dark);
    opacity: 0.6;
    padding: 20px;
}

.empty-msg .animated-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    animation: float 3s ease-in-out infinite;
}

.drag-hint {
    position: absolute;
    bottom: 20px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
    backdrop-filter: blur(5px);
}

.canvas-container:hover .drag-hint { opacity: 1; }

/* Sidebar Styling */
.sidebar {
    width: 400px;
    background: var(--sidebar-dark);
    border-left: 1px solid var(--border-dark);
    display: flex;
    flex-direction: column;
    padding: 25px;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    z-index: 10;
    transition: background-color 0.5s ease;
}

.scroll-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 15px;
}

.scroll-content::-webkit-scrollbar { width: 6px; }
.scroll-content::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 10px; }

.logo-area {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-dark);
}

.icon-box {
    width: 40px; height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.1rem;
}

.logo-area h2 { font-size: 1.5rem; font-weight: 800; }
.logo-area span { color: var(--primary); }

.config-section {
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.02);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-dark);
}

.config-section label {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.85rem; font-weight: 600; text-transform: uppercase;
    margin-bottom: 12px; opacity: 0.9;
}

/* Color Picker & Text Inputs */
.color-control {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-input {
    -webkit-appearance: none;
    width: 45px;
    height: 35px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: transparent;
}

.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 2px solid var(--border-dark); border-radius: 8px; }

.color-hint { font-size: 0.75rem; color: var(--text-dark); opacity: 0.6; }

/* New Text Controls */
.text-input, .modern-select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-dark);
    background: rgba(0,0,0,0.1);
    color: var(--text-dark);
    font-size: 0.9rem;
    transition: var(--transition);
}

.text-input { margin-bottom: 10px; }
.modern-select { cursor: pointer; appearance: none; }
.modern-select option, .modern-select optgroup { background: var(--sidebar-dark); color: var(--text-dark); }
.text-input:focus, .modern-select:focus { outline: none; border-color: var(--primary); }

.style-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.action-btn {
    width: 100%; padding: 14px;
    border: none; border-radius: 10px;
    cursor: pointer; font-weight: 600; font-size: 0.95rem;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    transition: var(--transition);
}

.action-btn.secondary { background: rgba(99, 102, 241, 0.1); color: var(--primary); border: 1px dashed var(--primary); }
.action-btn.secondary:hover { background: var(--primary); color: white; }

.action-btn.primary { background: var(--primary); color: white; margin-bottom: 10px;}
.action-btn.primary:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(1); box-shadow: none !important; }
.action-btn.primary.glow:not(:disabled):hover { box-shadow: 0 0 20px var(--primary-glow); transform: translateY(-2px); }

.action-btn.danger-btn { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.action-btn.danger-btn:hover { background: var(--danger); color: white; transform: translateY(-2px); box-shadow: 0 8px 20px var(--danger-glow); }

/* Sliders */
.range-container { display: flex; align-items: center; gap: 15px; }
.modern-slider { -webkit-appearance: none; flex: 1; height: 6px; background: var(--border-dark); border-radius: 5px; outline: none; }
.modern-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--primary); cursor: pointer; box-shadow: 0 0 10px rgba(0,0,0,0.3); }
.badge { background: var(--primary); color: white; padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; min-width: 55px; text-align: center; }

/* Formats */
.format-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.format-chip { padding: 12px 5px; background: transparent; border: 1px solid var(--border-dark); color: var(--text-dark); border-radius: 8px; cursor: pointer; font-size: 0.85rem; font-weight: 600; transition: var(--transition); }
.format-chip.active { background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 4px 15px var(--primary-glow); }

/* Theme Toggle */
.theme-switch-btn {
    position: fixed; bottom: 20px; left: 20px;
    width: 50px; height: 50px;
    border-radius: 50%; border: 1px solid var(--border-dark);
    background: var(--sidebar-dark); color: var(--text-dark);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    cursor: pointer; z-index: 100; font-size: 1.2rem;
    transition: var(--transition);
}

/* Animations */
@keyframes float { 0% { transform: translateY(0px); } 50% { transform: translateY(-10px); } 100% { transform: translateY(0px); } }
.fade-in { opacity: 0; animation: fadeIn 0.5s ease forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   Mobile Optimization 
   ========================================================= */
@media screen and (max-width: 1024px) {
    body { 
        overflow-y: auto !important;
        overflow-x: hidden; 
    }
    
    .main-wrapper {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        display: flex;
    }

    .preview-stage {
        flex: none;
        height: 40vh; 
        min-height: 250px; 
        padding: 15px;
        position: relative;
        display: flex;
    }

    .canvas-container {
        width: 100%;
        height: 100%;
    }

    .sidebar {
        width: 100%;
        flex: 1; 
        border-left: none;
        border-top: 1px solid var(--border-dark);
        padding: 20px 15px;
        box-shadow: none;
    }

    .scroll-content {
        overflow-y: visible; 
    }

    .theme-switch-btn {
        bottom: auto;
        top: 15px;
        left: 15px;
        width: 45px; height: 45px;
        font-size: 1rem;
    }
    
    .drag-hint {
        opacity: 1;
        bottom: 10px;
        font-size: 0.75rem;
    }
}