/* =======================================================================
   Multi-Domain Edge Manager — Flat UI
   Path: /app/web/static/styles.css
   ======================================================================= */

/* ----------------------------
   Design tokens (light mode)
   ---------------------------- */
:root {
  /* Layout */
  --container-max: 1100px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* Colors */
  --bg: #f7f7fb;
  --bg-elev: #ffffff;
  --text: #1b1f24;
  --text-muted: #6b7280;
  --border: #e5e7eb;

  --primary: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-contrast: #ffffff;
  --primary-soft: rgba(59,130,246,.12);

  --success: #16a34a;
  --warning: #f59e0b;
  --danger:  #dc2626;
  --info:    #0ea5e9;

  --success-weak: #eaf7ef;
  --warning-weak: #fff7e6;
  --danger-weak:  #fdecec;
  --info-weak:    #e6f6fd;

  /* Effects */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 6px 20px rgba(0,0,0,.08);
  --ring: 0 0 0 3px rgba(59,130,246,.25);

  /* Table */
  --table-head: #f2f4f8;
}

/* ----------------------------
   Dark mode
   ---------------------------- */
@media (prefers-color-scheme: dark) {
  :root{
    --bg: #0f1115;
    --bg-elev: #151922;
    --text: #e5e7eb;
    --text-muted: #9aa4b2;
    --border: #2a2f3a;

    --primary: #60a5fa;
    --primary-600: #3b82f6;
    --primary-700: #2563eb;
    --primary-contrast: #0b1220;
    --primary-soft: rgba(96,165,250,.15);

    --success: #22c55e;
    --warning: #fbbf24;
    --danger:  #ef4444;
    --info:    #38bdf8;

    --success-weak: rgba(34,197,94,.12);
    --warning-weak: rgba(251,191,36,.12);
    --danger-weak:  rgba(239,68,68,.12);
    --info-weak:    rgba(56,189,248,.12);

    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
    --shadow-md: 0 12px 32px rgba(0,0,0,.4);
    --ring: 0 0 0 3px rgba(96,165,250,.32);

    --table-head: #131722;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ----------------------------
   Base & layout
   ---------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg); /* flat background */
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

main {
  width: min(92vw, var(--container-max));
  margin: 24px auto 64px;
  padding: 0 2px;
  flex: 1;
}

/* ----------------------------
   Header & navigation
   ---------------------------- */
header {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

header h1 {
  width: min(92vw, var(--container-max));
  margin: 0 auto;
  padding: 16px 2px 4px;
  font-size: 1.25rem;
  letter-spacing: .2px;
}

header nav {
  width: min(92vw, var(--container-max));
  margin: 0 auto;
  padding: 8px 2px 14px;
}

header nav a {
  display: inline-block;
  margin-right: 14px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: background .2s ease, color .2s ease, transform .06s ease;
}

header nav a:hover {
  color: var(--text);
  background: var(--primary-soft);
}

header nav a:active { transform: translateY(1px); }

/* ----------------------------
   Flash messages / alerts
   ---------------------------- */
.flash-container { margin: 8px 0 2px; }

.alert {
  position: relative;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
}

.alert-success { background: var(--success-weak); border-color: var(--success); }
.alert-info    { background: var(--info-weak);    border-color: var(--info); }
.alert-warning { background: var(--warning-weak); border-color: var(--warning); }
.alert-error,
.alert-danger  { background: var(--danger-weak);  border-color: var(--danger); }

/* ----------------------------
   Buttons
   ---------------------------- */
.btn,
button,
input[type="submit"] {
  --btn-bg: var(--bg-elev);
  --btn-fg: var(--text);
  --btn-border: var(--border);

  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
  box-shadow: var(--shadow-sm);
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
  box-shadow: var(--shadow-md);
}

.btn:active,
button:active,
input[type="submit"]:active { transform: translateY(1px); }

/* Variants — flat fills, no gradients */
.btn-primary {
  --btn-bg: var(--primary);
  --btn-fg: var(--primary-contrast);
  --btn-border: var(--primary);
}
.btn-primary:hover { filter: brightness(1.02); }

.btn-secondary {
  --btn-bg: var(--primary-soft);
  --btn-fg: var(--primary-700);
  --btn-border: rgba(59,130,246,.25);
}

.btn-danger  { --btn-bg: var(--danger);  --btn-fg: #fff; --btn-border: var(--danger); }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-border: var(--success); }

.btn-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-600);
  box-shadow: none;
}
.btn-link:hover { text-decoration: underline; }

/* Keyboard focus */
:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 8px;
}

/* ----------------------------
   Forms
   ---------------------------- */
form { display: block; }

label {
  display: inline-block;
  margin: 10px 0 6px;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: min(560px, 100%);
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-600);
  box-shadow: var(--ring);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  accent-color: var(--primary);
}

/* Login box */
.form-box {
  width: min(460px, 100%);
  margin: 12px 0;
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Login page specific styles */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

body.login-page main {
  margin: 0;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

body.login-page h2 {
  text-align: center;
  margin-bottom: 24px;
  font-size: 1.5rem;
}
.form-group { margin-bottom: 12px; }
.form-group.checkbox label { font-weight: 500; }

/* ----------------------------
   Tables
   ---------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden; /* enables rounded corners */
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
}

thead th {
  background: var(--table-head); /* flat header */
  color: var(--text);
  text-align: left;
  padding: 12px;
  font-size: .95rem;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:hover { background: var(--primary-soft); }

.muted {
  color: var(--text-muted) !important;
  opacity: .7;
  user-select: text; /* Allow text selection */
}

.muted a,
.muted button,
.muted input,
.muted select,
.muted textarea {
  pointer-events: none; /* Prevent clicks on interactive elements */
  cursor: default;
}

/* Make tables scroll on small screens */
@media (max-width: 720px) {
  table { display: block; overflow-x: auto; white-space: nowrap; }
}


/* ----------------------------
   Cards (optional utility)
   ---------------------------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

/* ----------------------------
   Links & typography
   ---------------------------- */
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }

pre, code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

h1, h2, h3 { line-height: 1.2; margin: 0.25em 0 0.35em; }
p { margin: 0.4em 0 0.8em; }

/* ----------------------------
   Text truncation utilities
   ---------------------------- */
.text-truncate {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
  display: block;
}

.text-truncate:hover {
  overflow: visible;
  white-space: normal;
  word-break: break-all;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  position: absolute;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  max-width: 400px;
  min-width: 200px;
}


/* ----------------------------
   Spacing utilities
   ---------------------------- */
.mt-0{margin-top:0}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}
.p-0{padding:0}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}


/* ----------------------------
   Footer
   ---------------------------- */
footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  margin-top: 36px;
}
.footer-container {
  width: min(92vw, var(--container-max));
  margin: 0 auto;
  padding: 14px 2px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-sep { margin: 0 8px; opacity: .6; }
footer a { color: var(--primary-600); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* Network Visualization Styles */
.network-graph svg {
  display: block;
  margin: 0 auto;
  background-color: var(--bg-elev);
}

.network-graph text {
  fill: var(--text);
  font-size: 12px;
  pointer-events: none;
}

.network-graph circle {
  stroke: var(--bg-elev);
  stroke-width: 2px;
  cursor: grab;
}

.network-graph circle:hover {
  stroke-width: 3px;
}

.network-graph line {
  stroke: var(--border);
}

/* Dashboard Specific Styles */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.stat-card {
  background-color: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 5px;
}

.stat-label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.visualization-container {
  background-color: var(--bg-elev);
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 30px 0;
  box-shadow: var(--shadow-sm);
}

.visualization-container h3 {
  margin-top: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

.overview-tables {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 30px;
  margin: 30px 0;
}

.table-container {
  background-color: var(--bg-elev);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.table-container h3 {
  margin-top: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

@media (max-width: 768px) {
  .overview-tables {
    grid-template-columns: 1fr;
  }
}
