/* ============================================================
   ОшКызмат — единый портал приёма электронных заявок (г. Ош)
   Разработчик: Абдыкадырова Айзат Мамасалиевна
   ============================================================ */

:root {
  --brand: #6366f1;
  --brand-2: #0ea5e9;
  --brand-grad: linear-gradient(135deg, #6366f1 0%, #0ea5e9 100%);
  --radius: 16px;
  --radius-sm: 11px;
  --sidebar-w: 264px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .06), 0 6px 18px rgba(15, 23, 42, .06);
  --shadow-2: 0 10px 40px rgba(15, 23, 42, .12);
}

/* --- Тёмная тема (по умолчанию) --- */
[data-bs-theme="dark"] {
  --bg: #0b1120;
  --surface: #131c31;
  --surface-2: #1b2740;
  --border: #243049;
  --text: #e6edf7;
  --muted: #9aa7bd;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  --shadow-2: 0 18px 50px rgba(0, 0, 0, .45);
}

/* --- Светлая тема --- */
[data-bs-theme="light"] {
  --bg: #eef2f9;
  --surface: #ffffff;
  --surface-2: #f5f8fe;
  --border: #e2e8f3;
  --text: #16203a;
  --muted: #5b6b86;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
}

* { scrollbar-width: thin; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: -.01em;
}
a { text-decoration: none; }

.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-grad); color: #fff; font-size: 1.2rem;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .4);
}

/* ============ Кнопки ============ */
.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: #5457e6; --bs-btn-hover-border-color: #5457e6;
  --bs-btn-active-bg: #4f46e5; --bs-btn-focus-shadow-rgb: 99,102,241;
  font-weight: 600;
}
.btn { border-radius: var(--radius-sm); }
.btn-icon-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 10px; width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: .15s;
}
.btn-icon-ghost:hover { color: var(--text); border-color: var(--brand); }

/* ============ Каркас приложения ============ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; inset: 0 auto 0 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; z-index: 1040;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px;
  border-bottom: 1px solid var(--border); margin-bottom: 14px;
}
.brand-name { font-weight: 800; font-size: 1.05rem; }
.brand-sub { font-size: .72rem; color: var(--muted); }
.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: 11px; color: var(--muted); font-weight: 500; font-size: .92rem;
  transition: .15s;
}
.sidebar-nav .nav-link i { font-size: 1.1rem; }
.sidebar-nav .nav-link:hover { background: var(--surface-2); color: var(--text); }
.sidebar-nav .nav-link.active {
  background: var(--brand-grad); color: #fff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
}
.sidebar-section {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); padding: 16px 12px 6px; font-weight: 700;
}
.sidebar-foot {
  margin-top: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2);
  font-size: .76rem; color: var(--muted); display: flex; gap: 10px; align-items: flex-start;
}
.sidebar-foot i { color: var(--brand); font-size: 1rem; }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1035;
}

.app-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-weight: 700; }
.topbar-sub { font-size: .8rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px;
  border-radius: 40px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-grad);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; text-transform: uppercase;
}
.user-name { display: block; font-size: .85rem; font-weight: 600; line-height: 1.1; }
.user-role { display: block; font-size: .72rem; color: var(--muted); }

.content { padding: 26px; flex: 1; display: flex; flex-direction: column; }

/* ============ Карточки ============ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-1);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--border);
  font-weight: 700; padding: 16px 20px;
}
.card-body { padding: 20px; }

/* KPI-карточки */
.kpi-grid {
  display: grid; gap: 18px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-1);
}
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px;
  background: var(--accent, var(--brand)); opacity: .08; border-radius: 50%;
}
.kpi-icon {
  width: 46px; height: 46px; border-radius: 13px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 1.4rem; color: #fff;
  background: var(--accent, var(--brand)); margin-bottom: 14px;
}
.kpi-value { font-size: 2rem; font-weight: 800; line-height: 1; }
.kpi-label { color: var(--muted); font-size: .88rem; margin-top: 6px; }

.chart-card { padding: 20px; height: 100%; }
.chart-card h3 { font-size: .98rem; font-weight: 700; margin-bottom: 16px; }
.chart-wrap { position: relative; }

/* ============ Таблицы ============ */
.table { --bs-table-bg: transparent; color: var(--text); margin: 0; }
.table > :not(caption) > * > * { padding: 13px 14px; border-color: var(--border); }
.table thead th {
  color: var(--muted); font-size: .74rem; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 700; border-bottom: 1px solid var(--border);
}
.table tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: var(--surface-2); }
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-1);
}

.badge-status { font-weight: 600; padding: .4em .7em; border-radius: 8px; font-size: .76rem; }

/* ============ Формы ============ */
.form-label { font-weight: 600; font-size: .86rem; margin-bottom: 6px; }
.form-control, .form-select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 11px; padding: .6rem .85rem; transition: .15s;
}
.form-control:focus, .form-select:focus {
  background: var(--surface-2); color: var(--text); border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .18);
}
.form-control::placeholder { color: var(--muted); opacity: .7; }
.form-text { color: var(--muted); font-size: .8rem; }
.form-control.is-valid, .form-select.is-valid,
.was-validated .form-control:valid {
  border-color: #22c55e; background-image: none;
}
.form-control.is-invalid, .form-select.is-invalid,
.was-validated .form-control:invalid {
  border-color: #ef4444; background-image: none;
}
.invalid-feedback { font-size: .8rem; font-weight: 500; }
.valid-feedback { font-size: .8rem; }

/* Индикатор надёжности пароля */
.pw-meter { height: 6px; border-radius: 4px; background: var(--border); margin-top: 8px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; transition: .25s; border-radius: 4px; }
.pw-hint { font-size: .78rem; margin-top: 5px; color: var(--muted); }
.field-hint-ok { color: #22c55e; }
.field-hint-bad { color: #ef4444; }
.char-counter { font-size: .76rem; color: var(--muted); text-align: right; margin-top: 4px; }

/* ============ Публичные страницы ============ */
.public-navbar {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); padding: 12px 0;
}
.public-navbar .nav-link { color: var(--muted); font-weight: 500; }
.public-navbar .nav-link:hover { color: var(--text); }
.public-main { min-height: calc(100vh - 140px); padding: 40px 0; }

.hero {
  background: var(--brand-grad); border-radius: 26px; padding: 56px 48px; color: #fff;
  position: relative; overflow: hidden; box-shadow: var(--shadow-2);
}
.hero::before {
  content: ""; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px;
  background: rgba(255, 255, 255, .12); border-radius: 50%;
}
.hero::after {
  content: ""; position: absolute; right: 90px; bottom: -120px; width: 240px; height: 240px;
  background: rgba(255, 255, 255, .08); border-radius: 50%;
}
.hero h1 { font-weight: 800; font-size: 2.5rem; max-width: 660px; position: relative; }
.hero p { font-size: 1.1rem; opacity: .92; max-width: 580px; position: relative; }
.hero .btn-light { color: var(--brand); font-weight: 700; }

.stat-strip {
  display: grid; gap: 16px; margin: -38px 18px 0;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); position: relative; z-index: 3;
}
.stat-pill {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 20px; box-shadow: var(--shadow-1);
}
.stat-pill .n { font-size: 1.7rem; font-weight: 800; }
.stat-pill .l { color: var(--muted); font-size: .84rem; }

.service-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; height: 100%; transition: .18s; box-shadow: var(--shadow-1);
}
.service-card:hover { transform: translateY(-4px); border-color: var(--brand); box-shadow: var(--shadow-2); }
.service-ico {
  width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2);
  color: var(--brand); display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.3rem; margin-bottom: 14px;
}
.section-title { font-weight: 800; font-size: 1.7rem; margin-bottom: 6px; }
.section-sub { color: var(--muted); margin-bottom: 26px; }

/* ============ Аутентификация ============ */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
}
.auth-aside {
  background: var(--brand-grad); color: #fff; padding: 56px 50px; position: relative;
  overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside::before {
  content: ""; position: absolute; right: -100px; bottom: -100px; width: 360px; height: 360px;
  background: rgba(255, 255, 255, .1); border-radius: 50%;
}
.auth-aside h2 { font-weight: 800; font-size: 2rem; position: relative; }
.auth-feature { display: flex; gap: 14px; margin-top: 22px; position: relative; }
.auth-feature i { font-size: 1.4rem; }
.auth-body { display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 460px; }
.auth-card .brand-mark { width: 48px; height: 48px; font-size: 1.5rem; }

.quick-login { border: 1px dashed var(--border); border-radius: 14px; padding: 16px; background: var(--surface-2); }
.quick-login-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 12px; }
.quick-btn {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border-radius: 11px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); margin-bottom: 9px; transition: .15s; text-align: left; cursor: pointer;
}
.quick-btn:hover { border-color: var(--brand); transform: translateX(3px); }
.quick-btn .q-ico { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.q-admin { background: #6366f1; } .q-operator { background: #0ea5e9; } .q-citizen { background: #22c55e; }
.quick-btn .q-role { font-weight: 600; font-size: .9rem; }
.quick-btn .q-sub { font-size: .76rem; color: var(--muted); }

/* ============ Прочее ============ */
.message-stack { margin-bottom: 18px; }
.app-footer { padding: 18px 4px; margin-top: 28px; border-top: 1px solid var(--border); color: var(--muted); font-size: .82rem; }
.footer-dev { font-weight: 600; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty-state i { font-size: 2.6rem; opacity: .5; }
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before { content: ""; position: absolute; left: -23px; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--brand); border: 3px solid var(--surface); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.detail-item .k { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.detail-item .v { font-weight: 600; }

/* ============ Адаптивность ============ */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
  .app-main { margin-left: 0; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .hero { padding: 38px 26px; }
  .hero h1 { font-size: 1.9rem; }
}
