@font-face {
    font-family: VazirmatnLocal;
    src: local("Vazirmatn"), local("Vazir"), local("Tahoma");
}

:root {
    --bg: #f4f7fb;
    --panel: rgba(255, 255, 255, .86);
    --panel-solid: #ffffff;
    --text: #101828;
    --muted: #667085;
    --border: rgba(16, 24, 40, .10);
    --primary: #6957ff;
    --primary-dark: #5746ee;
    --secondary: #0ea5e9;
    --danger: #ef4444;
    --success: #10b981;
    --shadow: 0 24px 70px rgba(31, 41, 55, .12);
    --radius: 26px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: VazirmatnLocal, Tahoma, Arial, sans-serif;
    background:
        radial-gradient(circle at 20% 10%, rgba(105, 87, 255, .18), transparent 32%),
        radial-gradient(circle at 80% 30%, rgba(14, 165, 233, .18), transparent 34%),
        linear-gradient(135deg, #f7f8ff 0%, #eef6ff 100%);
    color: var(--text);
    min-height: 100vh;
}

button, input, textarea, select { font-family: inherit; }
button { cursor: pointer; }

.app-shell {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 22px;
    padding: 22px;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 22px;
    height: calc(100vh - 44px);
    background: rgba(15, 23, 42, .94);
    color: #fff;
    border-radius: 32px;
    padding: 22px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 900;
    background: linear-gradient(145deg, var(--primary), var(--secondary));
    box-shadow: 0 18px 45px rgba(105, 87, 255, .35);
}

.brand strong { display: block; font-size: 17px; }
.brand span { display: block; color: rgba(255, 255, 255, .7); font-size: 12px; margin-top: 4px; }

.nav { display: grid; gap: 10px; margin-top: 24px; }
.nav a {
    color: rgba(255, 255, 255, .78);
    text-decoration: none;
    padding: 13px 15px;
    border-radius: 18px;
    transition: .2s ease;
}
.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.sidebar-card {
    margin-top: auto;
    background: linear-gradient(145deg, rgba(105, 87, 255, .95), rgba(14, 165, 233, .88));
    border-radius: 24px;
    padding: 18px;
}
.sidebar-card small,
.sidebar-card span { display: block; color: rgba(255, 255, 255, .76); }
.sidebar-card strong { display: block; font-size: 25px; margin: 8px 0; }

.main { min-width: 0; }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 32px;
    box-shadow: var(--shadow);
    padding: 24px;
    backdrop-filter: blur(18px);
}
.topbar h1 { margin: 0; font-size: clamp(22px, 2vw, 32px); }
.topbar p { margin: 8px 0 0; color: var(--muted); line-height: 1.9; }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
    border: 0;
    border-radius: 16px;
    padding: 13px 18px;
    font-size: 14px;
    font-weight: 800;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--primary); color: #fff; box-shadow: 0 16px 34px rgba(105,87,255,.28); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #111827; color: #fff; }
.btn.ghost { background: rgba(16, 24, 40, .06); color: var(--text); }
.btn.full { width: 100%; margin-top: 12px; }

.grid-layout {
    display: grid;
    grid-template-columns: 390px 1fr;
    gap: 22px;
    margin-top: 22px;
}
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
    margin-top: 22px;
}
.panel {
    background: var(--panel);
    border: 1px solid rgba(255,255,255,.75);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    backdrop-filter: blur(18px);
}

.panel-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 18px;
}
.panel-title.compact { margin-top: 4px; }
.panel-title h2 { margin: 0; font-size: 18px; }
.panel-title span { color: var(--muted); font-size: 12px; line-height: 1.8; }
.preview-title { align-items: center; }

.product-list { display: grid; gap: 10px; }
.product-card {
    width: 100%;
    text-align: right;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .75);
    border-radius: 20px;
    padding: 14px;
    display: grid;
    gap: 5px;
    transition: .2s ease;
}
.product-card strong { font-size: 15px; }
.product-card span { color: var(--muted); line-height: 1.6; font-size: 12px; }
.product-card small { color: var(--primary); font-weight: 900; }
.product-card:hover,
.product-card.active {
    border-color: rgba(105, 87, 255, .55);
    background: rgba(105, 87, 255, .08);
}

.divider { height: 1px; background: var(--border); margin: 22px 0; }
.input-label, label { display: block; color: #344054; font-size: 13px; font-weight: 800; margin-bottom: 8px; }
input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px 13px;
    background: rgba(255, 255, 255, .88);
    color: var(--text);
    outline: none;
    transition: .2s ease;
    margin-top: 7px;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(105,87,255,.10); }
textarea { resize: vertical; min-height: 82px; }
.file-input { padding: 11px; }
.hint { color: var(--muted); display: block; margin: 6px 0 14px; line-height: 1.7; }
.color-row { display: grid; grid-template-columns: 56px 1fr; gap: 10px; margin-bottom: 14px; }
.color-row input[type="color"] { padding: 4px; height: 48px; }
.two-col, .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.toolbar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 14px; }
.mini-btn {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 13px;
    padding: 10px 7px;
    font-weight: 800;
    font-size: 12px;
}
.mini-btn.danger { color: var(--danger); }

.view-badges { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.view-badges span {
    background: rgba(105, 87, 255, .10);
    color: var(--primary-dark);
    border: 1px solid rgba(105, 87, 255, .16);
    border-radius: 999px;
    padding: 8px 11px;
    font-size: 12px;
    font-weight: 900;
}
.canvas-wrap {
    background:
        linear-gradient(45deg, rgba(15,23,42,.04) 25%, transparent 25%, transparent 75%, rgba(15,23,42,.04) 75%),
        linear-gradient(45deg, rgba(15,23,42,.04) 25%, transparent 25%, transparent 75%, rgba(15,23,42,.04) 75%);
    background-position: 0 0, 12px 12px;
    background-size: 24px 24px;
    border-radius: 24px;
    border: 1px dashed rgba(16,24,40,.18);
    overflow: hidden;
    display: grid;
    place-items: center;
    min-height: 520px;
}
canvas {
    max-width: 100%;
    height: auto;
    display: block;
    touch-action: none;
}
.preview-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-top: 16px;
    color: var(--muted);
    line-height: 1.8;
}
.preview-footer strong { color: var(--text); }
.result-panel { margin-top: 22px; }
.save-result {
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px;
    background: rgba(255,255,255,.7);
    line-height: 2;
}
.save-result.empty { color: var(--muted); }
.save-result.success { border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.08); }
.save-result.error { border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.08); color: #991b1b; }
.save-result a { color: var(--primary-dark); font-weight: 900; text-decoration: none; }

@media (max-width: 1200px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .nav { grid-template-columns: repeat(4, 1fr); }
    .grid-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { padding: 12px; gap: 12px; }
    .topbar, .preview-footer, .panel-title { flex-direction: column; align-items: stretch; }
    .bottom-grid, .two-col, .form-grid { grid-template-columns: 1fr; }
    .nav { grid-template-columns: 1fr 1fr; }
    .toolbar { grid-template-columns: 1fr 1fr; }
    .panel, .topbar, .sidebar { border-radius: 22px; padding: 16px; }
    .canvas-wrap { min-height: 360px; }
}
