/* =========================================================
   Mail — Premium Neumorphism (diadopsi dari page/utama.html)
   Full responsive (mobile, tablet, PC)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sniglet:wght@400;600;700&family=Balsamiq+Sans:wght@400;600;700&display=swap');

/* ---------- THEME VARIABLES ---------- */
:root,
[data-theme="light"] {
  --bg: #e0e5ec;
  --text: #4a4a4a;
  --text-soft: #6b7280;
  --shadow-light: #ffffff;
  --shadow-dark: #a3b1c6;
  --accent-1: #214d2e;
  --accent-2: #4caf50;
  --accent-3: #76c86b;
}

[data-theme="dark"] {
  --bg: #292d32;
  --text: #eeeeee;
  --text-soft: #a1a1aa;
  --shadow-light: #3a3f46;
  --shadow-dark: #181b1e;
  --accent-1: #76c86b;
  --accent-2: #4caf50;
  --accent-3: #214d2e;
}

/* ---------- BASE ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Balsamiq Sans', 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  touch-action: manipulation;
  transition: background 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Sniglet', 'Inter', sans-serif;
}

button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--accent-1);
  outline-offset: 3px;
}

.hidden { display: none !important; }

/* ---------- NEUMORPHISM CORE ---------- */
.neu {
  background: var(--bg);
  box-shadow: 8px 8px 16px var(--shadow-dark), -8px -8px 16px var(--shadow-light);
  border-radius: 16px;
}

.neu-inset {
  background: var(--bg);
  box-shadow: inset 6px 6px 12px var(--shadow-dark), inset -6px -6px 12px var(--shadow-light);
  border-radius: 12px;
  border: none;
  color: var(--text);
  font-family: inherit;
}

.neu-btn {
  background: var(--bg);
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  border: none;
  border-radius: 12px;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  transition: all 0.2s;
  font-family: inherit;
  font-size: 13px;
}

.neu-btn:hover { transform: translateY(-1px); }
.neu-btn:active { box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light); transform: none; }

.neu-btn .fa-copy,
.neu-btn .fa-sync-alt,
.neu-btn .fa-plus {
  color: var(--accent-1);
}

.neu-btn.accent { color: var(--accent-2); }
.neu-btn.solid { background: var(--accent-1); color: #fff; }
.neu-btn.solid:hover { background: var(--accent-3); }
.neu-btn.solid:active { box-shadow: inset 3px 3px 6px rgba(0,0,0,0.2); }

/* ---------- LAYOUT ---------- */
.app-wrap {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- HEADER / TOOLBAR ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 16px;
  padding: 0;
  flex: none;
}

.theme-toggle .light-icon { color: #f5b301; }
.theme-toggle .dark-icon { color: #7c8a9e; }

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  color: var(--accent-1);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -3px -3px 6px var(--shadow-light);
  white-space: nowrap;
}

/* ---------- BRAND ---------- */
.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -1px;
  color: var(--accent-1);
}

.brand p {
  font-size: 14px;
  color: var(--text-soft);
}

/* ---------- NEW BOX ---------- */
.new-box {
  padding: 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: slideDown 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.new-box.d-none { display: none; }

.new-box input,
.new-box select {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
}

.new-box input::placeholder { color: var(--text-soft); }
.new-box select { cursor: pointer; }

.new-box-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.new-box-actions .neu-btn { flex: 1; min-width: 120px; }

.new-box .danger {
  padding: 8px;
  font-size: 12px;
  color: #d33c3c;
  background: var(--bg);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- PANEL ---------- */
.panel {
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(163, 177, 198, 0.35);
}

.panel-head h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.panel-head .title-ico { color: var(--accent-2); margin-right: 6px; }

.count-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}

/* ---------- INBOX LIST ---------- */
.inbox-list { min-height: 120px; }

.inbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(163, 177, 198, 0.2);
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
  color: var(--text);
  width: 100%;
  text-align: left;
}

.inbox-item:hover { background: var(--bg); box-shadow: inset 3px 3px 8px var(--shadow-dark), inset -3px -3px 8px var(--shadow-light); }
.inbox-item:last-child { border-bottom: none; }

.inbox-item-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
  letter-spacing: -0.2px;
}

.inbox-delete {
  flex: none;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg);
  color: #d33c3c;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  transition: all 0.2s;
}

.inbox-delete:hover { background: #d33c3c; color: #fff; }

/* ---------- MESSAGE LIST ---------- */
.message-list { min-height: 180px; }

.message-item {
  display: block;
  width: 100%;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(163, 177, 198, 0.2);
  transition: background 0.2s;
  cursor: pointer;
  text-align: left;
  color: var(--text);
}

.message-item:hover { box-shadow: inset 3px 3px 8px var(--shadow-dark), inset -3px -3px 8px var(--shadow-light); }
.message-item:last-child { border-bottom: none; }

.message-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.message-item strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.message-preview {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.6;
  word-break: break-word;
  margin-top: 6px;
  max-height: 90px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.message-preview * { max-width: 100%; }
.message-preview img { max-width: 100%; height: auto; }
.message-preview a { color: var(--accent-1); text-decoration: underline; word-break: break-all; }
.message-preview .plain-body { white-space: pre-wrap; }

/* ---------- PAGINATION ---------- */
.pagination-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid rgba(163, 177, 198, 0.3);
}

.pagination-nav.d-none { display: none; }

.pagination-nav .neu-btn.pg { padding: 8px 16px; font-size: 12px; }

.page-info {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
  white-space: nowrap;
}

/* ---------- DETAIL VIEW ---------- */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
}

.back-btn:hover { color: var(--accent-1); }

.detail-body { padding: 24px 20px; }

.detail-subject {
  font-size: 20px;
  color: var(--text);
  margin-bottom: 12px;
  word-break: break-word;
}

.detail-meta {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(163, 177, 198, 0.3);
}

.detail-html-shell {
  background: var(--bg);
  border-radius: 14px;
  box-shadow: inset 6px 6px 12px var(--shadow-dark), inset -6px -6px 12px var(--shadow-light);
  padding: 16px;
}

.preview-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
  word-break: break-word;
  white-space: normal;
}

.preview-body a { color: var(--accent-1); text-decoration: underline; word-break: break-all; }
.preview-body img { max-width: 100%; height: auto; }
.preview-body table { max-width: 100%; overflow-x: auto; }
.preview-body pre { white-space: pre-wrap; word-break: break-word; max-width: 100%; overflow-x: auto; }
.preview-body h1, .preview-body h2, .preview-body h3, .preview-body h4 { margin: 12px 0 8px; font-weight: 700; }
.preview-body p { margin: 8px 0; }
.preview-body ul, .preview-body ol { padding-left: 22px; margin: 8px 0; }
.preview-body blockquote { margin: 10px 0; padding: 6px 14px; border-left: 4px solid var(--shadow-dark); }
.preview-body hr { border: none; border-top: 1px solid var(--shadow-dark); margin: 16px 0; }
.preview-body button, .preview-body .btn { background: var(--accent-2); color: #fff; border: none; border-radius: 8px; padding: 8px 16px; font-weight: 600; cursor: pointer; }

/* ---------- EMPTY STATES ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-soft);
}

.empty-state .icon { font-size: 40px; margin-bottom: 14px; opacity: 0.4; filter: grayscale(1); }
.empty-state .title { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.empty-state .sub { font-size: 13px; color: var(--text-soft); max-width: 300px; line-height: 1.6; }

/* ---------- FOOTER ---------- */
.app-footer {
  text-align: center;
  padding: 32px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-soft);
}

.app-footer span { color: var(--accent-2); font-weight: 600; }

/* ---------- TOAST ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light);
  animation: toastIn 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.fadeout { animation: toastOut 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards; }

@keyframes toastIn { from { opacity: 0; transform: translateY(20px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(0.96); } }

/* ---------- AUTH / PASSWORD ---------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-overlay.d-none { display: none; }

.auth-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 32px 28px;
}

.auth-icon { font-size: 44px; margin-bottom: 12px; }
.auth-card h2 { font-size: 18px; color: var(--text); }
.auth-card p { font-size: 13px; color: var(--text-soft); line-height: 1.5; }
.auth-card input { width: 100%; padding: 12px 16px; font-size: 14px; margin-bottom: 16px; }
.auth-card .neu-btn.solid { width: 100%; padding: 12px 16px; font-size: 14px; }

.auth-error { margin-top: 12px; font-size: 12px; font-weight: 600; color: #d33c3c; min-height: 16px; }

/* ---------- SWEETALERT THEME ---------- */
.swal2-popup {
  background: var(--bg) !important;
  color: var(--text) !important;
  box-shadow: 10px 10px 20px var(--shadow-dark), -10px -10px 20px var(--shadow-light) !important;
  border: none !important;
  border-radius: 20px !important;
}

.swal2-title { color: var(--text) !important; }
.swal2-html-container { color: var(--text-soft) !important; }
.swal2-confirm, .swal2-cancel { border: none !important; border-radius: 12px !important; box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light) !important; }

.swal2-toast {
  background: var(--bg) !important;
  color: var(--text) !important;
  box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light) !important;
}
.swal2-toast .swal2-title { color: var(--text) !important; }
.swal2-toast .swal2-timer-progress-bar { background: var(--accent-2) !important; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 640px) {
  .app-wrap { padding: 20px 14px 50px; }

  .topbar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .topbar-actions {
    justify-content: stretch;
    flex-wrap: nowrap;
    margin-left: auto;
  }

  .topbar-actions .neu-btn {
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 16px;
    border-radius: 50%;
  }

  .topbar-actions .btn-label { display: none; }

  .brand h1 { font-size: 28px; }

  .panel-head { padding: 14px 16px; }
  .message-item, .inbox-item { padding: 14px 16px; }

  .neu-btn .fa-copy, .neu-btn .fa-sync-alt, .neu-btn .fa-plus { font-size: 16px; }
}