/* Paleta i podstawy przejete z github.com/zbigniew73/cdn-caddy (web/style.css) */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #dde3e8;
  --text: #1a2530;
  --muted: #6b7a86;
  --accent: #12a594;
  --accent2: #155e75;
  --danger: #c0392b;
  --ok: #1e8e5a;
  --warn: #b8860b;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10171d;
    --panel: #17212b;
    --border: #26333d;
    --text: #e7edf2;
    --muted: #8a9aa6;
  }
}

:root[data-theme="dark"] {
  --bg: #10171d;
  --panel: #17212b;
  --border: #26333d;
  --text: #e7edf2;
  --muted: #8a9aa6;
}

* { box-sizing: border-box; }

/* Elementy z atrybutem hidden musza zniknac, niezaleznie od tego, co inne
   reguly (np. .screen, #app) ustawiaja na display - inaczej logowanie,
   zmiana hasla i dashboard pokazuja sie jednoczesnie. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}

button {
  font-family: var(--sans);
  cursor: pointer;
}

#auth-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
}

.login-box h1 {
  font-size: 18px;
  margin: 0 0 20px;
}

.login-box .hint {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.5;
}

.login-box label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.login-box button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: -4px 0 8px;
}

.success-msg {
  color: var(--ok);
  font-size: 13px;
  min-height: 18px;
  margin: -4px 0 8px;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

header h1 { font-size: 16px; margin: 0; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.user-email {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
}

.secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
}

.secondary.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.secondary.danger:hover {
  background: #a5311f;
}

.lang-switch-group {
  font-size: 12px;
}

.lang-sep {
  color: var(--muted);
}

.lang-switch {
  color: var(--muted);
  cursor: pointer;
}

.lang-switch.active {
  color: var(--accent);
  font-weight: 600;
  cursor: default;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

main { flex: 1; display: flex; min-height: 0; }

nav {
  width: 200px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 16px 0;
  background: var(--panel);
}

.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px 20px;
  margin-bottom: 4px;
}

.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 10px 20px;
  font-size: 14px;
  text-align: left;
}

.tab:hover { background: var(--bg); }
.tab.active { background: var(--bg); color: var(--accent); font-weight: 600; border-right: 2px solid var(--accent); }

.content { flex: 1; padding: 24px; overflow-y: auto; }

.app-footer {
  padding: 8px 20px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  text-align: right;
}

.panel-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 16px;
  max-width: 720px;
}

.panel-block h2 {
  font-size: 14px;
  margin: 0 0 12px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.card button.lua-example {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  color: inherit;
  border: none;
  border-radius: 0;
  padding: 4px 0;
  margin-bottom: 6px;
  font-size: inherit;
  font-weight: normal;
  cursor: pointer;
  font-family: var(--sans);
}

.lua-example .lua-example-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.lua-example .lua-example-code {
  display: block;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  word-break: break-all;
}

.lua-example:hover .lua-example-code {
  color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .lua-example .lua-example-code,
  :root:not([data-theme="light"]) .lua-example:hover .lua-example-code {
    color: #ffffff;
  }
}

:root[data-theme="dark"] .lua-example .lua-example-code,
:root[data-theme="dark"] .lua-example:hover .lua-example-code {
  color: #ffffff;
}

table.zones {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.zones th, table.zones td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}

table.zones td:last-child {
  white-space: nowrap;
  word-break: normal;
}

table.zones th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}

#zone-records-table th:nth-child(1),
#zone-records-table td:nth-child(1) {
  min-width: 220px;
}

#zone-records-table th:nth-child(2),
#zone-records-table td:nth-child(2) {
  min-width: 130px;
}

#zone-records-table th:nth-child(3),
#zone-records-table td:nth-child(3) {
  min-width: 130px;
}

table.zones td .secondary {
  padding: 4px 8px;
  font-size: 12px;
  margin-right: 4px;
}

#zone-editor .card + .card {
  margin-top: 16px;
}

.zone-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.zone-editor-header h2 { margin: 0; }

.system-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}

.stat-tile .stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.stat-tile .stat-value {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
}

.meter-track {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.meter-fill { height: 100%; border-radius: 4px; }
.meter-fill.good { background: var(--accent); }
.meter-fill.warning { background: var(--warn); }
.meter-fill.critical { background: var(--danger); }

.stat-tile .stat-detail {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.grid.settings-row-2 {
  margin-top: 16px;
}

.grid .card-full {
  grid-column: 1 / -1;
}

#zones-overview {
  grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 640px) {
  #zones-overview {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
}

.card h2 {
  font-size: 14px;
  margin: 0 0 14px;
}

.card hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.card .info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.card .info-row:last-child { border-bottom: none; }
.card .info-row .info-label { color: var(--muted); }

.field {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.field-input {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}

textarea.field-input {
  resize: vertical;
}

.card button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
}

.server-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.server-row:last-child { border-bottom: none; }

.server-row .server-name { font-weight: 600; }

.server-row .server-address {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.flag-icon {
  width: 16px;
  height: 12px;
  vertical-align: middle;
  border-radius: 2px;
  margin-left: 4px;
  margin-right: 4px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.primary { background: rgba(18, 165, 148, 0.15); color: var(--accent); }
.badge.secondary { background: rgba(184, 134, 11, 0.15); color: var(--warn); }
.badge.online { background: rgba(30, 142, 90, 0.15); color: var(--ok); }
.badge.offline { background: rgba(192, 57, 43, 0.15); color: var(--danger); }
.badge.unknown { background: rgba(107, 122, 134, 0.15); color: var(--muted); }
