/* Trustary Tmail - CSS Khusus Aplikasi & Desain FUSIONIFY UI
   Menggunakan 100% token tema resmi dari css/tokens.css */

.tmail-app {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gut);
}

/* =========================================================
   BASE STABILITY FOR MOBILE (iOS & ANDROID)
   ========================================================= */
html, body {
  overflow-x: clip;
  width: 100%;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Visibility Utilities */
.m-only { display: none !important; }
.d-only { display: inline-flex !important; }

@media (max-width: 768px) {
  .m-only { display: inline-flex !important; }
  .m-only.block, .m-only-block { display: block !important; }
  .d-only { display: none !important; }
  
  /* Prevent iOS Safari auto-zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* =========================================================
   HERO & GENERATOR BOX
   ========================================================= */
.tmail-hero {
  padding: clamp(28px, 5vw, 64px) 0 clamp(20px, 3.5vw, 48px);
  background: radial-gradient(120% 80% at 80% 10%, var(--hero-glow) 0%, transparent 60%);
}

.tmail-hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: clamp(20px, 4vw, 44px);
  align-items: center;
}

@media (max-width: 880px) {
  .tmail-hero-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .tmail-mascot-wrap {
    order: 2;
    margin: 12px auto 0;
    width: 100%;
    overflow-x: clip;
    overflow-y: visible;
    padding-top: 12px;
  }
  .tmail-mascot-wrap .mascot-stage {
    width: min(85%, 230px) !important;
    aspect-ratio: 1;
  }
  .tmail-mascot-wrap .mascot-stage .body {
    max-height: 180px !important;
    width: auto !important;
  }
  .tmail-mascot-wrap .bubble.say {
    font-size: 12.5px !important;
    padding: 6px 14px !important;
    top: 6px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    white-space: normal !important;
    text-align: center !important;
    max-width: 92% !important;
  }
}

.tmail-box {
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-sticker);
  padding: clamp(18px, 3.2vw, 28px);
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.tmail-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.tmail-box-label {
  font-family: var(--f-num);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.tmail-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--edge);
  border-radius: var(--r-m);
  padding: 8px 10px;
  gap: 10px;
  box-shadow: inset 0 2px 4px rgba(11, 15, 26, 0.04);
}

.tmail-prefix-box {
  display: flex;
  align-items: center;
  flex: 1 1 200px;
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: var(--r-s);
  padding: 2px 10px;
  box-shadow: 0 2px 0 var(--edge-shadow);
  min-width: 0;
}

.tmail-prefix-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--f-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  padding: 8px 4px;
  min-width: 0;
  outline: none;
}

.tmail-at {
  font-family: var(--f-num);
  font-size: 18px;
  font-weight: 800;
  color: var(--blue);
  user-select: none;
  padding: 0 4px;
  flex: none;
}

.tmail-domain-select {
  flex: 1 1 200px;
  border: 2px solid var(--edge);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r-s);
  padding: 8px 12px;
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  outline: none;
  box-shadow: 0 2px 0 var(--edge-shadow);
  min-height: 44px;
  min-width: 0;
  transition: border-color 0.2s;
}

.tmail-domain-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  margin-top: -4px;
}

.tmail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tmail-actions .btn {
  flex: 1 1 auto;
  justify-content: center;
}

/* =========================================================
   MASCOT STAGE INTEGRATION
   ========================================================= */
.tmail-mascot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: clip;
  overflow-y: visible;
  padding-top: 14px;
}

.tmail-mascot-wrap .mascot-stage {
  width: min(100%, 340px);
  position: relative;
}

.tmail-mascot-wrap .bubble.say {
  position: absolute;
  top: 4%;
  left: 50% !important;
  transform: translateX(-50%) !important;
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 13.5px;
  line-height: 1.35;
  white-space: normal;
  text-align: center;
  max-width: 270px;
  width: max-content;
  padding: 8px 14px;
  border-radius: var(--r-m);
  background: var(--card);
  border: 2px solid var(--edge);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
  z-index: 5;
}

.tmail-mascot-wrap .bubble.say::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  right: auto;
  transform: translateX(-50%) rotate(45deg);
  width: 14px;
  height: 14px;
  background: var(--card);
  border-right: 2px solid var(--edge);
  border-bottom: 2px solid var(--edge);
}

/* =========================================================
   KOTAK MASUK (INBOX)
   ========================================================= */
.tmail-inbox-section {
  padding: 20px 0 60px;
}

.tmail-inbox-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.tmail-inbox-timer {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-2);
  font-family: var(--f-num);
}

.tmail-timer-bar-wrap {
  width: 80px;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.tmail-timer-bar {
  height: 100%;
  width: 100%;
  background: var(--blue);
  transition: width 0.3s linear;
}

.tmail-inbox-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 0;
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-sticker);
  overflow: hidden;
  min-height: 540px;
}

@media (max-width: 900px) {
  .tmail-inbox-grid {
    grid-template-columns: 1fr;
  }
  .tmail-inbox-grid.has-selected .tmail-list-panel {
    display: none;
  }
  .tmail-inbox-grid:not(.has-selected) .tmail-detail-panel {
    display: none;
  }
}

.tmail-list-panel {
  border-right: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  background: var(--card);
}

.tmail-list-search {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.tmail-mail-items {
  flex: 1;
  overflow-y: auto;
  max-height: 580px;
}

.tmail-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s;
  display: grid;
  gap: 5px;
  position: relative;
}

.tmail-item:hover {
  background: var(--surface);
}

.tmail-item.active {
  background: var(--surface-2);
  border-left: 4px solid var(--blue);
}

.tmail-item-from {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tmail-item-time {
  font-size: 12px;
  font-family: var(--f-num);
  color: var(--ink-3);
}

.tmail-item-subject {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-blue-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tmail-item-snippet {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tmail-item-otp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  background: var(--go-bg);
  color: var(--go);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-family: var(--f-num);
  font-weight: 800;
  width: fit-content;
}

/* Detail Panel */
.tmail-detail-panel {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  min-height: 480px;
}

.tmail-detail-empty {
  margin: auto;
  text-align: center;
  padding: 40px 20px;
  display: grid;
  gap: 14px;
  justify-items: center;
  max-width: 360px;
}

.tmail-detail-header {
  padding: 18px 22px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

.tmail-otp-banner {
  background: var(--go-bg);
  border: 2px solid var(--go);
  border-radius: var(--r-m);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 20px 0;
  box-shadow: 0 2px 0 var(--edge-shadow);
}

.tmail-otp-digits {
  font-family: var(--f-num);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--go);
}

.tmail-detail-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--line);
  background: var(--card);
}

.tmail-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 14px;
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--ink-2);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tmail-tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.tmail-detail-body {
  padding: 20px;
  flex: 1;
  overflow-y: auto;
  max-height: 520px;
  background: var(--card);
  margin: 16px 20px 20px;
  border-radius: var(--r-m);
  border: 1px solid var(--line);
}

.tmail-html-frame {
  width: 100%;
  min-height: 380px;
  border: none;
  background: #ffffff;
}

/* =========================================================
   CLOUDFLARE UNIFIED MODAL
   ========================================================= */
.cf-modal-box {
  display: grid;
  gap: 18px;
}

.cf-domain-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
  padding-right: 4px;
}

.cf-domain-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  font-size: 13.5px;
}

.cf-contribute-card {
  background: var(--surface);
  border: 1.5px solid var(--edge);
  border-radius: var(--r-m);
  padding: 14px 16px;
  box-shadow: 0 2px 0 var(--edge-shadow);
}

/* =========================================================
   DOKUMENTASI REST API
   ========================================================= */
.docs-nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 18px;
  padding-bottom: 6px;
}

.docs-tab-btn {
  background: transparent;
  border: 2px solid transparent;
  padding: 7px 14px;
  border-radius: var(--r-s);
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.15s ease;
}

.docs-tab-btn:hover {
  background: var(--surface);
  color: var(--ink);
}

.docs-tab-btn.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--edge);
  box-shadow: 0 2px 0 var(--edge-shadow);
}

.endpoint-badge {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 6px;
  font-family: var(--f-num);
  font-weight: 800;
  font-size: 11.5px;
  letter-spacing: 0.04em;
}

.endpoint-badge.post { background: var(--go-bg); color: var(--go); border: 1px solid var(--go); }
.endpoint-badge.get { background: var(--surface); color: var(--text-blue-deep); border: 1px solid var(--blue-light); }
.endpoint-badge.delete { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }

/* =========================================================
   RESPONSIVE NAVIGATION & MOBILE DRAWER (iOS & ANDROID)
   ========================================================= */
.topbar {
  position: sticky !important;
  top: 0 !important;
  z-index: 100 !important;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) clamp(16px, 3vw, 32px) 12px;
  background: var(--nav-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 2px solid var(--edge);
  box-shadow: 0 2px 0 var(--edge-shadow);
}

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

.nav-mobile-btn {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: var(--r-m);
  border: 2px solid var(--edge);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 var(--edge-shadow);
  transition: all 0.15s ease;
  flex: none;
}

.nav-mobile-btn:active {
  transform: translateY(2px);
  box-shadow: none;
}

@media (max-width: 920px) {
  .topbar-nav-desktop {
    display: none !important;
  }
  .nav-mobile-btn {
    display: inline-flex !important;
  }
}

/* Mobile Nav Drawer Overlay & Drawer (Z-Index Hierarchy: Scrim 90 < Drawer 95 < Topbar 100) */
.mobile-nav-scrim {
  position: fixed;
  inset: 0;
  background: rgba(7, 16, 34, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s;
}

.mobile-nav-scrim.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-bottom: 2.5px solid var(--edge);
  box-shadow: 0 8px 24px rgba(7, 16, 34, 0.18), var(--shadow-pop);
  z-index: 95;
  padding-top: calc(max(12px, env(safe-area-inset-top)) + 64px);
  padding-inline: clamp(16px, 4vw, 24px);
  padding-bottom: 24px;
  display: none;
  flex-direction: column;
  gap: 10px;
  transform: translateY(-100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease, visibility 0.28s;
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
}

@media (max-width: 920px) {
  .mobile-nav-drawer {
    display: flex;
  }
}

.mobile-nav-drawer.open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.mobile-nav-drawer .btn {
  width: 100%;
  justify-content: flex-start;
  padding: 12px 18px;
  font-size: 15px;
  min-height: 48px;
  border-radius: var(--r-m);
}

.mobile-nav-divider {
  height: 1px;
  background: var(--line);
  margin: 6px 0;
}

/* =========================================================
   RESPONSIVE GENERATOR BOX & ACTIONS ON MOBILE (< 640px)
   ========================================================= */
@media (max-width: 640px) {
  .tmail-box {
    padding: 16px 14px;
    gap: 14px;
    border-radius: var(--r-m);
  }

  .tmail-input-wrap {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 8px;
    background: var(--surface);
  }

  .tmail-prefix-box {
    display: flex;
    align-items: center;
    background: var(--card);
    border: 2px solid var(--edge);
    border-radius: var(--r-s);
    padding: 2px 10px;
    box-shadow: inset 0 2px 4px rgba(11, 15, 26, 0.04);
  }

  .tmail-prefix-input {
    flex: 1;
    font-size: 16px !important;
    padding: 8px 4px;
    min-width: 0;
  }

  .tmail-at {
    padding: 0 4px;
    font-size: 18px;
  }

  .tmail-domain-select {
    width: 100% !important;
    min-height: 46px;
    font-size: 16px !important;
    padding: 10px 14px;
    border-radius: var(--r-s);
  }

  .tmail-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .tmail-actions .btn {
    min-height: 46px;
    font-size: 14px;
    padding: 8px 10px;
    justify-content: center;
  }

  .tmail-inbox-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .tmail-inbox-timer {
    width: 100%;
    justify-content: space-between;
  }

  .tmail-timer-bar-wrap {
    flex: 1;
    margin: 0 8px;
  }
}

/* =========================================================
   RESPONSIVE INBOX & DETAIL PANEL (< 900px)
   ========================================================= */
@media (max-width: 900px) {
  .tmail-inbox-grid {
    grid-template-columns: 1fr;
    min-height: auto;
    border-radius: var(--r-m);
  }

  .tmail-inbox-grid.has-selected .tmail-list-panel {
    display: none !important;
  }

  .tmail-inbox-grid:not(.has-selected) .tmail-detail-panel {
    display: none !important;
  }

  .tmail-mail-items {
    max-height: 460px;
  }

  .tmail-item {
    padding: 12px 14px;
  }

  .tmail-detail-header {
    padding: 14px 16px;
  }

  .btn-back-to-inbox {
    display: inline-flex !important;
    margin-bottom: 12px;
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-weight: 800;
  }

  .tmail-html-frame {
    width: 100%;
    max-width: 100%;
    min-width: 100%;
  }

  .tmail-detail-body {
    padding: 12px 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tmail-otp-banner {
    margin: 10px 12px 0;
    padding: 10px 14px;
  }

  .tmail-otp-digits {
    font-size: 22px;
    letter-spacing: 2px;
  }

  .tmail-detail-tabs {
    padding: 6px 12px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.modal-wrap {
  padding: 12px;
}

.modal.card {
  max-height: calc(100dvh - 32px);
  -webkit-overflow-scrolling: touch;
}

/* =========================================================
   DOCS & CODE TABS RESPONSIVENESS ON MOBILE
   ========================================================= */
@media (max-width: 768px) {
  .docs-nav-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    margin-bottom: 14px;
  }

  .docs-tab-btn {
    white-space: nowrap;
    flex: none;
    font-size: 13.5px;
    padding: 8px 14px;
  }

  .code-block pre {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px !important;
  }
}

/* =========================================================
   TABLE RESPONSIVENESS (ADMIN & DATA)
   ========================================================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
  .table {
    min-width: 580px;
  }
}



