/* Shared style of the website and the Telegram Mini App */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --text: #16202e;
  --muted: #5b6878;
  --border: #dde3ec;
  --primary: #1f6feb;
  --primary-hover: #1a5fd0;
  --primary-soft: #e3edff;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --telegram: #2aabee;
  --bubble: #ffffff;
  --chat-bg: #d9e7d2;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "Noto Sans Georgian", "Segoe UI", system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141c;
    --surface: #161e29;
    --surface-2: #1d2734;
    --text: #e7edf5;
    --muted: #9aa8b8;
    --border: #2a3646;
    --primary: #4c8dff;
    --primary-hover: #6a9fff;
    --primary-soft: #1b2d4d;
    --success: #34d399;
    --success-soft: #11372b;
    --warning: #fbbf24;
    --warning-soft: #3a2d0f;
    --danger: #f87171;
    --bubble: #1f2b38;
    --chat-bg: #17212b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.6rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.75rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }

.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 60px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 600; font-size: 0.95rem;
  padding: 10px 18px; min-height: 44px;
  background: var(--surface-2); color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { text-decoration: none; border-color: var(--border); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-telegram { background: var(--telegram); color: #fff; }
.btn-telegram:hover { background: color-mix(in srgb, var(--telegram) 88%, #000); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-small { min-height: 36px; padding: 6px 14px; font-size: 0.875rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--primary-soft); color: var(--text); border-radius: 999px;
  padding: 5px 6px 5px 12px; font-size: 0.875rem;
}
.chip .chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%; font-size: 1rem; line-height: 1; flex-shrink: 0;
}
.chip button:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--text); }
.chip-option { background: var(--surface-2); border: 1px solid var(--border); padding: 5px 12px; cursor: pointer; font: inherit; font-size: 0.875rem; }
.chip-option:hover { border-color: var(--primary); }

/* Forms */
input[type="text"], input[type="search"], input[type="number"] {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; min-height: 44px;
}
input::placeholder { color: var(--muted); }
label { cursor: pointer; }
.field-row { display: flex; gap: 10px; align-items: center; }
.field-row > * { flex: 1; }

/* Toggle switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; }
.switch + .switch { border-top: 1px solid var(--border); }
.switch input { appearance: none; width: 46px; height: 26px; border-radius: 999px; background: var(--border); position: relative; cursor: pointer; flex-shrink: 0; transition: background 0.15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.switch input:checked { background: var(--success); }
.switch input:checked::after { transform: translateX(20px); }

/* Notices */
.notice { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; border-radius: var(--radius); padding: 14px 16px; }
.notice-success { background: var(--success-soft); }
.notice-warning { background: var(--warning-soft); }

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 30; font-size: 0.95rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Telegram-like message preview */
.chat { background: var(--chat-bg); border-radius: var(--radius); padding: 18px; }
.bubble {
  background: var(--bubble); border-radius: 14px 14px 14px 4px; padding: 12px 14px; max-width: 460px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08); font-size: 0.9rem; line-height: 1.5;
}
.bubble p { margin: 0 0 0.6em; }
.bubble p:last-child { margin-bottom: 0; }
.bubble .files { margin-top: 8px; display: grid; gap: 6px; }
.bubble .file { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.bubble .file-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--telegram); color: #fff; display: grid; place-items: center; flex-shrink: 0; font-size: 0.95rem; }

/* Settings page: category tree */
.tree { border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 460px; overflow: auto; background: var(--surface); }
.tree:empty::after { content: "ვერაფერი მოიძებნა"; display: block; padding: 16px; color: var(--muted); }
.tree-row { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.tree-row:hover { background: var(--surface-2); }
.tree-toggle {
  width: 28px; height: 28px; flex-shrink: 0; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 0.8rem; transition: transform 0.15s;
}
.tree-toggle:hover { background: var(--border); }
.tree-toggle[aria-expanded="true"] { transform: rotate(90deg); }
.tree-spacer { width: 28px; flex-shrink: 0; }
.tree-row input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--primary); cursor: pointer; }
.tree-row input[type="checkbox"]:disabled { cursor: not-allowed; }
.tree-label { display: flex; gap: 8px; align-items: baseline; flex: 1; min-width: 0; }
.tree-code { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.tree-name { min-width: 0; }
.tree-path { display: block; color: var(--muted); font-size: 0.78rem; }
.tree-badge { font-size: 0.75rem; background: var(--primary-soft); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.tree-more { padding: 10px; color: var(--muted); font-size: 0.875rem; }

.presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip-option[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }

.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 16px; }
.types label { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.types input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }

.summary { font-size: 0.95rem; }
.summary .warn { color: var(--warning); font-weight: 600; }

.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.06);
}
.savebar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; padding-bottom: 12px; max-width: 760px; }
.has-savebar { padding-bottom: 96px; }
.page-narrow { max-width: 760px; }

.site-footer { border-top: 1px solid var(--border); padding: 28px 0 40px; margin-top: 56px; }

.show-mobile { display: none; }
@media (max-width: 520px) {
  .hide-mobile { display: none; }
  .show-mobile { display: inline; }
  .card { padding: 16px; }
  .tree-label { flex-direction: column; gap: 0; }
  .tree-row { gap: 6px; }
}
.site-footer .container { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
