/* ─────────────────────────────────────────────────────────────────────
   HUST Services - giao diện chung cho Auth Service và DNS Service
   Phẳng, ít trang trí, đỏ Bách Khoa chỉ dùng làm điểm nhấn
   ───────────────────────────────────────────────────────────────────── */
:root {
  --hust-red: #c8102e;
  --hust-red-dark: #a10d24;
  --hust-red-soft: #fdf0f2;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;

  --text-primary: #18202b;
  --text-secondary: #4b5563;
  --text-muted: #8a94a3;

  --success: #18794e;
  --success-soft: #e8f6ee;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --info: #1d5fb8;
  --info-soft: #eaf2fd;
  --warning: #8a5a00;
  --warning-soft: #fdf4e3;

  --focus: #2f6fd1;
  --focus-ring: 0 0 0 3px rgba(47, 111, 209, 0.16);

  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--info);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.01em;
}

svg.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Form controls ─────────────────────────────────────────────────── */
label,
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

input:focus,
select:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}

.field {
  margin-bottom: 18px;
}

.field-hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.field-hint strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.btn:disabled {
  cursor: progress;
  opacity: 0.7;
}

.btn-primary {
  background: var(--hust-red);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--hust-red-dark);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--surface-muted);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text-primary);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-dark {
  border-color: var(--border);
  border-top-color: var(--hust-red);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Alerts & toast ────────────────────────────────────────────────── */
.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error {
  background: var(--danger-soft);
  border: 1px solid #fecdca;
  color: var(--danger);
}

.alert details {
  margin-top: 6px;
}

.alert summary {
  cursor: pointer;
  font-weight: 600;
}

.alert pre {
  margin-top: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 16px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text-primary);
  color: #fff;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: var(--danger);
}

/* ── Top bar ───────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: inset 0 -2px 0 var(--hust-red);
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img {
  height: 36px;
  width: auto;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.user-chip-text {
  text-align: right;
  min-width: 0;
}

.user-chip-mssv {
  font-size: 14px;
  font-weight: 600;
}

.user-chip-email {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--hust-red-soft);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Page & panels ─────────────────────────────────────────────────── */
.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.panel h2 {
  font-size: 17px;
}

.panel-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.count {
  font-size: 13px;
  color: var(--text-muted);
}

.state-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Ô tên miền gộp: [subdomain][.root-domain ▾] ───────────────────── */
.domain-field {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.domain-field:focus-within {
  border-color: var(--focus);
  box-shadow: var(--focus-ring);
}

.domain-field input,
.domain-field select {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
}

.domain-field input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 15px;
}

.domain-field select {
  width: auto;
  flex-shrink: 0;
  background: var(--surface-muted);
  border-left: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 14px;
}

/* ── Nút chọn loại bản ghi ─────────────────────────────────────────── */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.segmented button {
  height: 36px;
  padding: 0 18px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--border-strong);
}

.segmented button:hover {
  background: var(--surface-muted);
}

.segmented button[aria-checked="true"] {
  background: var(--hust-red);
  color: #fff;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
}

.cmd-details {
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
}

.cmd-details summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.cmd-details summary::-webkit-details-marker {
  display: none;
}

.cmd-details summary:hover {
  color: var(--text-secondary);
}

.cmd-details code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ── Danh sách subdomain ───────────────────────────────────────────── */
.domain-list {
  margin-top: 12px;
}

.domain-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) auto minmax(0, 1.3fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.domain-row.is-new {
  animation: highlight 2.4s ease;
}

@keyframes highlight {
  0%, 40% { background: var(--hust-red-soft); }
  100% { background: transparent; }
}

.domain-name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.domain-date {
  font-size: 12px;
  color: var(--text-muted);
}

.domain-target {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.domain-badges,
.domain-actions {
  display: flex;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.badge-A { background: #eef0f3; color: #374151; }
.badge-CNAME { background: var(--info-soft); color: var(--info); }
.badge-TXT { background: var(--warning-soft); color: var(--warning); }
.badge-https { background: var(--success-soft); color: var(--success); }

.empty-state {
  text-align: center;
  padding: 28px 12px 12px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
}

.empty-state strong {
  display: block;
  color: var(--text-primary);
  font-size: 15px;
  margin-bottom: 2px;
}

/* ── Trang đăng nhập (Auth Service) ────────────────────────────────── */
.auth-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
}

.auth-brand {
  position: relative;
  background: var(--hust-red);
  overflow: hidden;
}

.auth-brand img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 30% 60%;
}

.auth-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.auth-panel {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.08);
}

.auth-logo {
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.auth-logo img {
  height: 56px;
}

.auth-logo .brand-name {
  font-size: 20px;
}

.auth-logo .brand-sub {
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-card {
  width: 100%;
}

.auth-card h2 {
  font-size: 30px;
  margin-bottom: 6px;
}

.auth-card .lead {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Form đăng nhập to hơn form trong dashboard */
.auth-card .field {
  margin-bottom: 20px;
}

.auth-card label {
  font-size: 14px;
}

.auth-card input[type="text"],
.auth-card input[type="password"] {
  height: 50px;
  padding: 0 14px;
  font-size: 16px;
}

.auth-card .btn {
  height: 50px;
  font-size: 16px;
}

.auth-card.state-panel {
  font-size: 15px;
}

.continue-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -12px 0 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.continue-note strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Ô mật khẩu có nút con mắt */
.password-field {
  position: relative;
}

.password-field input {
  padding-right: 52px !important;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--text-primary);
  background: var(--surface-muted);
}

.secure-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.secure-note .icon {
  margin-top: 2px;
}

.profile-box {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  margin-bottom: 16px;
}

.profile-box .avatar {
  width: 52px;
  height: 52px;
}

.profile-mssv {
  font-weight: 700;
  font-size: 16px;
}

.profile-email {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-all;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    height: 200px;
  }

  .auth-main {
    align-items: flex-start;
    padding: 28px 16px;
  }

  .auth-panel {
    padding: 24px 20px;
    box-shadow: none;
  }

  .auth-logo {
    padding-bottom: 20px;
    margin-bottom: 20px;
  }

  .auth-logo img {
    height: 44px;
  }

  .auth-card h2 {
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  .topbar-inner,
  .page {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand-sub,
  .user-chip-text {
    display: none;
  }

  .panel {
    padding: 18px 16px;
  }

  .domain-field select {
    max-width: 48%;
  }

  .form-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .domain-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
  }

  .domain-badges {
    grid-column: 1;
    grid-row: 2;
  }

  .domain-target {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .domain-actions {
    grid-column: 2;
    grid-row: 1 / 3;
  }
}
