/* static/css/app.css — TempMail v1.0 */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --bg-surface:   #1a1d2e;
  --bg-card:      #222537;
  --bg-hover:     #2a2e44;
  --border:       #2e3352;
  --accent:       #6c63ff;
  --accent-light: #8b84ff;
  --accent-glow:  rgba(108, 99, 255, 0.25);
  --success:      #22c55e;
  --warning:      #f59e0b;
  --error:        #ef4444;
  --text:         #e2e8f0;
  --text-muted:   #8892a4;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --font:         'Inter', system-ui, sans-serif;
}

html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ===== HEADER ===== */
.header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  max-width: 1400px;
  margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: .5rem; }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-size: 1.2rem; font-weight: 700; color: var(--accent-light); letter-spacing: -.3px; }
.header-actions { display: flex; align-items: center; gap: .75rem; }

/* ===== LAYOUT ===== */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr 1.4fr;
  gap: 0;
  flex: 1;
  height: calc(100vh - 56px);
  overflow: hidden;
}
.panel { overflow-y: auto; border-right: 1px solid var(--border); }
.panel:last-child { border-right: none; }
.panel-left  { padding: 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.panel-middle { display: flex; flex-direction: column; }
.panel-right { padding: 1.5rem; }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 1rem;
}

/* ===== FORM ===== */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .875rem; }
.form-group label { font-size: .8rem; font-weight: 500; color: var(--text-muted); }
.input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  padding: .55rem .8rem;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.hint { font-size: .75rem; color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn {
  border: none; cursor: pointer; font-family: var(--font);
  font-size: .875rem; font-weight: 500;
  border-radius: 7px; padding: .55rem 1rem;
  transition: all .2s; display: inline-flex; align-items: center; gap: .4rem;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-light); transform: translateY(-1px); box-shadow: 0 4px 14px var(--accent-glow); }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover  { border-color: var(--accent); color: var(--accent-light); }
.btn-secondary { background: var(--bg-hover); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-icon { background: transparent; color: var(--text-muted); padding: .4rem; border-radius: 6px; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-group { display: flex; gap: .6rem; }

/* ===== BADGES ===== */
.badge {
  font-size: .75rem; font-weight: 500; padding: .2rem .65rem;
  border-radius: 20px; display: inline-flex; align-items: center; gap: .3rem;
}
.badge-idle    { background: var(--bg-hover); color: var(--text-muted); }
.badge-active  { background: rgba(34,197,94,.15); color: var(--success); }
.badge-count   { background: var(--bg-surface); color: var(--text-muted); }

/* ===== ALERTS ===== */
.alert { padding: .65rem .9rem; border-radius: 7px; font-size: .85rem; margin-top: .75rem; }
.alert-error { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }

/* ===== MAILBOX INFO ===== */
.card-mailbox { border-color: var(--accent); }
.address-box {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .6rem .8rem; margin-bottom: .75rem;
}
.address-text { font-family: monospace; font-size: .85rem; color: var(--accent-light); flex: 1; word-break: break-all; }
.meta-row { display: flex; gap: .5rem; font-size: .8rem; align-items: center; }
.meta-label { color: var(--text-muted); }
.meta-value { color: var(--text); }

/* ===== OTP ===== */
.otp-box {
  margin-top: .875rem; background: rgba(108,99,255,.1);
  border: 1px solid rgba(108,99,255,.3); border-radius: 8px; padding: .75rem 1rem;
  text-align: center;
}
.otp-label { font-size: .75rem; color: var(--text-muted); margin-bottom: .4rem; }
.otp-code { font-size: 2rem; font-weight: 700; letter-spacing: .2em; color: var(--accent-light); font-family: monospace; }
.detail-otp {
  background: rgba(108,99,255,.1); border: 1px solid rgba(108,99,255,.3);
  border-radius: 8px; padding: .65rem 1rem; margin-bottom: 1rem;
  display: flex; align-items: center; gap: .75rem;
}
.otp-code-inline { font-size: 1.4rem; font-weight: 700; color: var(--accent-light); font-family: monospace; letter-spacing: .15em; }

/* ===== PANEL MIDDLE: INBOX LIST ===== */
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.panel-header h2 { font-size: 1rem; font-weight: 600; }
.message-list { list-style: none; flex: 1; }
.message-item {
  padding: .875rem 1.25rem; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .15s;
}
.message-item:hover { background: var(--bg-hover); }
.message-item.active { background: var(--bg-hover); border-left: 3px solid var(--accent); }
.msg-from { font-size: .8rem; color: var(--text-muted); margin-bottom: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-subject { font-size: .9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: .3rem; }
.msg-meta { display: flex; gap: .5rem; align-items: center; }
.msg-time { font-size: .75rem; color: var(--text-muted); }
.msg-code-badge { font-size: .7rem; background: var(--accent-glow); color: var(--accent-light); border-radius: 4px; padding: .1rem .4rem; font-weight: 600; }
.btn-copy-code {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  cursor: pointer; padding: .1rem .35rem; border-radius: 4px; font-size: .65rem;
  margin-left: .25rem; transition: all .2s;
}
.btn-copy-code:hover { border-color: var(--accent); color: var(--accent-light); background: var(--bg-card); }

/* ===== PANEL RIGHT: MESSAGE DETAIL ===== */
.detail-header { margin-bottom: 1rem; }
.detail-subject { font-size: 1.1rem; font-weight: 600; margin-bottom: .5rem; }
.detail-meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; font-size: .8rem; color: var(--text-muted); }
.detail-body {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; font-size: .875rem; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  max-height: calc(100vh - 300px); overflow-y: auto;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; min-height: 200px; color: var(--text-muted); text-align: center; gap: .5rem;
}
.empty-icon { font-size: 2.5rem; opacity: .5; }
.empty-state p { font-size: .9rem; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== POLLING BADGE ===== */
.badge-active {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #22c55e !important;
  border: 1px solid rgba(34, 197, 94, 0.3) !important;
  font-size: .7rem;
}
.badge-idle {
  background: rgba(100, 116, 139, 0.15) !important;
  color: var(--text-muted) !important;
  font-size: .7rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .layout { grid-template-columns: 260px 1fr; height: auto; overflow: visible; }
  .panel-right { display: none; }
  .panel { overflow-y: visible; height: auto; }
}
@media (max-width: 600px) {
  /* --- Header mobile --- */
  .header { padding: 0 .75rem; }
  .header-inner {
    height: auto;
    flex-wrap: wrap;
    padding: .6rem 0;
    gap: .5rem;
  }
  .logo { flex-shrink: 0; }
  .logo-text { font-size: 1.05rem; }
  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: .35rem;
    justify-content: center;
  }
  .header-actions .btn,
  .header-actions a.btn {
    padding: .35rem .55rem;
    font-size: .72rem;
    min-width: 0;
  }
  .header-actions svg { width: 20px; height: 20px; }

  /* --- Layout mobile: stack vertically --- */
  .layout {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
  }
  .panel {
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    width: 100%;
    overflow-y: visible;
    height: auto;
  }
  .panel-left {
    display: flex !important;
    order: 1;
    padding: 1rem;
  }
  .panel-middle {
    order: 2;
    min-height: 300px;
  }
  .panel-right {
    display: none;
    order: 3;
    padding: 1rem;
  }
  /* Khi xem detail message trên mobile → full-width */
  .panel-right.mobile-show {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: var(--bg);
    overflow-y: auto;
    padding: 1rem;
  }

  /* --- Card / Form mobile --- */
  .card { padding: 1rem; }
  .card-title { font-size: .8rem; }
  .btn-group { flex-wrap: wrap; }
  .btn-group .btn { flex: 1; min-width: 0; text-align: center; justify-content: center; }
  .address-box { padding: .5rem .6rem; }
  .address-text { font-size: .78rem; }
  .otp-code { font-size: 1.5rem; letter-spacing: .1em; }
  .otp-code-inline { font-size: 1.1rem; }

  /* --- Inbox list mobile --- */
  .panel-header { padding: .75rem 1rem; }
  .panel-header h2 { font-size: .9rem; }
  .message-item { padding: .75rem 1rem; }
  .msg-subject { font-size: .85rem; }
  .msg-from { font-size: .75rem; }

  /* --- Message detail mobile --- */
  .detail-body { max-height: none; font-size: .82rem; }
  .detail-subject { font-size: 1rem; }
  .detail-meta { font-size: .75rem; gap: .3rem .6rem; }

  /* --- Modal mobile --- */
  .modal-box { width: 92%; padding: 1.2rem; }
  .modal-box h3 { font-size: 1rem; }
}

/* ===== Mobile detail back button ===== */
.mobile-back-btn {
  display: none;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .5rem 1rem;
  border-radius: 7px;
  font-size: .85rem;
  cursor: pointer;
  margin-bottom: .75rem;
  font-family: var(--font);
}
@media (max-width: 600px) {
  .mobile-back-btn { display: inline-flex; align-items: center; gap: .3rem; }
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  background: linear-gradient(135deg, var(--accent), #6c5ce7);
  color: #fff; padding: .75rem 1.25rem; border-radius: 10px;
  font-size: .9rem; font-weight: 600;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.4);
  transform: translateY(100px); opacity: 0;
  transition: all .3s ease;
}
.toast-show {
  transform: translateY(0); opacity: 1;
}
@media (max-width: 600px) {
  .toast { bottom: 10px; right: 10px; left: 10px; font-size: .82rem; text-align: center; }
}

/* ===== BADGE NEW MAIL ANIMATION ===== */
@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}
.badge-new-mail {
  animation: badgePulse .4s ease 3;
  background: #22c55e !important; color: #fff !important;
}

/* ===== POLLING COUNTDOWN ===== */
.polling-countdown {
  font-size: .65rem; color: var(--text-muted);
  margin-left: .35rem; opacity: .7;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 95%; max-width: 440px;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
  max-height: 90vh;
  overflow-y: auto;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95); }
  to { opacity: 1; transform: scale(1); }
}
.modal-box h3 { margin-bottom: 1rem; font-size: 1.1rem; }
.modal-box .form-group { margin-bottom: .75rem; }
.modal-box .btn-group { margin-top: 1rem; flex-wrap: wrap; }
.modal-box textarea.input {
  resize: vertical;
  font-family: monospace;
  font-size: .85rem;
}
.alert-success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .85rem;
  margin-top: .5rem;
}

