/* ============================================================
   APEX POS Mail — Stylesheet
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --color-bg: #f4f4f8;
  --color-surface: #ffffff;
  --color-surface-2: #f0f0f5;
  --color-border: #e2e2ea;
  --color-primary: #6366f1;
  --color-primary-dim: #eef2ff;
  --color-text: #111827;
  --color-text-muted: #6b7280;
  --color-danger: #ef4444;
  --color-success: #22c55e;
  --color-unread-bg: #eef2ff;
  --sidebar-w: 240px;
  --list-w: 320px;
  --radius: 10px;
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
  --color-bg: #0f0f1a;
  --color-surface: #1a1a2e;
  --color-surface-2: #16213e;
  --color-border: #2a2a45;
  --color-primary: #818cf8;
  --color-primary-dim: #1e1e3f;
  --color-text: #e5e7eb;
  --color-text-muted: #9ca3af;
  --color-danger: #f87171;
  --color-success: #4ade80;
  --color-unread-bg: #1e1e3f;
  --shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
}

/* ── Reset ───────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  font-family: "DM Sans", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  transition:
    background 0.2s,
    color 0.2s;
}
button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}
input,
textarea {
  font-family: inherit;
  font-size: inherit;
}
svg {
  display: block;
}

/* ── Spinner ─────────────────────────────────────────────── */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.spin {
  animation: spin 0.7s linear infinite;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 99999;
  pointer-events: none;
}
[dir="rtl"] #toast-container {
  right: auto;
  left: 16px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  min-width: 260px;
  max-width: calc(100vw - 32px);
  pointer-events: all;
  animation: toastIn 300ms ease forwards;
  border-left: 4px solid #475569;
}
.toast.toast-success {
  border-left-color: #22c55e;
}
.toast.toast-error {
  border-left-color: #ef4444;
}
.toast.toast-warning {
  border-left-color: #f59e0b;
}
.toast.toast-info {
  border-left-color: #6366f1;
}
.toast.removing {
  animation: toastOut 300ms ease forwards;
}

[dir="rtl"] .toast {
  border-left: none;
  border-right: 4px solid #475569;
}
[dir="rtl"] .toast.toast-success {
  border-right-color: #22c55e;
  border-left: none;
}
[dir="rtl"] .toast.toast-error {
  border-right-color: #ef4444;
  border-left: none;
}
[dir="rtl"] .toast.toast-warning {
  border-right-color: #f59e0b;
  border-left: none;
}
[dir="rtl"] .toast.toast-info {
  border-right-color: #6366f1;
  border-left: none;
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-body {
  flex: 1;
}
.toast-title {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 2px;
}
.toast-msg {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.95);
  }
}

/* ── Page controls ───────────────────────────────────────── */
.page-controls {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 100;
}
[dir="rtl"] .page-controls {
  right: auto;
  left: 16px;
}
.ctrl-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.ctrl-btn:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.ctrl-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Hidden ──────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(
    ellipse at 60% 40%,
    var(--color-primary-dim) 0%,
    var(--color-bg) 60%
  );
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.1);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
/* .login-brand-icon {
  width: 100%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
} */
.login-brand-icon svg {
  width: 26px;
  height: 26px;
}
.login-title {
  font-size: 22px;
  font-weight: 600;
}
.login-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

.login-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 16px;
  color: var(--color-danger);
  font-size: 13px;
}
[data-theme="dark"] .login-alert {
  background: #2d1b1b;
  border-color: #7f1d1d;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 13px;
  font-weight: 500;
}
.form-input-wrap {
  position: relative;
}
.form-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}
[dir="rtl"] .form-input-icon {
  left: auto;
  right: 12px;
}
.form-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-surface-2);
  color: var(--color-text);
  outline: none;
  transition: border 0.15s;
}
[dir="rtl"] .form-input {
  padding: 10px 38px 10px 12px;
}
.form-input:focus {
  border-color: var(--color-primary);
}
.eye-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  padding: 4px;
  display: flex;
  align-items: center;
}
[dir="rtl"] .eye-toggle {
  right: auto;
  left: 10px;
}
.eye-toggle:hover {
  color: var(--color-primary);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  transition:
    opacity 0.15s,
    transform 0.1s;
}
.btn-primary svg {
  width: 16px;
  height: 16px;
}
.btn-primary:hover {
  opacity: 0.9;
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--color-text-muted);
}
.login-footer a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  margin-top: 20px;
}
.login-footer span {
  font-weight: 600;
  margin-top: 20px;
}

/* ══════════════════════════════════════════════════════════
   MAIL APP LAYOUT
══════════════════════════════════════════════════════════ */
.mail-app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* ── Mobile back button ──────────────────────────────────── */
.mobile-back {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 7px;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  background: var(--color-primary-dim);
}
.mobile-back svg {
  width: 16px;
  height: 16px;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease;
  z-index: 200;
}
[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--color-border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo svg {
  width: 17px;
  height: 17px;
}
.sidebar-brand {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
}
.sidebar-brand small {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 400;
}

.compose-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 12px 8px;
  padding: 10px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
}
.compose-btn svg {
  width: 16px;
  height: 16px;
}
.compose-btn:hover {
  opacity: 0.88;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 8px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  border-radius: 7px;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.12s;
  text-align: left;
  position: relative;
}
[dir="rtl"] .nav-item {
  text-align: right;
}
.nav-item:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.nav-item.active {
  background: var(--color-primary-dim);
  color: var(--color-primary);
}
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--color-primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}
[dir="rtl"] .nav-badge {
  margin-left: 0;
  margin-right: auto;
}

.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding: 12px;
}
.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.user-info {
  flex: 1;
  overflow: hidden;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  color: var(--color-text-muted);
  padding: 4px;
  display: flex;
  transition: color 0.12s;
}
.logout-btn:hover {
  color: var(--color-danger);
}
.logout-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Main ────────────────────────────────────────────────── */
.mail-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.mail-navbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 54px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.navbar-title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}
.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 12px;
  max-width: 480px;
  margin: 0 auto;
}
.search-bar svg {
  width: 15px;
  height: 15px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.search-bar input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  color: var(--color-text);
  font-size: 13px;
}
.navbar-actions {
  display: flex;
  gap: 4px;
}
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: all 0.12s;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ── Hamburger menu button ───────────────────────────────── */
.menu-btn {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 7px;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.menu-btn svg {
  width: 20px;
  height: 20px;
}

/* ── Content ─────────────────────────────────────────────── */
.mail-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Email List ──────────────────────────────────────────── */
.email-list-panel {
  width: var(--list-w);
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease;
}
[dir="rtl"] .email-list-panel {
  border-right: none;
  border-left: 1px solid var(--color-border);
}
.email-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.email-list-title {
  font-weight: 600;
  font-size: 13px;
}
.email-count {
  font-size: 11px;
  color: var(--color-text-muted);
}
.email-list {
  flex: 1;
  overflow-y: auto;
}

.email-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
  position: relative;
}
.email-item:hover {
  background: var(--color-surface-2);
}
.email-item.active {
  background: var(--color-primary-dim);
}
.email-item.unread {
  background: var(--color-unread-bg);
}
.email-item.unread.active {
  background: var(--color-primary-dim);
}

.unread-dot {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-primary);
}
[dir="rtl"] .unread-dot {
  left: auto;
  right: 6px;
}
.email-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.email-meta {
  flex: 1;
  overflow: hidden;
}
.email-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.email-sender-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.email-time {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.email-subject {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.email-preview {
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.email-item.unread .email-sender-name,
.email-item.unread .email-subject {
  color: var(--color-primary);
}

/* ── Reading Pane ────────────────────────────────────────── */
.reading-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-surface);
  transition: transform 0.25s ease;
}
.reading-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  gap: 10px;
}
.reading-empty svg {
  width: 40px;
  height: 40px;
  opacity: 0.35;
}
.reading-empty p {
  font-size: 13px;
}

.reading-header {
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.reading-subject {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}
.reading-from {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.reading-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.reading-sender-name {
  font-size: 13px;
  font-weight: 600;
}
.reading-sender-email {
  font-size: 12px;
  color: var(--color-text-muted);
}
.reading-date-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
[dir="rtl"] .reading-date-actions {
  margin-left: 0;
  margin-right: auto;
}
.reading-date {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-right: 6px;
}
.reading-action-btn {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: all 0.12s;
}
.reading-action-btn svg {
  width: 15px;
  height: 15px;
}
.reading-action-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.reading-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
.reading-body-text {
  font-size: 14px;
  line-height: 1.7;
}
.reading-body-text img {
  max-width: 100%;
  height: auto;
}

.reply-bar {
  border-top: 1px solid var(--color-border);
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.reply-input {
  flex: 1;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 17px 12px;
  background: var(--color-surface-2);
  color: var(--color-text);
  outline: none;
  resize: none;
  height: 40px;
  min-height: 40px;
  max-height: 120px;
  font-size: 13px;
  transition: border 0.15s;
}
.reply-input:focus {
  border-color: var(--color-primary);
}
.reply-send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.reply-send-btn svg {
  width: 14px;
  height: 14px;
}
.reply-send-btn:hover {
  opacity: 0.88;
}

/* ── Compose Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 16px;
  pointer-events: none;
}
.compose-modal {
  width: 100%;
  max-width: 520px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: all;
  animation: popUp 0.2s ease;
  max-height: 90vh;
}
@keyframes popUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.compose-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-primary);
  flex-shrink: 0;
}
.compose-modal-title {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
.modal-close-btn {
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  transition: color 0.12s;
}
.modal-close-btn:hover {
  color: #fff;
}
.modal-close-btn svg {
  width: 18px;
  height: 18px;
}

.compose-field {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
}
.compose-field-label {
  width: 56px;
  padding: 10px 12px;
  font-size: 11px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.compose-field input {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: none;
  color: var(--color-text);
  outline: none;
  font-size: 13px;
}
.compose-body {
  flex: 1;
  overflow: hidden;
}
.compose-body textarea {
  width: 100%;
  height: 160px;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--color-text);
  outline: none;
  resize: none;
  font-size: 13px;
  line-height: 1.6;
}
.compose-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}
.compose-actions {
  display: flex;
  gap: 4px;
}
.compose-tool-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: all 0.12s;
}
.compose-tool-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}
.compose-tool-btn svg {
  width: 16px;
  height: 16px;
}
.compose-send-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: opacity 0.15s;
}
.compose-send-btn svg {
  width: 14px;
  height: 14px;
}
.compose-send-btn:hover {
  opacity: 0.88;
}
.compose-send-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Sidebar overlay (mobile) ────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible {
  display: block;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 99px;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — TABLET (max 900px)
══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  :root {
    --list-w: 280px;
    --sidebar-w: 220px;
  }
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (max 640px)
══════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  :root {
    --sidebar-w: 80vw;
  }

  /* Sidebar slides in as drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    z-index: 200;
  }
  [dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Show hamburger */
  .menu-btn {
    display: flex !important;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    color: var(--color-text);
    position: relative;
    z-index: 20;
    pointer-events: all;
  }

  /* Navbar */
  .mail-navbar {
    padding: 0 10px;
    gap: 6px;
    position: relative;
    z-index: 20;
  }

  .navbar-actions {
    flex-shrink: 0;
    display: flex;
    gap: 2px;
    position: relative;
    z-index: 20;
    pointer-events: all;
  }

  .icon-btn {
    position: relative;
    z-index: 20;
    pointer-events: all;
  }

  /* Search takes remaining space */
  .search-bar {
    max-width: none;
    margin: 0;
    flex: 1;
    position: relative;
    z-index: 10;
  }

  /* Hide list title and count */
  .email-list-title {
    display: none !important;
  }
  .email-count {
    display: none;
  }

  /* Email list panel — starts BELOW navbar */
  .email-list-panel {
    position: absolute;
    top: 54px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 10;
    border-right: none;
  }
  .email-list-panel.hidden-mobile {
    display: none;
  }

  /* Reading pane — starts BELOW navbar */
  .reading-pane {
    position: absolute;
    top: 54px;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 10;
    display: none;
  }
  .reading-pane.visible-mobile {
    display: flex;
  }

  /* Show back button in reading pane */
  .mobile-back {
    display: flex;
    margin-bottom: 10px;
  }

  /* Compose full width on mobile */
  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }
  .compose-modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 95vh;
  }

  /* Reading header compact */
  .reading-header {
    padding: 12px 16px;
  }
  .reading-subject {
    font-size: 15px;
  }
  .reading-body {
    padding: 16px;
  }

  /* Reply bar compact */
  .reply-bar {
    padding: 8px 10px;
    gap: 6px;
  }
  .reply-send-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Toast full width */
  #toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast {
    min-width: 0;
    width: 100%;
  }

  .email-list-header {
    display: none;
  }
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 3px;
  cursor: pointer;
  gap: 0;
  user-select: none;
}
.lang-toggle-option {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 28px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  transition:
    background 0.2s,
    color 0.2s;
  color: var(--color-text-muted);
}
.lang-toggle-option.active {
  background: #4f46e5;
  color: #fff;
}
