/* ============================================================
   Orion + Mira — Unified Styles (единый файл для всей экосистемы)
   ============================================================ */

/* ----- Reset ----- */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }

html { font-size: 13px; }

/* ----- Variables ----- */
:root {
  /* Palette */
  --bg:            #0a0d10;
  --surface:       #111418;
  --surface2:      #181c21;
  --border:        #262b33;
  --text:          #e6eaf0;
  --muted:         #788290;
  --faint:         #404854;
  --brand:         #ffaa00;
  --accent:        #5b8def;
  --green:         #3cb878;
  --red:           #e0556a;
  --yellow:        #e0a030;

  /* Typography */
  --font:          system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono:          'SF Mono', Consolas, 'Cascadia Code', monospace;
  --text-base:     13px;
  --text-sm:       11px;
  --text-xs:       10px;

  /* Spacing */
  --radius:        8px;
  --radius-sm:     3px;
  --space-xs:      4px;
  --space-sm:      8px;
  --space-md:      12px;
  --space-lg:      16px;
  --space-xl:      24px;
  --space-2xl:     28px;

  /* Effects */
  --glass:         color-mix(in srgb, var(--bg) 94%, transparent);
  --transition:    0.18s ease;
}

/* ----- Body (единая раскладка: topbar → content → input) ----- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.45;
  min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font: inherit; background: none; border: none; color: inherit; outline: none;
}

a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }

/* ----- Scrollbar ----- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ----- Utility ----- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ============================================================
   Topbar (единый для Ориона и Миры)
   ============================================================ */
.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-shrink: 0;
  flex-wrap: nowrap;
  z-index: 100;
}

.topbar-title {
  font-weight: 600; color: var(--brand); font-size: 14px;
  white-space: nowrap; letter-spacing: -0.3px;
}

.topbar-sub {
  color: var(--muted); font-size: var(--text-xs); white-space: nowrap;
}

.topbar a {
  color: var(--accent); font-size: 14px; text-decoration: none; flex-shrink: 0;
}

.topbar-left {
  display: flex; align-items: center; gap: var(--space-sm); flex: 1; min-width: 0;
  flex-wrap: nowrap; overflow: hidden;
}

.topbar-right {
  display: flex; align-items: center; gap: var(--space-sm); flex-shrink: 0;
}

/* ----- Badges ----- */
.micro-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 6px;
  font-size: var(--text-xs); line-height: 1;
  border: 1px solid var(--border); border-radius: var(--radius);
  white-space: nowrap; flex-shrink: 0;
}
.micro-badge.muted  { color: var(--muted); }
.micro-badge.faint  { color: var(--faint); font-family: var(--mono); }

.api-dot {
  width: 5px; height: 5px; border-radius: 5px; background: var(--faint);
  transition: background var(--transition); flex-shrink: 0;
}
.api-dot.on  { background: var(--green); box-shadow: 0 0 4px var(--green); }
.api-dot.off { background: var(--red); }
.api-dot.connecting { background: var(--yellow); animation: apiPulse 0.8s ease-in-out infinite alternate; }
@keyframes apiPulse {
  from { opacity: 0.3; box-shadow: 0 0 2px var(--yellow); }
  to   { opacity: 1;   box-shadow: 0 0 6px var(--yellow); }
}

.api-badge.on  { border-color: color-mix(in srgb, var(--green) 35%, transparent); }
.api-badge.off { border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.api-badge.connecting { border-color: color-mix(in srgb, var(--yellow) 35%, transparent); }

/* ----- Icon button ----- */
.icon-btn {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); font-size: 12px; color: var(--muted);
  cursor: pointer; background: none; border: none; flex-shrink: 0;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.icon-btn:hover { background: var(--surface2); color: var(--text); }
.icon-btn:active { transform: scale(0.95); }

/* ============================================================
   Mira — Chat
   ============================================================ */

/* --- Layout --- */
#app.cy-app { flex:1; display:flex; flex-direction:column; overflow:hidden; }
#app.cy-app .cy-page { flex:1; overflow-y:auto; }

.chat-wrap {
  flex:1; overflow-y:auto; padding:12px;
  -webkit-overflow-scrolling:touch; display:flex; flex-direction:column;
}
.chat-inner {
  margin-top:auto; display:flex; flex-direction:column; gap:6px;
}

/* --- Welcome --- */
.chat-wrap .welcome {
  background:var(--surface); border:1px solid var(--border);
  border-radius:10px; padding:16px; text-align:center; margin-bottom:4px;
}
.chat-wrap .welcome h3 { font-size:15px; color:var(--brand); margin-bottom:6px; }
.chat-wrap .welcome p { font-size:12px; color:var(--muted); line-height:1.5; }

.quick-actions {
  display:flex; flex-wrap:wrap; gap:6px; margin-top:10px; justify-content:center;
}
.qa-btn {
  padding:7px 12px; font-size:11px; border-radius:16px;
  border:1px solid var(--border); color:var(--muted);
  background:var(--surface2); cursor:pointer; transition:.15s;
}
.qa-btn:active { border-color:var(--accent); color:var(--text); }

/* --- Messages --- */
.msg {
  max-width:85%; padding:10px 14px; border-radius:14px; font-size:13px;
  line-height:1.5; word-wrap:break-word; animation:in .2s ease;
}
.msg.user {
  align-self:flex-end; background:var(--accent); color:#fff;
  border-bottom-right-radius:4px;
}
.msg.bot {
  align-self:flex-start; background:var(--surface2);
  border:1px solid var(--border); border-bottom-left-radius:4px; white-space:pre-wrap;
}
.msg .time { font-size:10px; opacity:.45; margin-top:4px; }
.msg.user .time { text-align:right; }
.msg img { max-width:200px; border-radius:8px; margin-top:4px; cursor:pointer; }
.msg audio { max-width:200px; margin-top:4px; }

/* --- Typing indicator --- */
.typing {
  align-self:flex-start; display:flex; gap:4px; padding:12px 14px;
}
.typing span {
  width:6px; height:6px; background:var(--muted); border-radius:50%;
  animation:bounce 1.4s infinite;
}
.typing span:nth-child(2) { animation-delay:.2s; }
.typing span:nth-child(3) { animation-delay:.4s; }
@keyframes bounce { 0%,80%,100%{transform:scale(0)} 40%{transform:scale(1)} }
@keyframes in { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

/* --- Input bar --- */
.input-bar {
  display:flex; flex-direction:column; gap:0; border-top:1px solid var(--border);
  background:var(--glass); backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px);
  flex-shrink:0; z-index:100;
  padding-bottom:max(6px, env(safe-area-inset-bottom, 6px));
}
.input-row { display:flex; gap:8px; padding:6px 12px 8px; align-items:flex-end; }
.input-bar textarea {
  flex:1; background:var(--surface2); border:1px solid var(--border);
  border-radius:18px; padding:8px 14px; font-size:14px; color:var(--text);
  outline:none; resize:none; max-height:100px; font-family:var(--font);
  line-height:1.4; transition:border-color .15s;
}
.input-bar textarea:focus { border-color:var(--accent); }
.input-bar .cy-btn-round {
  width:36px; height:36px; border-radius:50%; background:var(--surface2);
  border:1px solid var(--border); color:var(--muted); font-size:16px;
  cursor:pointer; display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.input-bar .cy-btn-round:active { background:var(--border); }
.input-bar .cy-btn-send {
  width:36px; height:36px; border-radius:50%; background:var(--accent);
  color:#fff; font-size:16px; border:none; cursor:pointer;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
  transition:opacity .15s;
}
.input-bar .cy-btn-send:disabled { opacity:.4; }
.input-bar .cy-btn-send:active { opacity:.7; }
.input-bar .mic.recording {
  background:var(--red); border-color:var(--red); color:#fff;
  animation:pulse .8s infinite;
}
@keyframes pulse {
  0%,100%{box-shadow:0 0 0 0 rgba(224,85,106,.4)}
  50%{box-shadow:0 0 0 8px rgba(224,85,106,0)}
}

.preview-row { display:none; flex-wrap:wrap; gap:4px; padding:4px 12px 0; }
.preview-thumb {
  display:inline-flex; align-items:center; gap:4px;
  background:var(--surface2); border:1px solid var(--border);
  border-radius:8px; padding:4px 8px; font-size:11px; margin:4px 0;
}
.preview-thumb img { width:40px; height:40px; object-fit:cover; border-radius:8px; }
.preview-thumb .remove { color:var(--red); cursor:pointer; font-size:14px; margin-left:4px; }

/* --- Reload button --- */
#reloadBtn:hover { background:var(--surface2); color:var(--text); transform:scale(1.1); }
#reloadBtn:active { transform:scale(0.95); }

/* ============================================================
   Login Screen (общий)
   ============================================================ */
.login-screen {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top, 24px)) 24px max(24px, env(safe-area-inset-bottom, 24px));
  animation: fadeIn 0.3s ease;
}
.login-card {
  width: 340px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-2xl);
  animation: slideUp 0.35s ease;
}
.login-title {
  font-size: 15px; font-weight: 600; margin-bottom: 2px;
}
.login-version {
  color: var(--muted); font-size: var(--text-xs); margin-bottom: var(--space-xl);
}
.form-block { display: flex; flex-direction: column; gap: var(--space-md); }
.field { display: flex; flex-direction: column; gap: 2px; }
.field label {
  font-size: var(--text-xs); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.input, .select {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 9px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}
.field-check { display: flex; align-items: center; gap: var(--space-sm); }
.field-check label { font-size: var(--text-xs); color: var(--muted); cursor: pointer; }
.field-check input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.btn-primary {
  background: var(--accent); color: #fff; border-radius: var(--radius);
  padding: 10px 20px; font-weight: 500; cursor: pointer;
  transition: opacity var(--transition), transform var(--transition);
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

/* ============================================================
   Orion — App Layout
   ============================================================ */
.app {
  display: flex; flex-direction: column; flex: 1; overflow: hidden;
  animation: fadeIn 0.25s ease;
}

/* --- Status Tabs --- */
.status-tabs { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; }
.status-tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  height: 20px; display: inline-flex; align-items: center; padding: 0 8px;
  font-size: var(--text-xs); color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap;
  line-height: 1;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.tab-btn:hover { color: var(--text); background: color-mix(in srgb, var(--surface) 40%, transparent); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.tab-count { margin-left: 3px; opacity: 0.45; font-size: var(--text-xs); }
.mobile-select { display: none; }

/* --- Designer Row --- */
.designer-row {
  padding: 0 12px 1px; display: flex; gap: 4px; flex-wrap: wrap;
  font-size: var(--text-xs); animation: slideDown 0.2s ease;
}
.subtab-btn {
  padding: 3px 8px; font-size: var(--text-xs); color: var(--muted);
  cursor: pointer; border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.subtab-btn:hover { background: var(--surface2); }
.subtab-btn.active { background: var(--surface2); color: var(--text); font-weight: 500; }

/* --- Toolbar --- */
.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; flex-wrap: nowrap; animation: slideDown 0.2s ease;
  z-index: 99; background: var(--bg);
}
.toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; flex-wrap: nowrap; animation: slideDown 0.2s ease;
  z-index: 98; background: var(--bg);
}
.page { padding:0 12px 16px; scroll-padding-top:90px; }
/* Mobile */
@media (max-width: 768px) {
  .topbar { padding: 3px 6px; gap: 3px; flex-wrap: nowrap; }
  .topbar-left { flex-wrap: nowrap; gap: 3px; }
  .topbar-title { margin-right: 0; font-size:12px }
  .topbar-sub { margin-left: 0; display:none }
  .topbar-right { gap: 3px; flex-shrink: 0; }
  .status-tabs { display: none; }
  .mobile-select { display: block; margin:0; height:20px; max-width:120px; font-size:11px }
  .toolbar { z-index: 98; background: var(--bg); padding: 3px 6px; gap: 3px; flex-wrap: nowrap; }
  .icon-btn { width: 20px; height: 20px; font-size: 11px; }
  .micro-badge { height: 18px; padding: 0 4px; font-size:9px }
  .tab-btn { height: 18px; padding: 0 6px; font-size:10px }
  .page { padding: 4px 6px 16px; }
  .page { padding: 8px 8px 16px; }
  .chips-wrap { padding: var(--space-xs) 8px 6px; }
  .group-head { padding: 6px 10px; }
  .order-head { padding: 6px 10px; gap: 6px; }
  .order-id { min-width: 24px; font-size: var(--text-xs); }
  .order-date { min-width: 44px; font-size: var(--text-xs); }
  .order-product { min-width: 0; max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .order-desc-short { font-size: var(--text-sm); }
  .order-money { font-size: var(--text-xs); gap: var(--space-xs); }
  .order.open .order-body { padding: 10px 10px 10px 10px; max-height: 500px; }
  .details-grid { grid-template-columns: 1fr; gap: var(--space-sm); }
  .status-actions { justify-content: stretch; }
  .status-btn { flex: 1; text-align: center; }
  .detail-client-row { gap: var(--space-sm); }
  .client-phone { font-size: var(--text-xs); }
  .msg-icon { width: 12px; height: 12px; }
  .money-full  { display: none; }
  .money-short { display: inline; }
  .modal { margin: 10px; max-width: none; border-radius: var(--radius) var(--radius) 0 0; }

  .chat-wrap { padding: 8px; }
  .input-row { padding: 6px 8px 8px; }
}
