/* ═══════ МегаМеханика PWA — светлая тема ═══════ */

:root {
  --red: #C2001C;
  --red-hover: #9E0016;
  --red-light: rgba(194,0,28,0.08);
  --bg: #FFFFFF;
  --bg2: #F7F7F9;
  --card: #F0F0F5;
  --card-hover: #E8E8ED;
  --border: rgba(0,0,0,0.08);
  --text: #1D1D1F;
  --text2: #6E6E73;
  --text3: #AEAEB2;
  --green: #34C759;
  --yellow: #FF9F0A;
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; height: 100%; }
body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ═══════ SCREENS ═══════ */
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0; left: 0;
}
.screen.active { display: flex; }

/* ═══════ AUTH SCREEN ═══════ */
.auth-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  background: var(--bg);
}
.auth-logo { width: 80px; height: 80px; margin-bottom: 16px; }
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-title {
  font-size: 32px; font-weight: 800;
  letter-spacing: -0.02em; margin-bottom: 8px;
  color: var(--text);
}
.auth-subtitle {
  font-size: 16px; color: var(--text2);
  margin-bottom: 40px;
}
.auth-features {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 40px; width: 100%; max-width: 320px;
}
.auth-feature {
  display: flex; align-items: center; gap: 12px;
  font-size: 15px; color: var(--text);
  text-align: left;
}
.af-icon { font-size: 20px; flex-shrink: 0; }

.auth-buttons {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 320px; margin-bottom: 32px;
}

.auth-stats {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text3);
}
.auth-stat strong { color: var(--text2); }
.auth-stat-dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: var(--text3);
}
.auth-disclaimer {
  font-size: 11px; color: var(--text3); text-align: center;
  margin-top: 16px; line-height: 1.4; max-width: 300px;
}

/* ═══════ ROLE SELECT ═══════ */
.role-select {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  width: 100%;
}
.role-btn {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 8px 16px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--text2); cursor: pointer; transition: var(--transition);
}
.role-btn.active {
  border-color: var(--red); color: var(--red); background: var(--red-light);
}

/* ═══════ BUTTONS ═══════ */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 24px; border-radius: 50px; border: none;
  font-family: inherit; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  min-height: 48px;
}
.btn-tg {
  background: #2AABEE; color: #fff;
}
.btn-tg:hover { background: #229ED9; }
.btn-max {
  background: var(--card); color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-max:hover { background: var(--card-hover); }
.btn-red-full {
  background: var(--red); color: #fff;
  width: 100%; border-radius: var(--radius);
}
.btn-red-full:hover { background: var(--red-hover); }
.btn-booking {
  background: var(--bg); color: var(--text);
  width: 100%; border-radius: var(--radius);
  border: 1.5px solid var(--border);
  margin-top: 24px;
}
.btn-booking:hover { background: var(--bg2); }
.btn-ai-ask {
  background: var(--red); color: #fff;
  width: 100%; border-radius: var(--radius);
}
.btn-booking-sm {
  background: var(--bg); color: var(--text);
  width: 100%; border-radius: var(--radius);
  border: 1.5px solid var(--border);
}
.btn-dev {
  background: transparent; color: var(--text3);
  font-size: 12px; margin-top: 16px;
}

/* ═══════ HEADER ═══════ */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  min-height: 56px;
  flex-shrink: 0;
}
.header-user {
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--card); display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
#userName { font-size: 14px; font-weight: 600; color: var(--text); }
.header-quota {
  background: var(--red-light); color: var(--red);
  padding: 4px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
}
.header-title { font-size: 16px; font-weight: 700; color: var(--text); }
.header-quota-sm {
  font-size: 13px; color: var(--text3); font-weight: 500;
}
.back-btn {
  background: none; border: none; color: var(--text2);
  font-family: inherit; font-size: 14px; cursor: pointer;
  padding: 8px 0; min-height: 44px; display: flex; align-items: center;
}
.share-btn {
  background: none; border: none; color: var(--red);
  font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 8px 0; min-height: 44px; display: flex; align-items: center;
}

/* ═══════ MAIN CONTENT ═══════ */
.main-content {
  flex: 1; overflow-y: auto;
  padding: 24px 16px 100px;
  background: var(--bg);
}
.main-title {
  font-size: 24px; font-weight: 800;
  margin-bottom: 20px; letter-spacing: -0.02em;
  color: var(--text);
}

/* ═══════ INPUT ═══════ */
.input-group {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.input-field {
  flex: 1; background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  font-family: inherit; font-size: 15px; color: var(--text);
  transition: var(--transition);
  min-height: 48px;
}
.input-field:focus {
  outline: none; border-color: var(--red);
}
.input-field::placeholder { color: var(--text3); }
.textarea { border-radius: var(--radius); resize: none; }
.input-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--red); color: #fff; border: none;
  font-size: 18px; font-weight: 700; cursor: pointer;
  flex-shrink: 0; transition: var(--transition);
}
.input-btn:hover { background: var(--red-hover); }

.divider {
  display: flex; align-items: center; gap: 12px;
  margin: 8px 0 16px; color: var(--text3); font-size: 13px;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px;
  background: var(--border);
}

/* ═══════ QUICK TAGS ═══════ */
.quick-tags {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 20px;
}
.tag {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 20px; padding: 8px 16px;
  font-family: inherit; font-size: 13px; color: var(--text2);
  cursor: pointer; transition: var(--transition);
}
.tag:hover { background: var(--card-hover); color: var(--text); border-color: var(--red); }

/* ═══════ RESULT ═══════ */
.result-content {
  flex: 1; overflow-y: auto; padding: 20px 16px 0;
  background: var(--bg);
}
.result-code {
  font-size: 20px; font-weight: 800; margin-bottom: 4px; color: var(--text);
}
.result-system {
  font-size: 14px; color: var(--text2); margin-bottom: 16px;
}
.severity-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  margin-bottom: 16px; width: 100%;
}
.severity-critical {
  background: rgba(255,59,48,0.1); color: #D70015;
}
.severity-warning {
  background: rgba(255,159,10,0.1); color: #C77800;
}
.severity-info {
  background: rgba(52,199,89,0.1); color: #248A3D;
}
.result-section {
  background: var(--bg2); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
}
.result-label {
  font-size: 12px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 8px;
}
.result-text { font-size: 15px; line-height: 1.5; color: var(--text); }
.result-price {
  font-size: 18px; font-weight: 700; color: var(--red);
}
.result-actions {
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
  flex-shrink: 0;
}

/* ═══════ CHAT ═══════ */
.chat-disclaimer {
  text-align: center; font-size: 11px; color: var(--text3);
  padding: 8px 16px; background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--bg);
}
.msg {
  display: flex; gap: 10px; max-width: 85%;
  animation: msgIn 0.2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg2); display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.msg-user .msg-avatar { background: var(--red); font-size: 14px; color: #fff; }
.msg-text {
  background: var(--bg2); border-radius: 16px 16px 16px 4px;
  padding: 12px 16px; font-size: 14px; line-height: 1.5;
  color: var(--text);
}
.msg-user .msg-text {
  background: var(--red); color: #fff;
  border-radius: 16px 16px 4px 16px;
}
.msg-typing .msg-text {
  color: var(--text3);
}

.chat-input-bar {
  display: flex; gap: 8px; padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input {
  flex: 1; background: var(--bg2);
  border: 1.5px solid var(--border);
  border-radius: 24px; padding: 12px 16px;
  font-family: inherit; font-size: 15px; color: var(--text);
  min-height: 44px;
}
.chat-input:focus { outline: none; border-color: var(--red); }
.chat-input::placeholder { color: var(--text3); }
.chat-send {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--red); color: #fff; border: none;
  font-size: 18px; font-weight: 700; cursor: pointer;
  flex-shrink: 0;
}
.chat-send:disabled { opacity: 0.4; }

/* ═══════ BOOKING ═══════ */
.booking-content {
  flex: 1; overflow-y: auto; padding: 24px 16px 100px;
  background: var(--bg);
}
.booking-title {
  font-size: 22px; font-weight: 800; margin-bottom: 20px; color: var(--text);
}
.sto-cards {
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 20px;
}
.sto-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg2); border-radius: var(--radius);
  padding: 16px; cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
}
.sto-card:has(input:checked) {
  border-color: var(--red); background: var(--red-light);
}
.sto-card input { display: none; }
.sto-name { font-size: 16px; font-weight: 700; color: var(--text); }
.sto-type { font-size: 12px; color: var(--red); font-weight: 600; }
.sto-addr { font-size: 13px; color: var(--text2); margin-top: 2px; }
.booking-content .input-field { width: 100%; margin-bottom: 12px; }
.booking-note {
  text-align: center; font-size: 13px; color: var(--text3);
  margin-top: 12px;
}

/* ═══════ BOTTOM NAV ═══════ */
.bottom-nav {
  display: flex; justify-content: space-around;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 8px 0;
  padding-bottom: calc(8px + var(--safe-bottom));
  flex-shrink: 0;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--text3);
  font-family: inherit; font-size: 11px; font-weight: 500;
  cursor: pointer; padding: 4px 16px; min-height: 44px;
  justify-content: center; transition: var(--transition);
}
.nav-item.active { color: var(--red); }
.nav-icon { font-size: 20px; }

/* ═══════ TOAST ═══════ */
.toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff;
  padding: 12px 24px; border-radius: 50px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 1000; animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══════ SETTINGS PANEL ═══════ */
.header-right {
  display: flex; align-items: center; gap: 8px;
}
.settings-btn {
  background: none; border: none; font-size: 18px;
  cursor: pointer; padding: 4px; opacity: 0.5;
  transition: var(--transition);
}
.settings-btn:hover { opacity: 1; }
.settings-panel {
  display: none;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  flex-shrink: 0;
  animation: slideDown 0.2s ease;
}
.settings-panel.open { display: block; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.setting-row:last-child { margin-bottom: 0; }
.setting-label {
  font-size: 13px; font-weight: 600; color: var(--text2);
}
.theme-toggle, .font-toggle {
  display: flex; gap: 4px;
}
.theme-btn, .font-btn {
  background: var(--card); border: 1.5px solid transparent;
  border-radius: 8px; padding: 6px 12px;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text2); cursor: pointer;
  transition: var(--transition);
}
.theme-btn.active, .font-btn.active {
  border-color: var(--red); color: var(--red); background: var(--red-light);
}
.font-btn:nth-child(1) { font-size: 11px; }
.font-btn:nth-child(2) { font-size: 14px; }
.font-btn:nth-child(3) { font-size: 17px; }
.font-btn:nth-child(4) { font-size: 20px; }

/* ═══════ DARK THEME ═══════ */
body.dark {
  --bg: #1A1A1E;
  --bg2: #232328;
  --card: #2A2A30;
  --card-hover: #333338;
  --border: rgba(255,255,255,0.08);
  --text: #F5F5F7;
  --text2: #A1A1A6;
  --text3: #6E6E73;
  --red-light: rgba(194,0,28,0.15);
}
body.dark .severity-critical { background: rgba(255,59,48,0.15); color: #FF453A; }
body.dark .severity-warning { background: rgba(255,159,10,0.15); color: #FF9F0A; }
body.dark .severity-info { background: rgba(52,199,89,0.15); color: #30D158; }
body.dark .auth-logo img { filter: brightness(0) invert(1); }

/* ═══════ FONT SIZES ═══════ */
body.font-small { font-size: 14px; }
body.font-normal { font-size: 16px; }
body.font-large { font-size: 18px; }
body.font-xlarge { font-size: 21px; }

/* ═══════ RESPONSIVE ═══════ */
@media (min-width: 480px) {
  .screen { max-width: 420px; margin: 0 auto; left: 50%; transform: translateX(-50%); }
}
