/* SecOps CIDR Manager - design tokens & shared styles */
:root {
  --color-bg: #f2f4f7;
  --color-surface: #ffffff;
  --color-surface-alt: #f8f9fb;
  --color-border: #dde2e8;
  --color-text: #1c2530;
  --color-text-muted: #5b6775;
  --color-primary: #1c5fa8;
  --color-primary-dark: #164a84;
  --color-primary-contrast: #ffffff;
  --color-danger: #c0341f;
  --color-danger-bg: #fdecea;
  --color-success: #1f7a3f;
  --color-success-bg: #e8f6ec;
  --color-warning-bg: #fff6e0;
  --color-warning-text: #8a5b00;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 45, 0.08);
  --shadow-md: 0 4px 16px rgba(20, 30, 45, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--color-primary); }

button { font-family: inherit; }

/* ---------- Auth pages (login / access denied) ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }

.auth-shell {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 32px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
}

.auth-brand h1 { font-size: 16px; margin: 0; }
.auth-brand p { font-size: 12px; color: var(--color-text-muted); margin: 2px 0 0; }

.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 12px; font-weight: 600; color: var(--color-text-muted); margin-top: 10px; }
.auth-form input { padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 14px; }
.auth-form input:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.auth-form .btn { margin-top: 18px; }

.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--color-text-muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--color-border); }
.auth-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 8px; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--color-primary); color: var(--color-primary-contrast); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-alt); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a02c1a; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-icon { padding: 6px 8px; }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }

/* ---------- App shell ---------- */
.app-topbar {
  height: 56px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  max-width: 1024px;
  margin: 0 auto;
}

.app-topbar-brand {
  display: flex; align-items: center; gap: 10px; font-weight: 700;
  background: none; border: none; cursor: pointer; color: var(--color-text); padding: 6px 4px; border-radius: 6px;
  font-size: 14px; font-family: inherit; flex: none;
}
.app-topbar-brand:hover { background: var(--color-surface-alt); }
.app-topbar-brand .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--color-primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none;
}

.topbar-search { flex: 1; display: flex; justify-content: center; padding: 0 20px; min-width: 0; }
.topbar-search-inner { position: relative; width: 100%; max-width: 480px; }
.topbar-search input {
  width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--color-border); border-radius: 999px;
  font-size: 13.5px; background: var(--color-surface-alt); color: var(--color-text);
}
.topbar-search input:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; background: var(--color-surface); }
.topbar-search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--color-text-muted); font-size: 13px; pointer-events: none;
}

.user-menu { position: relative; }

.user-menu-button {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  border: none; cursor: pointer; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: 44px;
  width: 260px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 8px;
  display: none;
  z-index: 30;
}
.user-menu-dropdown.open { display: block; }

.user-menu-header { padding: 10px 12px 12px; border-bottom: 1px solid var(--color-border); margin-bottom: 8px; }
.user-menu-header .name { font-weight: 700; font-size: 14px; }
.user-menu-header .meta { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }

.user-menu-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); padding: 8px 12px 4px; }

.user-menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 6px; cursor: pointer; font-size: 13.5px;
  color: var(--color-text); background: none; border: none; width: 100%; text-align: left;
}
.user-menu-item:hover { background: var(--color-surface-alt); }

.app-shell { display: flex; min-height: calc(100vh - 56px); max-width: 1024px; margin: 0 auto; }

.app-sidebar {
  width: 240px;
  flex: none;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: 16px 10px;
}

.sidebar-section { margin-bottom: 18px; }
.sidebar-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); padding: 4px 10px 8px; }
.sidebar-link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 6px; font-size: 13.5px; color: var(--color-text);
  cursor: pointer; margin-bottom: 2px; background: none; border: none; width: 100%; text-align: left;
}
.sidebar-link:hover { background: var(--color-surface-alt); }
.sidebar-link.active { background: #e7f0fa; color: var(--color-primary-dark); font-weight: 600; }
.sidebar-link .count { color: var(--color-text-muted); font-size: 12px; }

.app-content { flex: 1; padding: 24px 28px; min-width: 0; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-header h2 { margin: 0; font-size: 19px; }
.page-header p { margin: 4px 0 0; color: var(--color-text-muted); font-size: 13px; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-body { padding: 18px 20px; }
.card + .card { margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted); font-weight: 700; }
tbody tr:hover { background: var(--color-surface-alt); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--color-text-muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-on { background: var(--color-success-bg); color: var(--color-success); }
.badge-off { background: var(--color-surface-alt); color: var(--color-text-muted); }
.badge-super { background: #eee6fb; color: #5b2ba8; }

.right-pill-group { display: flex; gap: 4px; flex-wrap: wrap; }
.right-pill { font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--color-surface-alt); color: var(--color-text-muted); }
.right-pill.on { background: #e7f0fa; color: var(--color-primary-dark); }

/* ---------- Forms (in-app, not auth) ---------- */
.form-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-field label { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); }
.form-field input[type="text"], .form-field input[type="password"], .form-field input[type="search"], .form-field select {
  padding: 9px 11px; border: 1px solid var(--color-border); border-radius: 6px; font-size: 13.5px;
  background: var(--color-surface); color: var(--color-text); font-family: inherit;
}
.form-field input:focus, .form-field select:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.form-hint { font-size: 12px; color: var(--color-text-muted); }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 4px 16px; margin: 10px 0; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 22, 32, 0.45);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 60px 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow-md);
  width: 100%; max-width: 460px; padding: 22px;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---------- Toasts ---------- */
#toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: 340px; }
.toast { padding: 12px 14px; border-radius: var(--radius); box-shadow: var(--shadow-md); font-size: 13.5px; }
.toast-success { background: var(--color-success); color: #fff; }
.toast-error { background: var(--color-danger); color: #fff; }

.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input { flex: 1; }

.muted { color: var(--color-text-muted); }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }

/* ---------- Sidebar section header as a link ---------- */
.sidebar-label-link {
  display: block; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted);
  padding: 4px 10px 8px; font-weight: 700; border-radius: 4px;
}
.sidebar-label-link:hover { color: var(--color-primary-dark); background: var(--color-surface-alt); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 13px; }
.pagination .page-info { color: var(--color-text-muted); }
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; align-items: center; }
.filter-row input { flex: 1; max-width: 320px; }

/* ---------- Dashboard: view toggle, bar chart, drilldown ---------- */
.view-toggle { display: inline-flex; border: 1px solid var(--color-border); border-radius: 999px; overflow: hidden; }
.view-toggle button {
  background: var(--color-surface); border: none; padding: 6px 14px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; color: var(--color-text-muted);
}
.view-toggle button.active { background: var(--color-primary); color: #fff; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

.stat-summary { display: flex; gap: 24px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-tile { min-width: 120px; }
.stat-tile .value { font-size: 26px; font-weight: 700; }
.stat-tile .label { font-size: 12px; color: var(--color-text-muted); }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px; border-radius: 6px; }
.bar-row:hover { background: var(--color-surface-alt); }
.bar-row.selected { background: #e7f0fa; }
.bar-row .bar-label { width: 130px; flex: none; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bar-track { flex: 1; height: 16px; background: var(--color-surface-alt); border-radius: 4px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: var(--color-primary); border-radius: 4px; min-width: 2px; }
.bar-row .bar-count { width: 34px; flex: none; text-align: right; font-size: 12.5px; font-weight: 600; }

.drilldown-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.drilldown-header .filter-chip {
  display: inline-flex; align-items: center; gap: 6px; background: #e7f0fa; color: var(--color-primary-dark);
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
}
.drilldown-header .filter-chip button { background: none; border: none; cursor: pointer; color: inherit; font-weight: 700; padding: 0; }

@keyframes highlightFlash {
  0% { background: #fff3c4; }
  100% { background: transparent; }
}
.entry-highlight { animation: highlightFlash 2.2s ease-out; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .app-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); }
  .app-content { padding: 18px; }
  .app-topbar-brand span:last-child { display: none; }
  .topbar-search { padding: 0 8px; }
}
