/* KidWatch – panel rodzica. Paleta wg walidowanego zestawu referencyjnego. */

:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;
  --status-good:    #0ca30c;
  --status-critical:#d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255, 255, 255, 0.10);
    --series-1:       #3987e5;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--text-muted); }
.error { color: var(--status-critical); }
code {
  background: var(--gridline);
  padding: 0 4px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* --- logowanie --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: min(340px, 90vw);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }

/* --- układ --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h1 { margin: 0; font-size: 20px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.agent-status { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text-secondary); }
.agent-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-muted); }
.agent-status.online .dot { background: var(--status-good); }
.agent-status.offline .dot { background: var(--status-critical); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.card h2 { margin: 0 0 10px; font-size: 16px; }

/* --- kafelki --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.tile-label { font-size: 13px; color: var(--text-secondary); }
.tile-value { font-size: 30px; font-weight: 650; margin-top: 2px; }
.tile-sub { font-size: 12px; margin-top: 2px; }
.tile-state { font-size: 20px; }
.tile-state.ok { color: var(--status-good); }
.tile-state.blocked { color: var(--status-critical); }

/* --- przyciski --- */
.btn {
  font: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  cursor: pointer;
}
.btn:hover { border-color: var(--baseline); }
.btn-primary {
  background: var(--series-1);
  border-color: var(--series-1);
  color: #fff;
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-ghost:hover { border-color: var(--border); }
.btn-small { padding: 4px 10px; font-size: 13px; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.custom-extra { display: inline-flex; gap: 6px; align-items: center; }
.custom-extra input { width: 80px; }

input, textarea, select {
  font: inherit;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--text-primary);
}
textarea { width: 100%; resize: vertical; margin-bottom: 10px; }

.save-status { margin-left: 10px; font-size: 14px; color: var(--status-good); }

/* --- prośby --- */
.badge {
  background: var(--status-critical);
  color: #fff;
  font-size: 12px;
  border-radius: 10px;
  padding: 1px 8px;
  vertical-align: middle;
}
.request-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--gridline);
}
.request-row:first-child { border-top: none; }
.request-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.request-status { font-size: 13px; margin-left: auto; }
.request-status.approved { color: var(--status-good); }
.request-status.denied { color: var(--status-critical); }

/* --- wykres --- */
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; }
.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  z-index: 20;
  white-space: nowrap;
}
.chart-tooltip .tt-value { font-weight: 650; }
.table-view { margin-top: 8px; font-size: 14px; }
.table-view table { border-collapse: collapse; margin-top: 8px; }
.table-view td, .table-view th {
  padding: 4px 12px 4px 0;
  text-align: left;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}

/* --- aktywność --- */
.apps-list { display: flex; flex-direction: column; gap: 8px; }
.app-row {
  display: grid;
  grid-template-columns: minmax(90px, 160px) 1fr auto;
  align-items: center;
  gap: 10px;
}
.app-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-bar-track {
  background: var(--gridline);
  border-radius: 5px;
  height: 10px;
  overflow: hidden;
}
.app-bar { height: 100%; background: var(--series-1); border-radius: 5px; }
.app-time {
  font-size: 13px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.activity-heading { font-size: 14px; margin: 16px 0 6px; color: var(--text-secondary); }
.activity-list { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.act-row {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--gridline);
  font-size: 14px;
  align-items: baseline;
}
.act-row:first-child { border-top: none; }
.act-time { color: var(--text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.act-app { font-weight: 600; flex-shrink: 0; }
.act-title { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- harmonogram --- */
.schedule-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.schedule-table th {
  text-align: left;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--gridline);
}
.schedule-table td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--gridline); }
.schedule-table input[type="number"] { width: 80px; }
.schedule-table input.windows-input { width: 100%; min-width: 180px; }

@media (max-width: 560px) {
  .tile-value { font-size: 24px; }
  .schedule-table, .schedule-table tbody, .schedule-table tr, .schedule-table td { display: block; }
  .schedule-table thead { display: none; }
  .schedule-table tr { padding: 8px 0; border-bottom: 1px solid var(--gridline); }
  .schedule-table td { border: none; padding: 2px 0; }
}
