@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;900&display=swap');

:root {
    --bg: #080b14;
    --bg2: #0d1120;
    --surface: #111827;
    --surface2: #1a2035;
    --surface3: #1e2640;
    --border: rgba(255,255,255,0.06);
    --border2: rgba(255,255,255,0.12);
    --accent: #818cf8;
    --accent2: #f472b6;
    --accent3: #34d399;
    --text: #e2e8f0;
    --text-muted: #64748b;
    --text-dim: #475569;
    --canvas-bg: #0f172a;
    --toolbar-bg: rgba(13,17,32,0.97);
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0,0,0,0.6);
    --glow: 0 0 20px rgba(129,140,248,0.15);
    --footer-h: 44px;
    --topbar-h: 52px;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    font-family: 'Tajawal', sans-serif;
    color: var(--text);
    direction: rtl;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ===== الكيرسور المخصص ===== */
#cursor-dot {
    position: fixed;
    top: 0; left: 0;
    width: 8px; height: 8px;
    background: white;
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 9999;
    mix-blend-mode: difference;
    transition: width 0.1s, height 0.1s;
}
#cursor-ring {
    position: fixed;
    top: 0; left: 0;
    width: 32px; height: 32px;
    border: 1.5px solid rgba(129,140,248,0.5);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 9998;
    transition: transform 0.08s ease, width 0.15s, height 0.15s, border-color 0.15s;
}

/* ===== الهيدر ===== */
#top-bar {
    width: 100%;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: 50;
}

.top-bar-inner {
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 8px rgba(129,140,248,0.5));
}

.logo-text {
    font-size: 1.1rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.session-info {
    flex: 1;
    display: flex;
    justify-content: center;
}

.session-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(129,140,248,0.08);
    border: 1px solid rgba(129,140,248,0.15);
    border-radius: 100px;
    padding: 4px 14px;
    font-size: 0.78rem;
}

.session-user {
    color: var(--accent);
    font-weight: 700;
}

.session-id {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 0.72rem;
}

.help-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--border2);
    border-radius: 100px;
    background: transparent;
    color: var(--text-muted);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}
.help-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(129,140,248,0.08);
}

/* ===== المحتوى الرئيسي ===== */
.main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    width: 100%;
    overflow: hidden;
    min-height: 0;
}

/* ===== الكانفاس ===== */
.canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
}

.canvas-wrap {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow), 0 0 0 1px var(--border), var(--glow);
    position: relative;
    flex-shrink: 0;
}

.canvas-wrap::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: calc(var(--radius) + 1px);
    background: linear-gradient(135deg, rgba(129,140,248,0.2), transparent, rgba(244,114,182,0.2));
    pointer-events: none;
    z-index: 1;
}

canvas {
    display: block;
    background: var(--canvas-bg);
    cursor: crosshair;
    position: relative;
    z-index: 0;
}

/* ===== شريط الأدوات ===== */
#toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
    padding: 10px 16px;
    background: var(--toolbar-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: calc(100vw - 20px);
    flex-shrink: 0;
}

.tool-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.tool-section-label {
    font-size: 0.6rem;
    color: var(--text-dim);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.tools-row {
    flex-direction: row;
    display: flex;
    gap: 4px;
}

/* ===== أنواع الفرشاة ===== */
.brush-types {
    display: flex;
    gap: 3px;
}

.brush-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.03);
    color: var(--text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.brush-btn:hover {
    background: rgba(129,140,248,0.15);
    border-color: rgba(129,140,248,0.4);
    color: var(--accent);
}
.brush-btn.active {
    background: rgba(129,140,248,0.2);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 0 10px rgba(129,140,248,0.3);
}

/* ===== اللون ===== */
.color-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

#color {
    width: 44px;
    height: 28px;
    border: 2px solid var(--border2);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    padding: 2px;
    transition: border-color 0.15s;
}
#color:hover { border-color: var(--accent); }
#color::-webkit-color-swatch-wrapper { padding: 0; }
#color::-webkit-color-swatch { border: none; border-radius: 4px; }

.quick-colors {
    display: flex;
    gap: 3px;
}

.qc {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1.5px solid rgba(255,255,255,0.1);
    background: var(--c);
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    flex-shrink: 0;
}
.qc:hover {
    transform: scale(1.2);
    border-color: white;
}

/* ===== السلايدرات ===== */
.slider-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

#bolder {
    width: 80px;
    accent-color: var(--accent);
    cursor: pointer;
    height: 4px;
}

#opacitySlider {
    width: 75px;
    accent-color: var(--accent2);
    cursor: pointer;
    height: 4px;
}

.opacity-slider {
    display: block;
}

.brush-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    transition: width 0.1s, height 0.1s;
    flex-shrink: 0;
}

/* ===== أزرار الأدوات ===== */
.tool-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.tool-btn:hover {
    background: rgba(129,140,248,0.15);
    border-color: rgba(129,140,248,0.4);
    transform: scale(1.08);
}
.tool-btn.active {
    background: rgba(129,140,248,0.25);
    border-color: var(--accent);
    box-shadow: 0 0 10px rgba(129,140,248,0.35);
}

/* ===== الفاصل ===== */
.sep {
    width: 1px;
    height: 36px;
    background: var(--border2);
    flex-shrink: 0;
}

/* ===== زر الإرسال ===== */
.send-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 100px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(129,140,248,0.3);
    letter-spacing: 0.2px;
}
.send-btn:hover {
    opacity: 0.9;
    transform: scale(1.04);
    box-shadow: 0 6px 20px rgba(129,140,248,0.45);
}

/* ===== الفوتر ===== */
#site-footer {
    height: var(--footer-h);
    width: 100%;
    background: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
}

.discord-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #5865F2;
    text-decoration: none;
    font-weight: 700;
    transition: color 0.15s;
    font-size: 0.85rem;
}
.discord-link:hover { color: #7289da; }

.footer-sep {
    color: var(--text-dim);
}

.footer-copy {
    color: var(--text-dim);
}

/* ===== المودالات - مشتركة ===== */
#modal-overlay, #help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 16px;
}
#modal-overlay.hidden, #help-overlay.hidden { display: none; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 900;
}

.modal-close-x {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border2);
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    font-family: sans-serif;
}
.modal-close-x:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text);
}

/* ===== مودال الإرسال ===== */
#modal {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 20px;
    padding: 24px;
    width: min(400px, calc(100vw - 32px));
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-preview {
    display: flex;
    justify-content: center;
}

#previewCanvas {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border2);
    background: var(--canvas-bg);
}

.switch-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.92rem;
    cursor: pointer;
    padding: 2px 0;
}

.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-sw {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.08);
    border-radius: 24px;
    transition: background 0.2s;
    cursor: pointer;
    border: 1px solid var(--border2);
}
.slider-sw::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    left: 2px; top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.switch input:checked + .slider-sw { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider-sw::before { transform: translateX(20px); }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 0.82rem; color: var(--text-muted); }
.field-group textarea {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--border2);
    border-radius: 10px;
    color: var(--text);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.92rem;
    padding: 10px 12px;
    resize: none;
    height: 70px;
    outline: none;
    transition: border-color 0.15s;
}
.field-group textarea:focus { border-color: var(--accent); }
.field-group textarea::placeholder { color: var(--text-dim); }

.char-count {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-align: left;
    direction: ltr;
}

.modal-btns {
    display: flex;
    gap: 10px;
}
.btn-cancel, .btn-send {
    flex: 1;
    padding: 11px;
    border: none;
    border-radius: 10px;
    font-family: 'Tajawal', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-cancel {
    background: rgba(255,255,255,0.05);
    color: var(--text);
    border: 1px solid var(--border2);
}
.btn-cancel:hover { background: rgba(255,255,255,0.1); }
.btn-send {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    box-shadow: 0 4px 12px rgba(129,140,248,0.25);
}
.btn-send:hover { opacity: 0.88; transform: scale(1.02); }

/* ===== مودال المساعدة ===== */
#help-modal {
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 20px;
    padding: 24px;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}

#help-modal::-webkit-scrollbar { width: 4px; }
#help-modal::-webkit-scrollbar-track { background: transparent; }
#help-modal::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.help-content {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.help-section h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.help-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}

.help-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    line-height: 1.4;
}

.help-item strong {
    font-size: 0.85rem;
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}

.help-item p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.help-tips {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.help-tips li {
    font-size: 0.88rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
}

.help-discord {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}

.discord-link-big {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #5865F2;
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(88,101,242,0.35);
}
.discord-link-big:hover {
    background: #4752c4;
    transform: scale(1.03);
}

/* ===== التوست ===== */
#toast {
    position: fixed;
    bottom: calc(var(--footer-h) + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 100px;
    padding: 10px 22px;
    font-size: 0.92rem;
    font-weight: 600;
    box-shadow: var(--shadow);
    z-index: 500;
    white-space: nowrap;
    animation: toastIn 0.2s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#toast.hidden { display: none; }
#toast.success { border-color: var(--accent3); color: var(--accent3); }
#toast.error { border-color: #f87171; color: #f87171; }

/* ===== سكرول بار عام ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
