/* OneDrone admin app — base layout + shared components. */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--mono); font-size: .92em; }

/* scrollbars (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-2); }

/* ── Layout ─────────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}
.brand {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 22px 12px;
  border-bottom: 1px solid var(--border);
}
.brand img { width: 100%; max-width: 150px; height: auto; display: block; }
.brand small {
  font-weight: 600; font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 2.5px;
}

.nav { padding: 10px 8px; overflow-y: auto; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-bg); color: var(--accent); }
.nav a.active svg { opacity: 1; }
.nav .sep { margin: 10px 10px 6px; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }

.sidebar .foot {
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted);
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 90;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
}
.topbar .search { flex: 0 1 340px; position: relative; }
.topbar .search input {
  width: 100%; padding: 7px 12px 7px 32px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font: inherit;
}
.topbar .search input:focus { outline: none; border-color: var(--border-2); }
.topbar .search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted);
}
.topbar .spacer { flex: 1; }

.conn { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.conn .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.conn.online .dot { background: var(--ok); animation: pulse 2s infinite; }
.conn.offline .dot { background: var(--crit); }

.alertbell { position: relative; display: flex; align-items: center; color: var(--text-2); }
.alertbell svg { width: 19px; height: 19px; }
.alertbell .cnt {
  position: absolute; top: -6px; right: -8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--crit); color: #fff;
  border-radius: 8px; font-size: 10.5px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
}
.alertbell.has .cnt { display: flex; }

.userchip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; font-size: 12.5px; color: var(--text-2);
}
.userchip .avatar {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-3); color: var(--text);
  display: grid; place-items: center; font-size: 10.5px; font-weight: 700;
}

.content { padding: 20px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 19px; font-weight: 700; }
.page-head .sub { color: var(--text-2); font-size: 13px; }

/* ── Components ─────────────────────────────────────────── */
.card {
  background: rgba(18, 27, 45, .90);   /* rahlo prosojno, da foto ozadje diha */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card .card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
}
.card .card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }

/* status badge with pulsing dot */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok     { background: var(--ok-bg);     color: var(--ok); }
.badge.active { background: var(--active-bg); color: var(--active); }
.badge.warn   { background: var(--warn-bg);   color: var(--warn); }
.badge.crit   { background: var(--crit-bg);   color: var(--crit); }
.badge.muted  { background: var(--surface-2); color: var(--text-2); }
.badge.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; font-size: 13px;
  cursor: pointer;
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--active); border-color: var(--active); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--crit-bg); border-color: var(--crit); color: var(--crit); }
.btn.danger:hover { background: var(--crit); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 9px 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: rgba(255, 255, 255, .015); }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea {
  padding: 8px 10px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--border-2);
}

/* kv grid (telemetry) */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kv .item { background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; }
.kv .item .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.kv .item .v { font-size: 14.5px; font-weight: 600; margin-top: 2px; font-family: var(--mono); }

/* console */
.console {
  background: #070d19; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-family: var(--mono); font-size: 12px;
  color: var(--text-2); overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

/* empty state */
.empty {
  padding: 40px 20px; text-align: center; color: var(--muted);
}
.empty .icon { font-size: 26px; margin-bottom: 8px; opacity: .6; }
.empty .hint { font-size: 12.5px; margin-top: 4px; }

/* modal */
.modal-back {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(4, 8, 16, .62); backdrop-filter: blur(3px);
  display: none; place-items: center; padding: 20px;
}
.modal-back.open { display: grid; }
.modal { width: min(520px, 94vw); max-height: 90vh; overflow-y: auto; padding: 22px; }
.modal h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.modal .modal-sub { font-size: 12px; color: var(--muted); margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px;
  color: var(--text-2); margin-bottom: 12px; }
.check input { width: 15px; height: 15px; accent-color: var(--active); }

/* toast */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 10px 18px; font-size: 13px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 999;
}
#toast.show { opacity: 1; }
