/* ===================================================================
   s89.ir design tokens
   Light theme : white + purple + pink
   Dark theme  : black + lilac ("یاسی")
   =================================================================== */

:root,
[data-theme="light"] {
    --bg: #fbf6fd;
    --surface: #ffffff;
    --surface-2: #f6ecfa;
    --primary: #7c3aed;
    --primary-2: #a855f7;
    --pink: #ec4899;
    --text: #241536;
    --muted: #7c6a92;
    --border: #ecdcf6;
    --shadow: 0 10px 30px rgba(124, 58, 237, 0.10);
}

[data-theme="dark"] {
    --bg: #0b0710;
    --surface: #15101d;
    --surface-2: #1c1526;
    --primary: #c4b5fd;   /* lilac */
    --primary-2: #a78bfa;
    --pink: #d8b4fe;      /* light lilac-pink */
    --text: #f1e9fb;
    --muted: #a996c4;
    --border: #2a2135;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Vazirmatn", Tahoma, sans-serif;
    line-height: 1.7;
    transition: background-color .25s ease, color .25s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
}

a { color: inherit; text-decoration: none; }

/* ---------------- header ---------------- */

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    gap: 16px;
}

.brand {
    font-weight: 800;
    font-size: 1.4rem;
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.brand-mark {
    background: linear-gradient(90deg, var(--primary), var(--pink));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand-tag { color: var(--muted); font-size: 1rem; }

.main-nav { flex: 1; display: flex; justify-content: center; }

.nav-dropdown { position: relative; }

.nav-dropdown-btn {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text);
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 10px;
}

.nav-dropdown-btn:hover { background: var(--surface-2); }

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    min-width: 220px;
    padding: 8px;
    flex-direction: column;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: flex;
}

.nav-dropdown-menu a {
    padding: 10px 12px;
    border-radius: 10px;
    font-size: .95rem;
}

.nav-dropdown-menu a:hover { background: var(--surface-2); color: var(--primary); }

.theme-toggle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* ---------------- layout ---------------- */

.site-main { flex: 1; padding: 40px 0 80px; }

.site-footer {
    border-top: 1px solid var(--border);
    padding: 20px 0;
    color: var(--muted);
    font-size: .9rem;
    text-align: center;
}

.page-head { margin-bottom: 28px; }
.page-head h1 { margin: 0 0 6px; font-size: 1.8rem; }
.page-head p { color: var(--muted); margin: 0; }

/* ---------------- hero ---------------- */

.hero {
    text-align: center;
    padding: 60px 10px 50px;
    background:
        radial-gradient(circle at 20% 20%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 55%),
        radial-gradient(circle at 80% 30%, color-mix(in srgb, var(--pink) 18%, transparent), transparent 55%);
    border-radius: 28px;
    margin-bottom: 36px;
}

.eyebrow {
    display: inline-block;
    font-size: .85rem;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 16px;
    font-weight: 600;
}

.hero h1 { font-size: 2.4rem; margin: 0 0 14px; }
.hero-sub { color: var(--muted); max-width: 560px; margin: 0 auto; }

/* ---------------- tool cards ---------------- */

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px;
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 22px;
    display: block;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
    border-color: var(--primary);
}

.tool-card h3 { margin: 14px 0 6px; font-size: 1.05rem; }
.tool-card p { margin: 0; color: var(--muted); font-size: .9rem; }

.tool-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    font-size: 1.3rem;
}

.tool-icon::before { content: "✨"; filter: grayscale(0) brightness(3); }
.tool-icon[data-icon="link"]::before { content: "🔗"; }
.tool-icon[data-icon="qrcode"]::before { content: "▦"; }
.tool-icon[data-icon="scan"]::before { content: "🔍"; }
.tool-icon[data-icon="calculator"]::before { content: "🧮"; }
.tool-icon[data-icon="image"]::before { content: "🖼️"; }
.tool-icon[data-icon="compress"]::before { content: "📦"; }
.tool-icon[data-icon="palette"]::before { content: "🎨"; }

/* ---------------- cards / forms ---------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    margin-bottom: 20px;
}

.form-card { max-width: 560px; }

.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }

label { font-size: .9rem; color: var(--muted); font-weight: 600; }

input[type="text"],
input[type="url"],
input[type="number"],
input[type="file"],
textarea,
select {
    font-family: inherit;
    font-size: 1rem;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
}

input[type="color"] {
    width: 100%;
    height: 42px;
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

textarea { resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 22px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(90deg, var(--primary), var(--pink));
    color: #fff;
}

.btn-secondary {
    background: var(--surface-2);
    color: var(--primary);
    border: 1px solid var(--border);
    margin-top: 14px;
}

.btn-ghost {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
}

.btn-sm { padding: 6px 14px; font-size: .85rem; }

.messages { margin-bottom: 18px; }
.message {
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--primary);
    margin-bottom: 8px;
}

.empty-state { color: var(--muted); }

/* ---------------- tables ---------------- */

.table-wrap { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    text-align: right;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: .92rem;
}
.data-table th { color: var(--muted); font-weight: 600; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- stats ---------------- */

.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-card { flex: 1; min-width: 160px; text-align: center; }
.stat-value { display: block; font-size: 1.8rem; font-weight: 800; color: var(--primary); }
.stat-label { color: var(--muted); font-size: .85rem; }

/* ---------------- split layout (qr generator) ---------------- */

.split-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 760px) { .split-layout { grid-template-columns: 1fr; } }

.preview-card { text-align: center; }
.qr-preview, .img-preview {
    max-width: 100%;
    border-radius: 14px;
    border: 1px solid var(--border);
    margin-bottom: 4px;
}

.qr-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 8px;
    word-break: break-all;
}

.badge {
    background: var(--surface-2);
    color: var(--primary);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: .75rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---------------- color picker ---------------- */

.colorpicker-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.cp-main { position: relative; }
.cp-native-input { opacity: 0; position: absolute; inset: 0; width: 90px; height: 90px; cursor: pointer; border: none; }
.cp-swatch { width: 90px; height: 90px; border-radius: 20px; border: 1px solid var(--border); pointer-events: none; }
.cp-values { display: flex; gap: 14px; flex-wrap: wrap; flex: 1; }
.cp-field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.cp-field input { font-family: monospace; }

.cp-palette { display: flex; gap: 10px; flex-wrap: wrap; }
.cp-swatch-item {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    border: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 4px;
    font-size: .68rem;
    font-family: monospace;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

/* ---------------- balloon calculator (floating widget) ---------------- */

.balloon-calc { position: fixed; bottom: 22px; left: 22px; z-index: 100; }

.balloon-calc-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .2s ease;
}

.balloon-calc-toggle:hover { transform: scale(1.08) rotate(10deg); }

.balloon-calc-panel {
    position: absolute;
    bottom: 68px;
    left: 0;
    width: 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 14px;
}

.calc-page-wrap { display: flex; justify-content: center; }
.calc-standalone { width: 320px; position: static; }

.calc-screen {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    text-align: left;
    direction: ltr;
}
.calc-expression { color: var(--muted); font-size: .85rem; min-height: 1.1em; }
.calc-result { font-size: 1.6rem; font-weight: 700; direction: ltr; }

.calc-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.calc-key {
    padding: 12px 0;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
}
.calc-key:hover { border-color: var(--primary); }
.calc-key-op { color: var(--primary); font-weight: 700; }
.calc-key-fn { color: var(--pink); }
.calc-key-equals { background: linear-gradient(90deg, var(--primary), var(--pink)); color: #fff; grid-column: span 2; }
.calc-key-zero { grid-column: span 2; }
