/* ═══════════════════════════════════════════
   Квайб · Менеджер пользователей — стили
   ═══════════════════════════════════════════ */

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

:root {
  --bg:          #0f1117;
  --surface:     #181b24;
  --surface-2:   #1e2230;
  --surface-3:   #252a38;
  --border:      #2a2f3e;
  --border-l:    #353b4d;
  --text:        #e4e6ee;
  --text-dim:    #8b90a0;
  --accent:      #6ee7a0;
  --accent-dim:  #3d9e6a;
  --danger:      #f06e6e;
  --danger-dim:  #9e3d3d;
  --error:       #f45;
  --error-bg:    rgba(255,68,85,.08);
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 8px 32px rgba(0,0,0,.45);
  --font:        'SN Pro', system-ui, -apple-system, sans-serif;
  --mono:        'JetBrains Mono', Menlo, monospace;
}

html { height: 100%; }

body {
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4 { font-family: var(--font); font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.35rem; margin-bottom: .75rem; }

code { font-family: var(--mono); background: var(--surface-3); padding: .15em .4em; border-radius: 4px; font-size: .88em; }
.muted { color: var(--text-dim); font-size: .88rem; margin-top: .5rem; }

.hidden { display: none !important; }

/* ───── экраны ───── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

/* ───── кнопки ───── */
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--font); font-size: .88rem; font-weight: 600;
  border: none; border-radius: var(--radius-sm); cursor: pointer;
  padding: .55rem 1.2rem; transition: all .18s;
  color: var(--text); background: var(--surface-3);
}
.btn:hover { background: var(--border-l); }
.btn--primary { background: var(--accent-dim); color: #fff; }
.btn--primary:hover { background: var(--accent); color: #111; }
.btn--danger { background: var(--danger-dim); color: #fff; }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--outline { background: transparent; border: 1.5px solid var(--border-l); color: var(--text-dim); }
.btn--outline:hover { border-color: var(--accent); color: var(--accent); }
.btn--small { padding: .4rem .8rem; font-size: .8rem; }
.btn--ghost { background: transparent; color: var(--text-dim); }
.btn--ghost:hover { color: var(--danger); }

/* ══════════ ЭКРАН ВХОДА ══════════ */
#loginScreen {
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 20%, rgba(110,231,160,.06) 0%, transparent 60%);
}

.login-card {
  width: 100%; max-width: 400px; padding: 2.5rem 2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); animation: fadeUp .4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-card__icon { color: var(--accent); margin-bottom: 1.2rem; }
.login-card__title { font-size: 1.5rem; margin-bottom: .3rem; }
.login-card__subtitle { color: var(--text-dim); font-size: .88rem; margin-bottom: 1.5rem; }

/* ───── поле ввода ───── */
.field { margin-bottom: 1.1rem; }
.field__label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-dim); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.field__input {
  width: 100%; padding: .7rem .9rem; font-size: 1rem; font-family: var(--font);
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.field__input::placeholder { color: var(--text-dim); opacity: .55; }
.field__input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(110,231,160,.15); }

/* ошибка */
.field--error .field__input {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 3px rgba(255,68,85,.12);
  animation: shake .35s ease;
}
@keyframes shake {
  10%,90% { transform: translateX(-2px); }
  20%,80% { transform: translateX(4px); }
  30%,50%,70% { transform: translateX(-5px); }
  40%,60% { transform: translateX(5px); }
}

.field__error {
  display: block; min-height: 1.2em; margin-top: .3rem;
  font-size: .78rem; color: var(--error); font-weight: 600;
}

/* ───── сохранённые пользователи ───── */
.saved-users { margin-top: 1.3rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.saved-users__title { font-size: .78rem; color: var(--text-dim); margin-bottom: .55rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.saved-users__list { display: flex; flex-wrap: wrap; gap: .45rem; }

.user-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .75rem; font-size: .82rem; font-weight: 600;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 20px;
  cursor: pointer; transition: all .18s; color: var(--text);
}
.user-chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.user-chip__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* ══════════ ОСНОВНОЙ ИНТЕРФЕЙС ══════════ */
#appScreen {
  flex-direction: column; background: var(--bg);
}

/* ───── верхняя панель ───── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar__left { display: flex; align-items: center; gap: .75rem; }
.topbar__logo {
  font-family: var(--mono); font-weight: 700; font-size: .9rem;
  background: var(--accent); color: #111; padding: .25rem .55rem; border-radius: 6px;
}
.topbar__greeting { font-size: .9rem; color: var(--text-dim); }
.topbar__greeting strong { color: var(--text); }
.topbar__right { display: flex; gap: .5rem; }

/* ───── тело приложения ───── */
.app-body {
  display: grid; grid-template-columns: 200px 1fr 280px;
  flex: 1; min-height: calc(100vh - 48px);
}

/* ───── боковая панель ───── */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border); padding: 1.2rem 0;
}
.sidebar__title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); padding: 0 1rem; margin-bottom: .6rem; font-weight: 700; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }

.nav-btn {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .6rem 1rem; font-family: var(--font); font-size: .85rem; font-weight: 600;
  background: transparent; border: none; color: var(--text-dim); cursor: pointer;
  transition: all .15s; border-left: 3px solid transparent; text-align: left;
}
.nav-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-btn.active {
  color: var(--accent); background: rgba(110,231,160,.06);
  border-left-color: var(--accent);
}
.nav-btn.active svg { color: var(--accent); }

/* ───── контент ───── */
.content { padding: 1.5rem 2rem; overflow-y: auto; }

/* ───── страницы ───── */
.page { display: none; animation: fadeIn .25s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ───── карточки статистики ───── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; margin-top: .5rem; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.2rem; text-align: center; transition: border-color .2s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card__value { display: block; font-size: 2rem; font-weight: 800; color: var(--accent); font-family: var(--mono); }
.stat-card__label { display: block; font-size: .78rem; color: var(--text-dim); margin-top: .2rem; }

/* ───── инфо-блок ───── */
.info-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.2rem 1.5rem; }
.info-row { display: flex; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--text-dim); min-width: 140px; font-size: .88rem; }
.info-val { font-weight: 600; font-size: .88rem; }

/* ══════════ ПАНЕЛЬ ИСТОРИИ ══════════ */
.history-panel {
  background: var(--surface); border-left: 1px solid var(--border);
  padding: 1.2rem; display: flex; flex-direction: column;
  max-height: calc(100vh - 48px);
}
.history-panel__title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim);
  margin-bottom: .8rem; font-weight: 700; display: flex; align-items: center; gap: .45rem;
  flex-shrink: 0;
}

.history-list {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  margin-bottom: .8rem;
}
.history-list::-webkit-scrollbar { width: 5px; }
.history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.history-entry {
  padding: .45rem .65rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border-left: 3px solid var(--border);
  font-size: .78rem; line-height: 1.4; animation: slideIn .2s ease;
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.history-entry--click  { border-left-color: var(--accent); }
.history-entry--nav    { border-left-color: #7ba4f4; }
.history-entry--auth   { border-left-color: #e4b85a; }
.history-entry--system { border-left-color: var(--text-dim); }

.history-entry__time {
  font-family: var(--mono); font-size: .68rem; color: var(--text-dim);
  display: block; margin-bottom: 1px;
}
.history-entry__text { color: var(--text); }

/* ══════════ МОДАЛЬНЫЕ ОКНА ══════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  animation: fadeIn .2s ease;
}
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 2rem; width: 100%; max-width: 380px; box-shadow: var(--shadow);
  animation: fadeUp .25s ease;
}
.modal h3 { margin-bottom: .7rem; }
.modal p { color: var(--text-dim); font-size: .9rem; line-height: 1.5; margin-bottom: 1.2rem; }
.modal__actions { display: flex; justify-content: flex-end; gap: .5rem; }

.switch-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; max-height: 280px; overflow-y: auto; }
.switch-user-btn {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  padding: .65rem .9rem; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; color: var(--text);
  font-family: var(--font); font-size: .88rem; font-weight: 600; transition: all .15s;
}
.switch-user-btn:hover { border-color: var(--accent); color: var(--accent); }
.switch-user-btn.current { border-color: var(--accent); background: rgba(110,231,160,.06); color: var(--accent); }
.switch-user-btn__badge { font-size: .7rem; font-family: var(--mono); color: var(--text-dim); }

/* ───── адаптив ───── */
@media (max-width: 860px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .history-panel {
    position: fixed; bottom: 0; left: 0; right: 0;
    max-height: 40vh; border-left: none; border-top: 1px solid var(--border);
    z-index: 40; display: none;
  }
  .history-panel.open { display: flex; }
}

/* ───── пустая история ───── */
.history-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); font-size: .82rem; text-align: center; opacity: .6;
}
