/* ================================================================
   AOHC Auth — Huawei Cloud Corporate UI
   ================================================================ */

/* ── Color System ── */
:root {
  /* Huawei Cloud brand */
  --huawei-red: #C7000B;
  --huawei-red-hover: #E0000F;
  --huawei-red-dim: rgba(199, 0, 11, 0.12);
  --huawei-red-glow: rgba(199, 0, 11, 0.22);

  /* Surfaces (dark) */
  --surface: #0a0c12;
  --surface-elevated: #12151e;
  --surface-input: #181c28;
  --border: #252a38;
  --border-soft: #1e2330;
  --border-focus: #3a4156;

  /* Text */
  --text-primary: #e8eaf0;
  --text-secondary: #8b94a5;
  --text-muted: #5e6776;

  /* Feedback */
  --danger: #e0526a;
  --danger-bg: rgba(224, 82, 106, 0.10);
  --success: #4caf7d;
  --success-bg: rgba(76, 175, 125, 0.10);

  /* Layout */
  --radius: 10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-card: 0 24px 48px rgba(0, 0, 0, 0.40);
  --shadow-input: 0 0 0 3px var(--huawei-red-glow);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--surface);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--huawei-red); text-decoration: none; }
a:hover { color: var(--huawei-red-hover); }

/* ================================================================
   AUTH SPLIT LAYOUT (55/45)
   ================================================================ */
.auth-shell {
  display: grid;
  grid-template-columns: 55fr 45fr;
  min-height: 100vh;
}

/* ── Left: Branding Panel ── */
.auth-branding {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px 56px;
  background: var(--surface-elevated);
  overflow: hidden;
}

/* Subtle grid pattern */
.auth-branding::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--border-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-soft) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
  mask-image: radial-gradient(ellipse at 30% 40%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 0%, transparent 70%);
}

/* Red glow accent */
.auth-branding::after {
  content: '';
  position: absolute;
  top: -120px;
  left: -80px;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--huawei-red-glow) 0%, transparent 60%);
  pointer-events: none;
}

.auth-branding-content {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

.auth-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 40px;
}
.auth-logo img {
  width: 100%;
  height: 100%;
  display: block;
}

.auth-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 16px;
  letter-spacing: -0.5px;
}
.auth-title span {
  display: block;
  color: var(--huawei-red);
}

.auth-description {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0 0 48px;
  max-width: 360px;
}

/* Decorative network nodes */
.auth-nodes {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 6px;
  margin-bottom: 48px;
}
.auth-nodes span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-focus);
}
.auth-nodes span:nth-child(1) { background: var(--huawei-red); }
.auth-nodes span:nth-child(2) { background: var(--huawei-red); opacity: 0.6; }
.auth-nodes span:nth-child(3) { background: var(--huawei-red); opacity: 0.3; }

/* Security badge */
.auth-security-badge {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--huawei-red-dim);
  border: 1px solid var(--huawei-red-glow);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.3px;
}
.auth-security-badge svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Right: Form Panel ── */
.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: var(--surface);
}

.auth-form-wrap {
  width: 100%;
  max-width: 380px;
}

/* Form header */
.auth-form-header {
  margin-bottom: 32px;
}
.auth-form-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.3px;
}
.auth-form-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* ================================================================
   FORM ELEMENTS
   ================================================================ */
label {
  display: block;
  margin: 0 0 6px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.input-group {
  position: relative;
  margin-bottom: 18px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select {
  width: 100%;
  padding: 13px 14px;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--text-muted); }
input:focus, select:focus {
  outline: none;
  border-color: var(--huawei-red);
  box-shadow: var(--shadow-input);
}

/* Password show/hide toggle */
.pwd-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin: 0;
  width: auto;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s;
}
.pwd-toggle:hover { color: var(--text-primary); }
.pwd-toggle svg { width: 18px; height: 18px; display: block; }

/* Primary button — Huawei Red */
button, .btn {
  width: 100%;
  padding: 14px;
  margin-top: 24px;
  background: var(--huawei-red);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
button:hover, .btn:hover { background: var(--huawei-red-hover); }
button:active, .btn:active { transform: scale(0.985); }
.btn-secondary { background: var(--surface-input); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); }

/* ================================================================
   ERROR / SUCCESS MESSAGES
   ================================================================ */
.error {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: #f4b6c2;
  padding: 11px 14px;
  border-radius: var(--radius);
  margin: 0 0 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.success {
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: #b6e6c8;
  padding: 11px 14px;
  border-radius: var(--radius);
  margin: 0 0 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ================================================================
   OTP CELLS
   ================================================================ */
.otp-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 8px;
}
.otp-cell {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.otp-cell:focus {
  outline: none;
  border-color: var(--huawei-red);
  box-shadow: var(--shadow-input);
}
.otp-sep {
  width: 12px;
  align-self: center;
  height: 2px;
  background: var(--border-focus);
  border-radius: 2px;
}

/* ================================================================
   STEPPER (Activation)
   ================================================================ */
.stepper {
  display: flex;
  align-items: center;
  margin-bottom: 32px;
  gap: 0;
}
.stepper-step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.stepper-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}
.stepper-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.stepper-step.active .stepper-num {
  background: var(--huawei-red);
  border-color: var(--huawei-red);
  color: #fff;
}
.stepper-step.active .stepper-label {
  color: var(--text-primary);
  font-weight: 600;
}
.stepper-step.done .stepper-num {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.stepper-step.done .stepper-label {
  color: var(--text-secondary);
}
.stepper-line {
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 4px;
}
.stepper-step.done + .stepper-line { background: var(--success); }

/* ================================================================
   PASSWORD REQUIREMENTS
   ================================================================ */
.pwd-reqs {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}
.pwd-reqs li {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.pwd-reqs li::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border-focus);
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}
.pwd-reqs li.met { color: var(--success); }
.pwd-reqs li.met::before {
  border-color: var(--success);
  background: var(--success);
}

/* ================================================================
   QR CODE
   ================================================================ */
.qr {
  text-align: center;
  margin: 24px 0;
}
.qr img {
  background: #fff;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

/* ================================================================
   MISC TEXT
   ================================================================ */
.muted { color: var(--text-secondary); font-size: 13px; }
.center { text-align: center; }
.mfa-note { margin-top: 20px; text-align: center; }
.mfa-apps {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 20px;
}
.mfa-apps span {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.mfa-apps span::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-focus);
}

/* ================================================================
   ADMIN / APP PAGES (backward compatible)
   ================================================================ */
.wrap {
  max-width: 420px;
  margin: 56px auto;
  padding: 0 20px;
}
.wrap-wide { max-width: 900px; }

.card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  box-shadow: var(--shadow-card);
}

.brand {
  font-size: 17px;
  font-weight: 650;
  margin-bottom: 2px;
  letter-spacing: 0.2px;
}
.brand-sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}
.logo-block { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px;
  background: var(--huawei-red);
}

table { width: 100%; border-collapse: collapse; margin-top: 18px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--text-secondary); font-weight: 600; }
td.actions form { display: inline; }
td.actions button { width: auto; padding: 5px 10px; margin: 2px; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.badge-on { background: rgba(76,175,125,0.18); color: #b6e6c8; }
.badge-off { background: rgba(154,164,178,0.18); color: var(--text-muted); }
.badge-admin { background: var(--huawei-red-dim); color: #f0a0a8; }

.nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.nav a { font-size: 13px; }

/* ================================================================
   LOGOUT BUTTON (injected into agent page)
   ================================================================ */
#aohc-logout-btn {
  position: fixed; top: 14px; right: 16px; z-index: 2147483647;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(18, 21, 30, 0.85); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px); transition: color .15s, border-color .15s, background .15s;
  text-decoration: none;
}
#aohc-logout-btn:hover { color: #fff; border-color: var(--huawei-red); background: var(--huawei-red-glow); }
#aohc-logout-btn svg { width: 18px; height: 18px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */

/* Tablet */
@media (max-width: 1024px) {
  .auth-shell { grid-template-columns: 45fr 55fr; }
  .auth-branding { padding: 48px 40px; }
  .auth-title { font-size: 26px; }
}

/* Mobile */
@media (max-width: 768px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-branding {
    padding: 32px 24px 24px;
    min-height: auto;
  }
  .auth-branding::before { opacity: 0.2; }
  .auth-logo { width: 40px; height: 40px; margin-bottom: 20px; }
  .auth-title { font-size: 22px; margin-bottom: 8px; }
  .auth-description { font-size: 13px; margin-bottom: 20px; }
  .auth-nodes { margin-bottom: 20px; }
  .auth-form-side { padding: 32px 24px; }
  .auth-form-wrap { max-width: none; }
  .otp-cell { width: 40px; height: 48px; font-size: 20px; }
  .otp-row { gap: 6px; }
  .stepper-label { display: none; }
  .pwd-reqs { grid-template-columns: 1fr; }
}

/* Small mobile */
@media (max-width: 420px) {
  .auth-branding { padding: 24px 20px 16px; }
  .auth-form-side { padding: 24px 20px; }
  .otp-cell { width: 36px; height: 44px; font-size: 18px; }
  .otp-row { gap: 4px; }
  .wrap { margin: 24px auto; }
  .card { padding: 22px 20px; }
  table { font-size: 12px; }
  th, td { padding: 8px 5px; }
}

/* ================================================================
   ADMIN DASHBOARD LAYOUT
   ================================================================ */
.admin-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
.admin-sidebar {
  background: var(--surface-elevated);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-sidebar-header {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}
.admin-sidebar-header img { width: 36px; height: 36px; margin-bottom: 12px; }
.admin-sidebar-header .admin-title { font-size: 15px; font-weight: 700; margin: 0; }
.admin-sidebar-header .admin-subtitle { font-size: 12px; color: var(--text-secondary); margin: 4px 0 0; }

.admin-nav { flex: 1; padding: 0 12px; }
.admin-nav-section { margin-bottom: 16px; }
.admin-nav-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-muted);
  padding: 0 12px 6px;
}
.admin-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--text-secondary);
  transition: background .12s, color .12s;
  margin-bottom: 2px;
}
.admin-nav a:hover { background: var(--surface-input); color: var(--text-primary); }
.admin-nav a.active { background: var(--huawei-red-dim); color: #fff; font-weight: 600; }
.admin-nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }
.admin-nav a.active svg { opacity: 1; }

.admin-sidebar-footer { padding: 16px 24px; border-top: 1px solid var(--border-soft); }
.admin-sidebar-footer .admin-user-info { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.admin-sidebar-footer .admin-user-info strong { color: var(--text-primary); display: block; font-size: 13px; }

/* ── Main content ── */
.admin-main { padding: 32px 40px; overflow-y: auto; }
.admin-page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-page-title { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -0.3px; }
.admin-page-subtitle { font-size: 14px; color: var(--text-secondary); margin: 4px 0 0; }

/* ── Metric cards ── */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 32px; }
.metric-card {
  background: var(--surface-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 22px 24px;
  transition: border-color .15s;
}
.metric-card:hover { border-color: var(--border-focus); }
.metric-card .metric-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; margin: 0 0 8px; }
.metric-card .metric-value { font-size: 32px; font-weight: 700; margin: 0; letter-spacing: -1px; }
.metric-card .metric-delta { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.metric-card .metric-icon { float: right; width: 36px; height: 36px; border-radius: 10px; background: var(--huawei-red-dim); display: flex; align-items: center; justify-content: center; }
.metric-card .metric-icon svg { width: 18px; height: 18px; color: var(--huawei-red); }

/* ── Admin table ── */
.admin-table-wrap {
  background: var(--surface-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.admin-table-wrap table { margin-top: 0; }
.admin-table-wrap th { background: var(--surface); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 16px; }
.admin-table-wrap td { padding: 12px 16px; }
.admin-table-wrap tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Admin forms ── */
.admin-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.admin-form-card {
  background: var(--surface-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px 28px; margin-bottom: 24px;
}
.admin-form-card h3 { font-size: 16px; font-weight: 600; margin: 0 0 18px; }
.admin-form-card .input-group { margin-bottom: 14px; }
.admin-form-card button { width: auto; padding: 10px 24px; margin-top: 8px; }
.admin-form-card .btn-secondary { display: inline-block; text-align: center; }

/* ── Permission checkboxes ── */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.perm-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface-input);
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color .15s;
}
.perm-item:hover { border-color: var(--border-focus); }
.perm-item input { width: auto; accent-color: var(--huawei-red); }
.perm-item span { font-size: 13px; }
.perm-item code { font-size: 11px; color: var(--text-muted); display: block; }

/* ── Admin badges ── */
.badge-danger { background: rgba(224,82,106,0.18); color: #f0a0a8; }
.badge-info { background: rgba(100,160,255,0.15); color: #a0c4f0; }

/* ── Admin actions ── */
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-actions form { display: inline; }
.admin-actions button { width: auto; padding: 5px 12px; margin: 0; font-size: 11px; }

/* ── Audit log ── */
.audit-entry {
  padding: 12px 16px; border-bottom: 1px solid var(--border-soft);
  display: grid; grid-template-columns: 140px 100px 1fr 120px;
  gap: 12px; align-items: center; font-size: 13px;
}
.audit-entry:hover { background: rgba(255,255,255,0.02); }
.audit-time { color: var(--text-muted); font-size: 12px; }
.audit-action { font-weight: 600; }
.audit-details { color: var(--text-secondary); font-size: 12px; }

/* ── Admin responsive ── */
@media (max-width: 1024px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: fixed; left: -260px; z-index: 100; transition: left .2s; width: 260px; }
  .admin-sidebar.open { left: 0; }
  .admin-main { padding: 20px; }
  .admin-form-row { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
  .audit-entry { grid-template-columns: 1fr; gap: 4px; }
}
