/* ============================================================
   MAIL OTP - giao dien toi, layout khong cuon toan trang.
   Chi khung danh sach thu (#list) co thanh cuon rieng.
   ============================================================ */

:root {
  --bg:      #0b1016;
  --panel:   #151f2e;
  --panel2:  #1b273a;
  --line:    #24334a;
  --text:    #e8eef7;
  --dim:     #8fa3bd;
  --accent:  #4c8dff;
  --accent2: #6ea8ff;
  --otp:     #3fb950;
  --danger:  #f85149;
  --radius:  12px;
  --shadow:  0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;                 /* khong cuon toan trang */
  background:
    radial-gradient(1100px 500px at 12% -10%, #17263c 0%, transparent 60%),
    radial-gradient(900px 420px at 105% 0%, #1a2033 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 "Segoe UI", system-ui, -apple-system, "Noto Sans", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.admin-page { overflow: auto; }   /* trang admin cuon binh thuong */

/* ---------- Header ---------- */
.top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 22, .72);
  backdrop-filter: blur(8px);
}

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

.logo {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  flex: 0 0 auto;
  border-radius: 11px;
  font-size: 20px;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  box-shadow: 0 4px 14px rgba(76, 141, 255, .35);
}

.top h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: .2px;
}

.sub, .sub-inline {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--dim);
}

.sub b { color: var(--accent2); font-weight: 600; }

.top-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.live-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--otp);
  box-shadow: 0 0 0 3px rgba(63, 185, 80, .18);
  animation: pulse 2s infinite;
}
.live-dot.off { background: var(--dim); animation: none; box-shadow: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

.status { font-size: 12.5px; color: var(--dim); white-space: nowrap; }

/* ---------- Vung giua: co dinh cao, khong cuon ---------- */
.wrap {
  flex: 1 1 auto;
  min-height: 0;                    /* quan trong de con cuon duoc */
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 22px;
}

.panel {
  flex: 0 0 auto;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  box-shadow: var(--shadow);
}

.panel.narrow { max-width: 420px; margin: 40px auto; }

.panel-title {
  margin: 0 0 12px;
  font-size: 14.5px;
  font-weight: 620;
  color: var(--text);
}

.row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.row.options {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  align-items: center;
}

.spacer { flex: 1 1 auto; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.grow { flex: 1 1 260px; }

.field label {
  font-size: 12px;
  color: var(--dim);
  font-weight: 550;
}

/* ---------- Input ---------- */
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0e1622;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(76, 141, 255, .16);
}

input::placeholder { color: #5d7290; }

.mono {
  font-family: "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: 13px;
}

.addr-input { display: flex; align-items: stretch; }

.addr-input input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.addr-input .suffix {
  display: grid;
  place-items: center;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-left: none;
  border-top-right-radius: 9px;
  border-bottom-right-radius: 9px;
  background: #101a28;
  color: var(--dim);
  font-size: 13px;
  white-space: nowrap;
}

/* ---------- Nut ---------- */
.btn {
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #1c2942;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .08s, background .15s, border-color .15s;
}

.btn:hover  { background: #22314e; border-color: #33456a; }
.btn:active { transform: translateY(1px); }

.btn.primary {
  border-color: transparent;
  background: linear-gradient(140deg, var(--accent), #3a6fd8);
  box-shadow: 0 3px 12px rgba(76, 141, 255, .3);
}
.btn.primary:hover { background: linear-gradient(140deg, var(--accent2), #4478e0); }

.btn.ghost  { background: transparent; }
.btn.small  { padding: 6px 12px; font-size: 12.5px; }
.btn.tiny   { padding: 4px 9px; font-size: 11.5px; }
.btn.danger { border-color: #5c2a2a; color: #ff9a94; }
.btn.danger:hover { background: #3a1e1e; }
.btn.copied { background: #1f4a2a; border-color: #2d6b3c; }

/* ---------- Cong tac tu dong lam moi ---------- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}

.switch input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }

.keyinfo {
  padding: 3px 10px;
  border: 1px solid #2d5a3a;
  border-radius: 20px;
  background: rgba(63, 185, 80, .12);
  color: #7ee08c;
  font-size: 12px;
  font-weight: 560;
}

/* ---------- Khung danh sach: CHI CHO NAY CUON ---------- */
.listwrap {
  flex: 1 1 auto;
  min-height: 0;                    /* cho phep con thu nho lai */
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 31, 46, .55);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.listhead {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 22, 34, .6);
}

.list-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 620;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .6px;
}

.count { font-size: 12.5px; color: var(--dim); }

.list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;                 /* thanh cuon rieng */
  overscroll-behavior: contain;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #33456a transparent;
}

.list:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.list::-webkit-scrollbar       { width: 10px; }
.list::-webkit-scrollbar-track { background: transparent; }
.list::-webkit-scrollbar-thumb {
  background: #2b3c5a;
  border: 2px solid transparent;
  background-clip: content-box;
  border-radius: 8px;
}
.list::-webkit-scrollbar-thumb:hover { background: #3a5080; background-clip: content-box; }

/* ---------- The thu ---------- */
.mail {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #17212f, #141d2a);
  padding: 12px 14px;
  transition: border-color .15s, transform .15s;
}

.mail:hover { border-color: #33456a; }

.mail.fresh {
  border-color: #2d6b3c;
  animation: pop .45s ease;
}

@keyframes pop {
  0%   { transform: scale(.985); box-shadow: 0 0 0 0 rgba(63, 185, 80, .5); }
  60%  { box-shadow: 0 0 0 8px rgba(63, 185, 80, 0); }
  100% { transform: scale(1); }
}

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

.mail-to {
  font-weight: 620;
  font-size: 13.5px;
  color: var(--accent2);
  word-break: break-all;
}

.mail-time { font-size: 11.5px; color: var(--dim); white-space: nowrap; }

.mail-from {
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 6px;
  word-break: break-all;
}

.mail-subject {
  font-size: 14px;
  font-weight: 560;
  margin-bottom: 8px;
}

.otp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0;
  padding: 9px 12px;
  border: 1px dashed #2d6b3c;
  border-radius: 9px;
  background: rgba(63, 185, 80, .07);
}

.otp-label { font-size: 11.5px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; }

.otp-code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--otp);
}

.mail-body {
  font-size: 12.8px;
  color: #b9c8dc;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 96px;
  overflow: hidden;
  position: relative;
  transition: max-height .2s;
}

.mail-body.open { max-height: none; }

.mail-body mark {
  background: rgba(63, 185, 80, .22);
  color: var(--otp);
  font-weight: 700;
  padding: 0 3px;
  border-radius: 3px;
}

.more {
  margin-top: 6px;
  background: none;
  border: none;
  color: var(--accent2);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.more:hover { text-decoration: underline; }

.empty {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--dim);
  font-size: 13.5px;
}
.empty b { color: var(--accent2); }
.hidden { display: none !important; }

/* ---------- Footer ---------- */
.foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 22px;
  border-top: 1px solid var(--line);
  background: rgba(11, 16, 22, .7);
  font-size: 11.5px;
  color: var(--dim);
}

.dim { color: var(--dim); }

/* ---------- Trang admin ---------- */
.alert {
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 13.5px;
  margin-bottom: 12px;
  border: 1px solid;
}
.alert.error { border-color: #5c2a2a; background: rgba(248, 81, 73, .1); color: #ff9a94; }
.alert.ok    { border-color: #2d6b3c; background: rgba(63, 185, 80, .1); color: #7ee08c; }

.login-form { display: flex; flex-direction: column; gap: 10px; }
.login-form label { font-size: 12px; color: var(--dim); }

.keybox { border-color: #2d6b3c; }

.copyrow { display: flex; gap: 8px; }
.copyrow input { flex: 1 1 auto; }

.hint { margin: 6px 0 0; font-size: 12.5px; color: var(--dim); }
.hint code, .code code { color: var(--accent2); }

code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #0e1622;
  color: var(--accent2);
}

pre.code {
  margin: 8px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0b1320;
  color: #b9c8dc;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
  overflow-x: auto;
  white-space: pre;
}

.table-scroll { overflow-x: auto; }

.keytable { width: 100%; border-collapse: collapse; font-size: 13px; }
.keytable th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--dim);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.keytable td { padding: 9px 10px; border-bottom: 1px solid #1c2738; vertical-align: middle; }
.keytable tr.off { opacity: .5; }
.keytable .actions { display: flex; gap: 6px; white-space: nowrap; }
.inline { display: inline; margin: 0; }

.badge {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid;
}
.badge.on  { border-color: #2d6b3c; background: rgba(63, 185, 80, .12); color: #7ee08c; }
.badge.off { border-color: #4a3a1e; background: rgba(210, 153, 34, .12); color: #d8b562; }

.empty-inline { color: var(--dim); font-size: 13.5px; margin: 0; }

/* ---------- Man hinh nho ---------- */
@media (max-width: 760px) {
  .wrap { padding: 12px 14px; }
  .top  { padding: 12px 14px; }
  .row  { flex-direction: column; align-items: stretch; }
  .row.options { flex-direction: row; flex-wrap: wrap; }
  .btn.primary { width: 100%; }
  .sub { display: none; }
  .otp-code { font-size: 20px; }
  .foot { display: none; }
}
