/* gw-intunet panel — overrides + componentes sobre Pico */

:root {
  /* Palette — tech / infra */
  --gw-primary:        #14b8a6;
  --gw-primary-hover:  #0d9488;
  --gw-primary-soft:   color-mix(in srgb, var(--gw-primary) 14%, transparent);
  --gw-success:        #10b981;
  --gw-success-soft:   color-mix(in srgb, var(--gw-success) 14%, transparent);
  --gw-warning:        #f59e0b;
  --gw-warning-soft:   color-mix(in srgb, var(--gw-warning) 14%, transparent);
  --gw-danger:         #ef4444;
  --gw-danger-soft:    color-mix(in srgb, var(--gw-danger) 14%, transparent);
  --gw-muted:          color-mix(in srgb, var(--pico-muted-color) 80%, transparent);

  --gw-radius:         .5rem;
  --gw-shadow-sm:      0 1px 2px 0 rgb(0 0 0 / .04);
  --gw-shadow-md:      0 4px 12px -2px rgb(0 0 0 / .08);

  /* Override pico primary so buttons usen nuestro accent */
  --pico-primary:               var(--gw-primary);
  --pico-primary-background:    var(--gw-primary);
  --pico-primary-border:        var(--gw-primary);
  --pico-primary-hover:         var(--gw-primary-hover);
  --pico-primary-hover-background: var(--gw-primary-hover);
  --pico-primary-hover-border:  var(--gw-primary-hover);
  --pico-primary-focus:         color-mix(in srgb, var(--gw-primary) 25%, transparent);
  --pico-font-family-monospace: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --gw-primary:        #2dd4bf;
    --gw-primary-hover:  #5eead4;
    --gw-shadow-md:      0 4px 12px -2px rgb(0 0 0 / .35);
  }
}

html, body { height: 100%; }
body { padding-bottom: 4rem; }
main.container { padding-top: 1.5rem; }

/* ─── Topbar ──────────────────────────────────────────────────────────── */
.gw-topbar {
  display: flex; align-items: center; gap: 1.25rem;
  padding: .65rem 1.25rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
  background: var(--pico-card-background-color);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.gw-topbar .brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 700; letter-spacing: -.01em;
  color: var(--pico-color); text-decoration: none;
}
.gw-topbar .brand .dot {
  display: inline-block; width: .55rem; height: .55rem; border-radius: 50%;
  background: var(--gw-primary); box-shadow: 0 0 0 3px var(--gw-primary-soft);
}
.gw-topbar nav { display: flex; gap: .25rem; flex: 1; margin-left: 1rem; }
.gw-topbar nav a {
  color: var(--pico-color); text-decoration: none;
  padding: .4rem .85rem; border-radius: var(--gw-radius);
  font-size: .92rem; transition: background .15s;
}
.gw-topbar nav a:hover { background: var(--pico-secondary-background); }
.gw-topbar nav a.active {
  background: var(--gw-primary-soft);
  color: var(--gw-primary-hover);
  font-weight: 600;
}
.gw-topbar .user {
  display: flex; align-items: center; gap: .65rem; font-size: .85rem;
}
.gw-topbar .user .avatar {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--gw-primary), var(--gw-primary-hover));
  color: white; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .85rem;
}
.gw-topbar .user .meta { display: flex; flex-direction: column; line-height: 1.15; }
.gw-topbar .user .meta strong { font-size: .9rem; }
.gw-topbar .user .meta small { color: var(--gw-muted); }
.gw-topbar form { margin: 0; }
.gw-topbar form button {
  margin: 0; padding: .35rem .75rem; font-size: .82rem;
}

@media (max-width: 720px) {
  .gw-topbar { flex-wrap: wrap; gap: .5rem; padding: .5rem .75rem; }
  .gw-topbar nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .gw-topbar .user .meta { display: none; }
}

/* ─── Page header ─────────────────────────────────────────────────────── */
.gw-pageheader {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.gw-pageheader h2 { margin: 0; }
.gw-pageheader .subtitle { color: var(--gw-muted); font-size: .92rem; margin-top: .25rem; }
.gw-pageheader .actions { display: flex; gap: .5rem; }
.gw-pageheader .actions > * { margin: 0; }

/* ─── Stat cards (dashboard) ──────────────────────────────────────────── */
.gw-stats {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 1.5rem;
}
.gw-stat {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--gw-radius);
  padding: 1rem 1.15rem;
  display: flex; align-items: flex-start; gap: .85rem;
  transition: box-shadow .15s, transform .15s;
}
.gw-stat:hover { box-shadow: var(--gw-shadow-md); transform: translateY(-1px); }
.gw-stat .icon {
  width: 2.4rem; height: 2.4rem; border-radius: var(--gw-radius);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--gw-primary-soft); color: var(--gw-primary-hover);
  flex-shrink: 0;
}
.gw-stat .icon svg { width: 1.3rem; height: 1.3rem; }
.gw-stat .icon.success { background: var(--gw-success-soft); color: var(--gw-success); }
.gw-stat .icon.warning { background: var(--gw-warning-soft); color: var(--gw-warning); }
.gw-stat .icon.danger  { background: var(--gw-danger-soft);  color: var(--gw-danger); }
.gw-stat .body { flex: 1; min-width: 0; }
.gw-stat .label {
  text-transform: uppercase; font-size: .72rem; letter-spacing: .04em;
  color: var(--gw-muted); margin: 0;
}
.gw-stat .value { font-size: 1.85rem; font-weight: 700; line-height: 1.1; margin: .1rem 0 0; }
.gw-stat .sub { color: var(--gw-muted); font-size: .82rem; margin: .15rem 0 0; }

/* ─── Activity feed ───────────────────────────────────────────────────── */
.gw-feed {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--gw-radius);
  padding: 0; overflow: hidden;
}
.gw-feed .header {
  padding: .75rem 1rem; border-bottom: 1px solid var(--pico-muted-border-color);
  display: flex; justify-content: space-between; align-items: center;
}
.gw-feed .header h4 { margin: 0; font-size: .95rem; }
.gw-feed ul { list-style: none; margin: 0; padding: 0; }
.gw-feed li {
  display: grid; grid-template-columns: auto 1fr auto; gap: .75rem;
  padding: .65rem 1rem; align-items: center;
  border-bottom: 1px solid var(--pico-muted-border-color);
  font-size: .87rem;
}
.gw-feed li:last-child { border-bottom: none; }
.gw-feed li .dot {
  width: .55rem; height: .55rem; border-radius: 50%;
  background: var(--gw-muted); flex-shrink: 0;
}
.gw-feed li.kind-ok    .dot { background: var(--gw-success); }
.gw-feed li.kind-warn  .dot { background: var(--gw-warning); }
.gw-feed li.kind-err   .dot { background: var(--gw-danger); }
.gw-feed li.kind-info  .dot { background: var(--gw-primary); }
.gw-feed li .text { color: var(--pico-color); }
.gw-feed li .text strong { font-weight: 600; }
.gw-feed li .ts {
  font-family: var(--pico-font-family-monospace); font-size: .76rem;
  color: var(--gw-muted); white-space: nowrap;
}

/* ─── Tables ──────────────────────────────────────────────────────────── */
.gw-table {
  width: 100%; border-collapse: collapse; font-size: .9rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--gw-radius);
  overflow: hidden;
}
.gw-table th, .gw-table td {
  padding: .65rem .85rem; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.gw-table thead th {
  background: var(--pico-secondary-background);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--gw-muted); font-weight: 600;
}
.gw-table tbody tr:last-child td { border-bottom: none; }
.gw-table tbody tr:hover { background: color-mix(in srgb, var(--gw-primary) 4%, transparent); }
.gw-table td code {
  font-size: .8rem; padding: .1rem .35rem; border-radius: .25rem;
  background: var(--pico-secondary-background);
}
.gw-table td .row-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.gw-table td .row-actions a, .gw-table td .row-actions button {
  margin: 0; padding: .25rem .65rem; font-size: .78rem;
}
.gw-table .empty {
  text-align: center; padding: 2rem 1rem; color: var(--gw-muted);
}

/* ─── Status badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .55rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; line-height: 1.4;
  background: var(--pico-secondary-background); color: var(--pico-color);
}
.badge::before {
  content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor;
}
.badge.ok      { background: var(--gw-success-soft); color: var(--gw-success); }
.badge.warn    { background: var(--gw-warning-soft); color: var(--gw-warning); }
.badge.err     { background: var(--gw-danger-soft);  color: var(--gw-danger); }
.badge.info    { background: var(--gw-primary-soft); color: var(--gw-primary-hover); }
.badge.muted   { background: var(--pico-secondary-background); color: var(--gw-muted); }

/* ─── Forms ───────────────────────────────────────────────────────────── */
form .field-group {
  display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
form fieldset {
  border: 1px solid var(--pico-muted-border-color); border-radius: var(--gw-radius);
  padding: 1rem 1.25rem; margin-bottom: 1rem;
}
form fieldset legend {
  padding: 0 .5rem; font-weight: 600; font-size: .92rem;
}
form .actions { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }
form .actions > * { margin: 0; }
form small { color: var(--gw-muted); }

/* ─── Login ───────────────────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 20% 0%, var(--gw-primary-soft) 0%, transparent 50%),
    radial-gradient(circle at 80% 100%, color-mix(in srgb, var(--gw-primary) 8%, transparent) 0%, transparent 60%);
}
.gw-login {
  max-width: 24rem; width: 100%; padding: 2.25rem 2rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--gw-radius);
  box-shadow: var(--gw-shadow-md);
}
.gw-login .brand {
  display: flex; align-items: center; gap: .5rem; margin-bottom: 1.25rem;
  font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em;
}
.gw-login .brand .dot {
  width: .65rem; height: .65rem; border-radius: 50%;
  background: var(--gw-primary); box-shadow: 0 0 0 4px var(--gw-primary-soft);
}
.gw-login button[type=submit] { width: 100%; margin-top: .25rem; }
.gw-login .footnote { display: block; margin-top: 1.25rem; color: var(--gw-muted); font-size: .8rem; }

/* ─── Flash ───────────────────────────────────────────────────────────── */
.gw-flash {
  display: flex; gap: .65rem; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; border-radius: var(--gw-radius); margin: 0 0 1rem;
  font-size: .9rem;
}
.gw-flash.success { background: var(--gw-success-soft); border-left: 3px solid var(--gw-success); }
.gw-flash.error   { background: var(--gw-danger-soft);  border-left: 3px solid var(--gw-danger); }
.gw-flash.warn    { background: var(--gw-warning-soft); border-left: 3px solid var(--gw-warning); }
.gw-flash a.dismiss { color: inherit; text-decoration: none; opacity: .7; padding: 0 .35rem; }
.gw-flash a.dismiss:hover { opacity: 1; }

/* ─── Toast (HX-Trigger driven) ───────────────────────────────────────── */
#gw-toasts {
  position: fixed; top: 1rem; right: 1rem; z-index: 100;
  display: flex; flex-direction: column; gap: .5rem; max-width: 24rem;
  pointer-events: none;
}
.gw-toast {
  pointer-events: auto;
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-left: 3px solid var(--gw-primary);
  border-radius: var(--gw-radius);
  padding: .65rem .85rem; font-size: .88rem;
  box-shadow: var(--gw-shadow-md);
  animation: gw-toast-in .22s ease-out;
}
.gw-toast.success { border-left-color: var(--gw-success); }
.gw-toast.error   { border-left-color: var(--gw-danger); }
.gw-toast.warn    { border-left-color: var(--gw-warning); }
.gw-toast.fade-out { animation: gw-toast-out .22s ease-in forwards; }
@keyframes gw-toast-in  { from { transform: translateX(.5rem); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes gw-toast-out { to { transform: translateX(.5rem); opacity: 0; } }

/* ─── HTMX indicator ──────────────────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ─── Detalle (definition list) ───────────────────────────────────────── */
.gw-detail {
  background: var(--pico-card-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--gw-radius);
  overflow: hidden; margin-bottom: 1.25rem;
}
.gw-detail dl { margin: 0; }
.gw-detail .row {
  display: grid; grid-template-columns: 12rem 1fr; gap: 1rem;
  padding: .55rem 1rem; align-items: baseline;
  border-bottom: 1px solid var(--pico-muted-border-color);
}
.gw-detail .row:last-child { border-bottom: none; }
.gw-detail dt { color: var(--gw-muted); font-size: .82rem; margin: 0; }
.gw-detail dd { margin: 0; font-family: var(--pico-font-family-monospace); font-size: .87rem; word-break: break-all; }
@media (max-width: 600px) { .gw-detail .row { grid-template-columns: 1fr; gap: .15rem; } }

/* ─── Audit JSON ──────────────────────────────────────────────────────── */
.audit-json {
  font-family: var(--pico-font-family-monospace); font-size: .76rem;
  color: var(--gw-muted); white-space: pre-wrap; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ─── Buttons consistency ─────────────────────────────────────────────── */
.btn-danger {
  --pico-primary-background: var(--gw-danger);
  --pico-primary-border:     var(--gw-danger);
  --pico-primary-hover-background: color-mix(in srgb, var(--gw-danger) 85%, black);
  --pico-primary-hover-border:     color-mix(in srgb, var(--gw-danger) 85%, black);
}
.btn-icon {
  display: inline-flex; align-items: center; gap: .35rem;
}
.btn-icon svg { width: 1rem; height: 1rem; }

/* ─── Quick-action grid ───────────────────────────────────────────────── */
.gw-grid-2 {
  display: grid; gap: 1rem;
  grid-template-columns: 2fr 1fr;
}
@media (max-width: 900px) { .gw-grid-2 { grid-template-columns: 1fr; } }
