/* ====== Base / Theme ====== */
:root{
  --bg: #0b1020;           /* fonas */
  --panel: #121736;        /* header/nav */
  --card: #161b2e;         /* kortelės */
  --text: #eaf0ff;         /* pagr. tekstas */
  --muted: #9fb0ff;        /* antrinis tekstas */
  --accent: #2f4bff;       /* ryškios detalės */
  --accent-2: #2bd576;     /* žali indikatoriai */
  --border: #2b3564;
  --hover: #1b2242;
}

*{ box-sizing: border-box }
html,body{
  height:100%;
  margin:0;
  font:15px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,Arial;
  background:var(--bg);
  color:var(--text);
}
a{ color:inherit; text-decoration:none }
img{ max-width:100% }
button{ font:inherit }

/* ====== Layout (header + app + nav + content) ====== */

/* Viršutinė juosta – visada viršuje */
.bar{
  position:fixed;
  top:0;
  left:0;
  right:0;
  height:56px;
  display:flex;
  align-items:center;
  gap:12px;
  padding:0 16px;
  background:var(--panel);
  border-bottom:1px solid var(--border);
  z-index:100;
}
.brand{ font-weight:700 }
.muted{ color:var(--muted) }
.spacer{ flex:1 }

/* Kad turinys nebūtų po headeriu */
body{
  padding-top:56px;
}

/* Pagrindinis layout – desktop: kairėje meniu, dešinėje turinys */
.app{
  display:grid;
  grid-template-columns: 240px 1fr;
  gap:0;
  min-height: calc(100vh - 56px);
}

/* Sidenav – desktop */
nav.sidenav{
  background:var(--panel);
  border-right:1px solid var(--border);
  height:calc(100vh - 56px);
  overflow:auto;
}
.sidenav .section{
  padding:12px 14px;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:var(--muted);
}
.sidenav .item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 14px;
  cursor:pointer;
  border-left:3px solid transparent;
}
.sidenav .item:hover{ background:var(--hover) }
.sidenav .item.active{
  background:linear-gradient(90deg, rgba(47,75,255,.18), transparent);
  border-left-color:var(--accent);
}
.sidenav .item .k{ width:22px; text-align:center; opacity:.9 }

/* Turinys */
main.content,
.main{
  padding:18px;
}
.page-title{
  display:flex;
  align-items:center;
  gap:10px;
  margin:4px 0 16px 0;
}
.badge{
  font-size:12px;
  padding:2px 8px;
  border-radius:999px;
  background:#1c2444;
  color:var(--muted);
  border:1px solid var(--border);
}

/* Hamburger + backdrop (mobile naudos) */
.menu-toggle{
  display:none;
  font-size:20px;
  line-height:1;
  margin-right:8px;
  background:none;
  border:none;
  cursor:pointer;
}
.nav-backdrop{
  display:none;
}

/* ====== Cards / Grid ====== */
.grid{
  display:grid; gap:14px;
}
.grid.cols-4{ grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width:1200px){ .grid.cols-4{ grid-template-columns: repeat(3, 1fr); } }
@media (max-width:980px){ .grid.cols-3, .grid.cols-4{ grid-template-columns: repeat(2, 1fr); } }
@media (max-width:640px){ .grid.cols-2, .grid.cols-3, .grid.cols-4{ grid-template-columns: 1fr; } }

.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:14px;
  box-shadow: 0 10px 24px rgba(0,0,0,.25);
}
.card h3{
  margin:0 0 8px 0;
  font-size:14px;
  color:var(--muted);
}
.card .value{
  font-size:26px;
  font-weight:700;
  letter-spacing:.3px;
}

/* ====== Tables ====== */
.table{
  width:100%;
  border-collapse: collapse;
  font-size:14px;
  overflow:hidden;
  border-radius:12px;
  border:1px solid var(--border);
}
.table th, .table td{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  text-align:left;
}
.table th{
  background:#1a2140;
  color:#cbd5ff;
  font-weight:600;
}
.table tr:hover td{ background:#10162c }

/* ====== Buttons / Inputs ====== */
.btn{
  padding:10px 14px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#1a2140;
  color:var(--text);
  cursor:pointer;
}
.btn.disabled,
.btn[disabled]{
  opacity:.6;
  cursor:not-allowed;
}
.btn.primary{ background:var(--accent); border-color:transparent }
.btn.ghost{ background:#10162c }
.input{
  width:100%;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#0f1427;
  color:var(--text);
  outline:none;
}

/* ====== Utility ====== */
.row{
  display:flex;
  gap:12px;
  align-items:center;
  flex-wrap:wrap;
}
.col{ display:flex; flex-direction:column; gap:8px }
.separator{ height:1px; background:var(--border); margin:10px 0 }
.kpi{
  display:flex;
  align-items:center;
  gap:8px;
  color:#b9c5ff;
  font-size:12px;
}
.kpi .dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--accent-2);
}

/* ====== Talk UI (per-app view-talk) ====== */

/* Chat log */
.log{
  height:260px;
  overflow:auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background:#0f1427;
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px;
}

/* „Rašo…“ indikatorius */
.typing{
  min-height:48px;
  white-space:pre-wrap;
  word-wrap:break-word;
  background:#0f1427;
  border:1px dashed var(--border);
  border-radius:10px;
  padding:10px;
}

/* Chips / pill */
.chips{ display:flex; gap:6px; flex-wrap:wrap }
.chip{
  background:#0f1427;
  border:1px solid var(--border);
  color:#cfd6ff;
  padding:4px 8px;
  border-radius:999px;
  font-size:12px;
}
.chip.ok{ border-color:#1a6c44; color:#bfffe3; background:#0b1310 }
.chip.warn{ border-color:#5d4020; color:#ffd9af; background:#15100a }
.counter{ font-size:12px; color:var(--muted); margin-left:6px }
.pill{
  display:inline-flex;
  gap:6px;
  align-items:center;
  padding:6px 10px;
  border-radius:999px;
  background:#1b2442;
  border:1px solid var(--border);
  margin:4px 6px 0 0;
}
.pill .btn{ padding:4px 8px; border-radius:999px }

/* Asmenų sąrašas */
.list{ display:flex; flex-direction:column; gap:10px }
.list .item{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:10px;
  background:linear-gradient(180deg, rgba(26,33,64,.55), rgba(16,22,44,.55));
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
}
.list .item:hover{ background:var(--hover) }
.list .item .info{ min-width:0 }
.list .item .info .muted{ display:block; margin-top:4px }
.list .item .actions{ display:flex; align-items:center }
.list .item.active{
  background:#0f2a1f;
  border-color:#1a6c44;
  box-shadow:0 0 0 1px rgba(26,108,68,.30) inset;
}
.list .item.active b,
.list .item.active .muted{
  color: var(--accent-2) !important;
}

/* Mikrofono būsena 
.btn.mic.recording{ position:relative }
.btn.mic.recording::after{
  content:"";
  position:absolute;
  top:6px;
  right:6px;
  width:8px;
  height:8px;
  border-radius:999px;
  background:#ff4d4f;
  box-shadow:0 0 0 4px rgba(255,77,79,.25);
}*/

/* Mikrofono mygtuko būsena */
.btn.mic.recording{
  background:#7f1d1d;
  border-color:#f87171;
  color:#fff;
}
.btn.mic.recording:hover{
  background:#991b1b;
}
.small{
  font-size:12px;
}


/* TTS grotuvas */
#ttsPlayer{
  width:100%;
  display:block !important;
  margin-top:8px;
  background:#0f1427;
  border:1px solid var(--border);
  border-radius:10px;
}

/* Talk UI utilitai */
#talk-suggest .col{ gap:6px }
#talk-suggest input.input{ height:38px }

/* === UI papildymai === */
.status{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#1a2140;
}
.status.ok{ border-color:#1a6c44; background:#10231a }
.status.warn{ border-color:#5d3a1a; background:#2a1f12 }
.status.err{ border-color:#5d1a2b; background:#2a121a }
.status .dot{
  width:8px;
  height:8px;
  border-radius:50%;
  background:#2bd576;
}
.status.warn .dot{ background:#ffad3b }
.status.err .dot{ background:#ff5e7a }

.actions{ display:flex; gap:8px }
.link{ color:#cfe0ff; cursor:pointer }

/* Modal */
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:50;
}
.modal{
  width:min(640px, 92vw);
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:16px;
  box-shadow:0 20px 60px rgba(0,0,0,.45);
}
.modal .hdr{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:10px;
}
.modal .grid2{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}
@media (max-width:720px){ .modal .grid2{ grid-template-columns:1fr } }
.errtxt{ color:#ff8fa1; font-size:12px }

/* Confirm modal */
.cmodal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.5);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:55;
}
.cmodal{
  width:min(460px,92vw);
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:16px;
  box-shadow:0 20px 60px rgba(0,0,0,.45);
}
.cmodal .hdr{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:8px;
}
.cmodal .body{ color:#cfe0ff; font-size:14px }
.cmodal .row-right{
  display:flex;
  gap:8px;
  justify-content:flex-end;
  margin-top:16px;
}
.btn.danger{ background:#8b1e2b; border-color:#8b1e2b }
.btn.danger:hover{ background:#a22332 }
.link.danger{ color:#ff6b6b; font-weight:600; }
.link.danger:hover{ color:#ff4040; text-decoration: underline; }

.table td.actions{ white-space: nowrap; }
.table th, .table td{ vertical-align: middle; }

/* === Chat (naujas) === */
.chat {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 12px;
}

.chat-hdr {
  display: flex; align-items: center; justify-content: space-between;
}
.ws-chip {
  display:inline-flex; align-items:center; gap:8px;
  padding:4px 10px; border:1px solid var(--border);
  border-radius:999px; background:var(--card-2); font-size:12px;
}
.ws-chip .dot { width:8px; height:8px; border-radius:50%; background:#666; }
.ws-chip.ok .dot { background:#2bd576; }
.ws-chip.err .dot { background:#ff5e7a; }

.chat-summary {
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--card);
  padding:10px;
  font-size:14px;
  color:var(--muted);
}

.chat-body {
  height: 420px;
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--card);
  padding:12px;
  overflow:auto;
}
.msg { margin-bottom:10px; }
.msg .who { color:var(--muted); margin-right:6px; }
.msg .text { white-space:pre-wrap; }

.chat-footer {
  display:flex;
  gap:10px;
  align-items:flex-end;
}
.chat-footer .input {
  min-height: 44px;
  resize: vertical;
  flex:1;
}
.chat-actions {
  display:flex;
  flex-direction:column;
  gap:8px;
  width:140px;
}

.voicebar {
  display:flex;
  align-items:center;
  gap:8px;
}
.voicebar audio { width: 100%; }

#chat-summary .muted { opacity:.75; font-size:.9em; }
#chat-summary ul { padding-left: 1.2rem; }

#talk-search-bar { background:#0b0e1a; padding:4px 6px; border-radius:8px; }
#talk-search { border:1px solid #333; background:#161a2a; color:#eee; }
#talk-search-btn:hover { background:#2d3a6a; }

/* Audio fix */
.chat .chat-summary {
  position: relative;
  z-index: 5;
}
.chat .chat-summary * {
  pointer-events: auto;
}
.chat .typing,
.chat .muted {
  pointer-events: none;
}
.chat .chat-body {
  position: relative;
  z-index: 1;
}

#talk-finalize-full.disabled,
#talk-finalize-full[disabled] { opacity:.6; cursor:not-allowed; }
#talk-finalize-full.busy::after {
  content:'…';
  margin-left:.35rem;
  animation: blink 1.2s steps(1) infinite;
}
@keyframes blink { 50% { opacity:.3; } }

/* Settings page */
.settings-page{
  max-width: 960px;
  margin: 0 auto 32px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.row-right{
  display:flex;
  justify-content:flex-end;
  gap:8px;
}

/* ====== Toast ====== */
.toast-stack{
  position:fixed;
  right:16px;
  bottom:16px;
  display:flex;
  flex-direction:column;
  gap:8px;
  z-index:60;
}
.toast{
  min-width:260px;
  max-width:420px;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--card);
  box-shadow:0 10px 30px rgba(0,0,0,.35);
  font-size:14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  opacity:0;
  transform:translateY(8px);
  animation:toast-in .2s ease-out forwards;
}
.toast.ok{border-color:#1a6c44; background:#10231a}
.toast.err{border-color:#5d1a2b; background:#2a121a}
.toast.warn{border-color:#5d3a1a; background:#2a1f12}
.toast .msg{color:#cfe0ff}
.toast .x{cursor:pointer; opacity:.7}
@keyframes toast-in{to{opacity:1; transform:translateY(0)}}

/* ====== Mobile layout (drawer) ====== */
@media (max-width: 960px) {
  .menu-toggle{
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }

  .app{
    display:block;
    min-height: calc(100vh - 56px);
  }

  nav.sidenav{
    position:fixed;
    top:56px;
    left:0;
    bottom:0;
    width:260px;
    max-width:80%;
    height:auto;
    transform:translateX(-100%);
    transition: transform 0.25s ease-out;
    z-index:90;
    box-shadow:4px 0 12px rgba(0,0,0,0.4);
  }

  body.nav-open nav.sidenav{
    transform:translateX(0);
  }

  .nav-backdrop{
    position:fixed;
    top:56px;
    left:0;
    right:0;
    bottom:0;
    background:rgba(0,0,0,0.45);
    display:none;
    z-index:80;
  }

  body.nav-open .nav-backdrop{
    display:block;
  }

  main.content,
  .main{
    padding:12px;
  }

  .row{
    flex-wrap:wrap;
  }

  table.table{
    display:block;
    width:100%;
    overflow-x:auto;
  }
}

/* === Real-time audio recording bar (global) === */
.recording-bar {
  display:flex;
  align-items:center;
  justify-content:flex-start;
  gap:12px;
  background:#151a32;
  border:1px solid var(--border);
  border-radius:12px;
  padding:8px 12px;
  margin-top:6px;
  animation: recFadeIn .25s ease-out;
}

@keyframes recFadeIn{
  from{opacity:0; transform:translateY(4px);}
  to  {opacity:1; transform:translateY(0);}
}

/* pats waveform canvas */
#recording-canvas{
  display:block;
  width:100%;
  height:40px;
  background:#0b1020;
  border-radius:8px;
}

/* tekstas šalia */
.recording-bar .muted.small{
  font-size:12px;
  opacity:.85;
  white-space:nowrap;
}

/* ====== Utility stack helperiai (naudojami ir auth) ====== */
.vstack{
  display:flex;
  flex-direction:column;
}
.gap8{ gap:8px; }
.gap12{ gap:12px; }

/* ====== Auth (login) page ====== */
/* ====== Auth (login) layout ====== */
body.auth-body{
  margin:0;
  min-height:100vh;
  background:var(--bg);
  color:var(--text);
  font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
}

.auth-main{
  max-width:880px;
  margin:40px auto;
  padding:0 16px;
  display:flex;
  justify-content:center;
}

.auth-card{
  width:100%;
  border-radius:16px;
  border:1px solid var(--border);
  background:var(--card);
  box-shadow:0 18px 40px rgba(0,0,0,.35);
  padding:20px 20px 18px;
}

.auth-title{
  margin:0 0 4px;
  font-size:20px;
}
.auth-subtitle{
  margin:0;
  font-size:14px;
}

/* Helperiai */
.vstack{
  display:flex;
  flex-direction:column;
}
.gap8{ gap:8px; }

/* Dvi formos */
.auth-forms{
  display:flex;
  flex-wrap:wrap;
  gap:16px;
  margin-top:12px;
}
.auth-form{
  flex:1 1 260px;
}
.auth-form h3{
  margin:0 0 6px;
  font-size:15px;
}
.auth-form label{
  font-size:13px;
}

/* „arba“ */
.auth-divider{
  margin:18px 0 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-size:13px;
  color:var(--muted);
}
.auth-divider::before,
.auth-divider::after{
  content:"";
  flex:1;
  height:1px;
  background:var(--border);
}

/* Google mygtukas */
.auth-google-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  width:100%;
  border-radius:999px;
  margin-bottom:10px;
}
.auth-google-btn svg{
  flex-shrink:0;
}

/* Kalbos pasirinkimas po Google */
.auth-lang-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
  font-size:14px;
}
.auth-lang-label{
  display:flex;
  align-items:center;
  gap:6px;
}

.auth-lang-select{
  max-width:180px;
  border-radius:999px;
  padding:4px 10px;
}
.auth-lang-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
  font-size:14px;
}

.auth-lang-label{
  display:flex;
  align-items:center;
  gap:8px;
}

/* Bendra vėliavėlės „dėžutė“ */
.auth-lang-flag{
  width:24px;
  height:16px;
  border-radius:3px;
  border:1px solid rgba(0,0,0,.5);
  box-shadow:0 0 0 1px rgba(255,255,255,.08);
  background-size:100% 100%;
  background-repeat:no-repeat;
  flex-shrink:0;
}

/* Lietuva – geltona / žalia / raudona */
.auth-flag-lt{
  background-image:linear-gradient(
    to bottom,
    #f6d435 0 33%,
    #118a3b 33% 66%,
    #c12026 66% 100%
  );
}

/* JAV (EN) – stilizuotas variantas */
.auth-flag-en{
  background-image:
    /* juostos */
    linear-gradient(
      to bottom,
      #b22234 0 14%,
      #ffffff 14% 28%,
      #b22234 28% 42%,
      #ffffff 42% 56%,
      #b22234 56% 70%,
      #ffffff 70% 84%,
      #b22234 84% 100%
    );
  position:relative;
}
.auth-flag-en::before{
  content:"";
  position:absolute;
  left:0;
  top:0;
  width:55%;
  height:55%;
  background:#1f3c88;
  border-radius:2px 0 2px 0;
}

/* Mažas info langelis */
.auth-note{
  margin-top:4px;
  padding:8px 10px;
  border-radius:10px;
  background:rgba(11,16,32,.85);
  border:1px dashed var(--border);
  font-size:12px;
  color:var(--muted);
}

/* Mobile */
@media (max-width:640px){
  .auth-main{
    margin:20px auto;
  }
  .auth-card{
    padding:16px 14px 14px;
  }
  .auth-forms{
    flex-direction:column;
  }
  .auth-lang-row{
    flex-direction:column;
    align-items:flex-start;
  }
  .auth-lang-select{
    width:100%;
    max-width:none;
  }
}
