/* RUNOM Console (ADR-0031) — arkusz zewnętrzny WYŁĄCZNIE (CSP: style-src 'self',
   celowo bez 'unsafe-inline' — zero atrybutów style="" i bloków <style> w JS). */

:root {
  --bg: #15171b;
  --bg-elevated: #1c1f25;
  --bg-hover: #262a32;
  --bg-input: #20232a;
  --border: #2d323b;
  --text: #e8eaed;
  --text-muted: #9aa1ac;
  --accent: #e0752c;
  --accent-contrast: #16110a;
  --accent-hover: #ef8438;
  --success: #3fae5c;
  --warning: #d9a441;
  --danger: #e0524a;
  --danger-hover: #ef655c;
  --focus: #6fb2ff;
  --radius: 8px;
  --radius-sm: 4px;
  color-scheme: dark;
}

:root[data-theme='light'] {
  --bg: #f4f5f7;
  --bg-elevated: #ffffff;
  --bg-hover: #eceef2;
  --bg-input: #ffffff;
  --border: #d7dbe1;
  --text: #1b1d21;
  --text-muted: #5b6270;
  --accent: #c8611c;
  --accent-contrast: #ffffff;
  --accent-hover: #b3560f;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, Cantarell, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

#app {
  height: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  .fade-in {
    animation: fade-in 120ms ease-out;
  }
}
@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

a,
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* === Ekran logowania === */
.login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.login-wordmark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}
.login-wordmark .accent {
  color: var(--accent);
}
.login-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
}
.field textarea {
  resize: vertical;
  min-height: 72px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 600;
  font-size: 14px;
}
.btn:hover {
  background: var(--bg-elevated);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}
.btn-block {
  width: 100%;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

/* === Powłoka aplikacji === */
.shell {
  display: grid;
  grid-template-columns: 250px 1fr 320px;
  height: 100vh;
}
.sidebar,
.rightpanel {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px;
}
.rightpanel {
  border-right: none;
  border-left: 1px solid var(--border);
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.brand {
  font-weight: 700;
  font-size: 16px;
  padding: 8px 8px 16px;
}
.brand .accent {
  color: var(--accent);
}
.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 16px 8px 6px;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-item button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
}
.nav-item button:hover {
  background: var(--bg-hover);
}
.nav-item.active button {
  background: var(--bg-hover);
  color: var(--accent);
  font-weight: 600;
}
.project-select,
.provider-select {
  width: 100%;
  margin-bottom: 8px;
}
.conv-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item:hover,
.conv-item.active {
  background: var(--bg-hover);
  color: var(--text);
}

.screen {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* === Rozmowa === */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 760px;
  margin: 0 auto 16px;
}
.msg {
  border-radius: var(--radius);
  padding: 12px 14px;
  max-width: 100%;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg-user {
  background: var(--bg-hover);
  align-self: flex-end;
  margin-left: 20%;
}
.msg-assistant {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.msg-context {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 13px;
}
.msg-error {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}
.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.msg-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.msg-actions button {
  font-size: 12px;
  padding: 4px 8px;
}
.proposed-memory-card {
  margin-top: 10px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--bg-hover);
}
.proposed-memory-card .label {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 6px;
}

.composer {
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  gap: 8px;
  padding: 12px 0 4px;
  border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 160px;
}

/* === Karty i listy ogólne === */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card-title {
  font-weight: 600;
  margin-bottom: 4px;
}
.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.badge-current {
  border-color: var(--success);
  color: var(--success);
}
.badge-superseded {
  border-color: var(--text-muted);
}
.badge-disputed {
  border-color: var(--danger);
  color: var(--danger);
}
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}
.toolbar input,
.toolbar select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
}
.status-ok {
  color: var(--success);
}
.status-bad {
  color: var(--danger);
}
.status-unknown {
  color: var(--text-muted);
}

/* === Modal potwierdzenia === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 420px;
  width: 100%;
}
.modal-title {
  font-weight: 700;
  margin-bottom: 8px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* === Ustawienia (tabela klucz/wartość) === */
.kv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}
.kv-table th,
.kv-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-table th {
  color: var(--text-muted);
  font-weight: 500;
  width: 45%;
}

/* === Drawer (mobile) === */
.drawer-backdrop {
  display: none;
}

/* === Responsywność === */
@media (max-width: 900px) {
  .shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
  }
  .topbar {
    display: flex;
  }
  .sidebar,
  .rightpanel {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(84vw, 320px);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 160ms ease-out;
  }
  .rightpanel {
    right: 0;
    left: auto;
    transform: translateX(105%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .rightpanel.open {
    transform: translateX(0);
  }
  .drawer-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 30;
  }
  .msg-user {
    margin-left: 8%;
  }
  .composer {
    padding-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .rightpanel {
    transition: none;
  }
}
