/* styles.css — supplements Pico CSS with project-specific layouts */

:root {
  --gap-sm: 0.5rem;
  --gap-md: 1rem;
  --gap-lg: 1.5rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --row-warning-bg: rgba(255, 196, 0, 0.08);
  --row-warning-fg: var(--pico-color-amber-500, #b27300);
  --row-critical-bg: rgba(255, 88, 0, 0.10);
  --row-critical-fg: var(--pico-color-red-500, #c1272d);
  --row-expired-bg: rgba(120, 0, 0, 0.12);
  --row-expired-fg: var(--pico-color-red-700, #7a1f1f);
  --toast-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  --section-border: var(--pico-muted-border-color, rgba(125, 125, 125, 0.2));
}

/* ─────────── Layout ─────────── */
html, body { height: 100%; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--pico-card-background-color);
  border-bottom: 1px solid var(--section-border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.app-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  margin: 0;
}
.app-header .actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.app-header .actions .user-tag {
  font-size: 0.85rem;
  opacity: 0.75;
}

main.app-main {
  flex: 1;
  padding: 1rem;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}
main.app-main.compact {
  max-width: 480px;
}

/* ─────────── Auth pages ─────────── */
.auth-card {
  width: 100%;
  max-width: 420px;
  margin: 4rem auto;
  padding: 1.75rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--section-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--toast-shadow);
}
.auth-card h1 {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.4rem;
}
.auth-card .subtitle {
  margin-top: -0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  opacity: 0.7;
}
.auth-card label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}
.auth-card .form-row { margin-bottom: 0.9rem; }
.auth-card .submit-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.auth-card .footnote {
  margin-top: 1rem;
  font-size: 0.8rem;
  opacity: 0.65;
  text-align: center;
}

/* QR block */
.qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
}
.qr-block canvas, .qr-block svg, .qr-block table {
  max-width: 260px;
  width: 100%;
  height: auto;
  border: 1px solid var(--section-border);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 0.5rem;
}
.qr-block .secret-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  background: var(--pico-card-sectioning-background-color, rgba(125,125,125,0.06));
  border: 1px solid var(--section-border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  word-break: break-all;
  text-align: center;
  user-select: all;
}
.qr-block .otpauth-link {
  font-size: 0.8rem;
  word-break: break-all;
}

/* ─────────── Dashboard sections ─────────── */
.dashboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.dashboard-toolbar h1 { margin: 0; font-size: 1.4rem; }
.dashboard-toolbar .summary {
  font-size: 0.9rem;
  opacity: 0.75;
}
.dashboard-toolbar .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.provider-section {
  border: 1px solid var(--section-border);
  border-radius: var(--radius-lg);
  background: var(--pico-card-background-color);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.provider-section header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  background: var(--pico-card-sectioning-background-color, rgba(125,125,125,0.04));
  border-bottom: 1px solid var(--section-border);
}
.provider-section header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}
.provider-section header h2 a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed currentColor;
  padding-bottom: 1px;
}
.provider-section header h2 a:hover { color: var(--pico-primary); }
.provider-section header .meta {
  font-size: 0.8rem;
  opacity: 0.7;
}
.provider-section header .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.provider-section .empty-state {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Tables */
.vds-table-wrap { width: 100%; overflow-x: auto; }
.vds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.vds-table th, .vds-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--section-border);
}
.vds-table thead th {
  background: var(--pico-card-sectioning-background-color, rgba(125,125,125,0.04));
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  opacity: 0.85;
}
.vds-table tbody tr:last-child td { border-bottom: none; }
.vds-table tbody tr.row-warning  td:first-child { border-left: 3px solid var(--row-warning-fg); }
.vds-table tbody tr.row-warning { background: var(--row-warning-bg); }
.vds-table tbody tr.row-critical td:first-child { border-left: 3px solid var(--row-critical-fg); }
.vds-table tbody tr.row-critical { background: var(--row-critical-bg); }
.vds-table tbody tr.row-expired td:first-child  { border-left: 3px solid var(--row-expired-fg); }
.vds-table tbody tr.row-expired { background: var(--row-expired-bg); opacity: 0.85; }

.vds-table input[type="text"] {
  width: 100%;
  min-width: 7rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
}
.vds-table input[type="text"]:hover {
  border-color: var(--section-border);
}
.vds-table input[type="text"]:focus {
  border-color: var(--pico-primary);
  background: var(--pico-card-background-color);
  outline: none;
}
.vds-table input.dirty {
  border-color: var(--pico-primary);
  background: rgba(60, 120, 240, 0.06);
}
.vds-table input.saved {
  border-color: rgba(60, 160, 80, 0.4);
}
.vds-table input.error {
  border-color: var(--row-critical-fg);
  background: rgba(255, 60, 60, 0.06);
}

.vds-table .col-name { font-weight: 500; }
.vds-table .col-ip, .vds-table .col-paid { white-space: nowrap; font-variant-numeric: tabular-nums; }
.vds-table .col-paid .days-left { font-size: 0.78rem; opacity: 0.7; margin-left: 0.25rem; }

/* Buttons */
.btn-row { display: inline-flex; gap: 0.5rem; align-items: center; }
button.icon-btn {
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
}

/* Type badges for providers (API / Browser / Mock) */
.badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--pico-muted-border-color);
  color: var(--pico-color);
  vertical-align: middle;
}
.badge-api {
  background: #2563eb;
  color: #fff;
}
.badge-browser {
  background: #d97706;
  color: #fff;
}
.badge-mock {
  background: #6b7280;
  color: #fff;
}
.spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────── Modal ─────────── */
.modal-host {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}
.modal-card {
  width: 100%;
  max-width: 560px;
  background: var(--pico-card-background-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--toast-shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { margin-top: 0; font-size: 1.2rem; }
.modal-card .form-row { margin-bottom: 0.85rem; }
.modal-card .form-row label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.25rem; }
.modal-card .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}
.modal-card textarea {
  width: 100%;
  min-height: 100px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

/* ─────────── Toast ─────────── */
.toast-host {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  background: var(--pico-card-background-color);
  border: 1px solid var(--section-border);
  border-left: 4px solid var(--pico-primary);
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  box-shadow: var(--toast-shadow);
  font-size: 0.9rem;
  min-width: 260px;
  max-width: 360px;
  animation: toast-in 0.2s ease-out;
}
.toast-success { border-left-color: #2e8b57; }
.toast-warn    { border-left-color: #d49b00; }
.toast-error   { border-left-color: #c1272d; }
.toast-text { flex: 1; line-height: 1.4; }
.toast-close {
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  opacity: 0.55;
  padding: 0;
  width: 1.25rem;
  height: 1.25rem;
}
.toast-close:hover { opacity: 1; }
.toast-leave { animation: toast-out 0.2s ease-in forwards; }
@keyframes toast-in  { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { to { transform: translateX(20px); opacity: 0; } }

/* ─────────── Forms / inputs ─────────── */
form .row-error {
  color: var(--row-critical-fg);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}
input.error, select.error, textarea.error {
  border-color: var(--row-critical-fg) !important;
}

/* ─────────── Responsive ─────────── */
@media (max-width: 720px) {
  main.app-main { padding: 0.75rem; }
  .app-header { padding: 0.6rem 0.85rem; }
  .auth-card { margin: 2rem auto; padding: 1.25rem; }
  .vds-table { font-size: 0.85rem; }
  .vds-table th, .vds-table td { padding: 0.4rem 0.5rem; }
  .provider-section header { padding: 0.7rem 0.85rem; }
}
