/* ==========================================================================
   VaultMail - Design System & Modern Glassmorphism Styling
   Tokens & Variables (UI/UX Pro Max certified)
   ========================================================================== */

:root {
  /* Colors */
  --bg-dark: #090D16;
  --bg-surface: rgba(17, 24, 39, 0.75);
  --bg-surface-elevated: rgba(24, 34, 53, 0.85);
  --bg-card: rgba(15, 23, 42, 0.65);
  --bg-glass-input: rgba(11, 17, 32, 0.8);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: rgba(59, 130, 246, 0.6);
  
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: rgba(37, 99, 235, 0.15);
  
  --accent-cyan: #06B6D4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.2);
  
  --success: #10B981;
  --success-glow: rgba(16, 185, 129, 0.25);
  
  --destructive: #EF4444;
  --destructive-hover: #DC2626;
  --destructive-light: rgba(239, 68, 68, 0.12);
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  
  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, monospace;
  
  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* Shadows & Glass */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 24px -2px rgba(37, 99, 235, 0.25);
  --backdrop-blur: blur(16px);
  
  /* Transitions */
  --ease-smooth: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --ease-slow: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset & Typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.font-mono {
  font-family: var(--font-mono);
}

/* Background Ambient Meshes */
.app-background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.mesh-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.35;
}

.blob-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #2563EB, #1D4ED8);
  top: -150px;
  left: -100px;
}

.blob-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #06B6D4, #3B82F6);
  bottom: -120px;
  right: -80px;
}

.blob-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #7C3AED, transparent);
  top: 40%;
  left: 35%;
  opacity: 0.15;
}

/* Layout */
.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--bg-surface);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(6, 182, 212, 0.35);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.25);
  overflow: hidden;
  padding: 3px;
  transition: var(--ease-smooth);
}

.brand-icon:hover {
  border-color: rgba(6, 182, 212, 0.7);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
  transform: translateY(-1px);
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-text h1 span {
  color: var(--accent-cyan);
}

.badge-persistent {
  background: rgba(16, 185, 129, 0.12);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success-glow);
  animation: pulse-dot 2.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Main Container: Sidebar + Workspace */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 64px);
}

/* Sidebar */
.sidebar {
  width: 340px;
  background: var(--bg-surface);
  backdrop-filter: var(--backdrop-blur);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title-row h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.count-badge {
  background: var(--primary-light);
  color: #60A5FA;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-dim);
  transition: var(--ease-smooth);
}

.search-box:focus-within {
  border-color: var(--border-focus);
  color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.85rem;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

/* Account List Items */
.account-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: var(--ease-smooth);
  user-select: none;
}

.account-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-hover);
}

.account-item.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.4);
}

.account-item-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.account-tag-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-address-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-item.active .account-address-text {
  color: #93C5FD;
}

.account-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-item-action {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 5px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--ease-smooth);
}

.btn-item-action:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.1);
}

.btn-item-action.action-delete:hover {
  color: var(--destructive);
  background: var(--destructive-light);
}

/* Sidebar Footer & Backup Actions */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: rgba(11, 15, 25, 0.7);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.data-privacy-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-dim);
  justify-content: center;
}

/* Workspace / Main Content */
.content-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: transparent;
}

/* Active Account Card */
.active-account-card {
  padding: 20px 28px;
  background: var(--bg-surface);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.active-account-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.active-label-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #60A5FA;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-icon-inline {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  transition: var(--ease-smooth);
}

.btn-icon-inline:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.email-display-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.active-email-address {
  font-size: 1.4rem;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.5px;
  word-break: break-all;
}

.account-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.account-meta-divider {
  color: var(--border-subtle);
}

.account-meta-link {
  background: none;
  border: none;
  color: #93C5FD;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  padding: 2px 0;
  transition: var(--ease-smooth);
}

.account-meta-link:hover {
  color: #FFFFFF;
  text-decoration: underline;
}

/* Controls & Countdown Bar */
.active-account-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.refresh-control-group {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.btn-icon-round {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--ease-smooth);
}

.btn-icon-round:hover {
  background: var(--primary-light);
  color: #60A5FA;
  border-color: rgba(37, 99, 235, 0.4);
}

.rotating {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.refresh-countdown {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 90px;
}

.countdown-text {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.countdown-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.countdown-progress {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #2563EB, #06B6D4);
  transition: width 1s linear;
}

/* Inbox Section Layout */
.inbox-section {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Message Feed Pane */
.inbox-list-pane {
  width: 380px;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  background: rgba(11, 15, 25, 0.4);
  flex-shrink: 0;
}

.inbox-pane-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.inbox-heading-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inbox-heading-row h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.inbox-count-pill {
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--ease-smooth);
}

.btn-text-danger:hover {
  color: var(--destructive);
  text-decoration: underline;
}

/* Messages Container */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-item {
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--ease-smooth);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.message-item:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.message-item.active {
  background: rgba(37, 99, 235, 0.12);
  border-color: rgba(37, 99, 235, 0.4);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.message-item.unread::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent-cyan);
  box-shadow: 0 0 6px var(--accent-cyan);
}

.msg-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.msg-sender {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-time {
  font-size: 0.72rem;
  color: var(--text-dim);
  flex-shrink: 0;
}

.msg-subject {
  font-size: 0.82rem;
  font-weight: 500;
  color: #CBD5E1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-snippet {
  font-size: 0.75rem;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.msg-otp-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(6, 182, 212, 0.15);
  color: #22D3EE;
  border: 1px solid rgba(6, 182, 212, 0.3);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  width: fit-content;
  margin-top: 4px;
}

/* Empty State */
.empty-inbox-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
}

.radar-beacon {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60A5FA;
  margin-bottom: 16px;
}

.radar-wave {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.4);
  animation: radar-pulse 2s infinite ease-out;
}

@keyframes radar-pulse {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.empty-inbox-state h4 {
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-inbox-state p {
  font-size: 0.8rem;
  color: var(--text-dim);
  max-width: 260px;
}

/* Reader Pane */
.inbox-reader-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-surface);
}

.reader-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  text-align: center;
  padding: 40px;
}

.empty-icon-wrap {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: var(--text-muted);
}

.reader-empty-state h4 {
  font-size: 1.1rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

.reader-empty-state p {
  font-size: 0.85rem;
  max-width: 360px;
}

.reader-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.reader-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-shrink: 0;
}

.reader-subject-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.reader-subject {
  font-size: 1.25rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.3;
}

.reader-sender-details {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sender-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3B82F6, #1E40AF);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.sender-meta {
  display: flex;
  flex-direction: column;
}

.sender-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.sender-email {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.reader-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Smart OTP Highlight Card */
.otp-highlight-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.15), rgba(37, 99, 235, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.15);
}

.otp-card-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.otp-badge-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #38BDF8;
  letter-spacing: 0.5px;
}

.otp-code-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: 4px;
}

/* Reader Body & View Tabs */
.reader-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #FFFFFF;
}

.body-view-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  background: #0F172A;
  border-bottom: 1px solid var(--border-subtle);
}

.view-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--ease-smooth);
}

.view-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.view-tab.active {
  background: var(--primary);
  color: #FFFFFF;
}

.body-frame-container {
  flex: 1;
  height: 100%;
}

.body-frame-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #FFFFFF;
}

.body-text-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background-color: #0F172A;
  color: #E2E8F0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.body-text-container pre {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--ease-smooth);
  user-select: none;
  min-height: 40px;
}

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

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-hover);
}

.btn-copy {
  padding: 8px 14px;
  font-size: 0.8rem;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--border-hover);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.btn-destructive {
  background: var(--destructive-light);
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.25);
}

.btn-destructive:hover {
  background: var(--destructive);
  color: #FFFFFF;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  min-height: 32px;
}

.icon-only {
  padding: 8px;
  width: 40px;
  height: 40px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal-dialog {
  background: #111827;
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop.show .modal-dialog {
  transform: scale(1);
}

.modal-dialog-sm {
  max-width: 400px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
}

.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input,
.select-field {
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  font-family: var(--font-sans);
  transition: var(--ease-smooth);
}

.form-group input:focus,
.select-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.input-with-domain {
  display: flex;
  align-items: center;
  background: var(--bg-glass-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.input-with-domain input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
}

.domain-prefix {
  padding: 0 14px;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.9rem;
}

.input-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.copy-input-row {
  display: flex;
  gap: 8px;
}

.copy-input-row input {
  flex: 1;
}

.toggle-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.pill-btn {
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--ease-smooth);
}

.pill-btn.active {
  background: var(--primary);
  color: #FFFFFF;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(11, 15, 25, 0.4);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #1E293B;
  color: #FFFFFF;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hover);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
  animation: toast-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success {
  border-left: 4px solid var(--success);
}

.toast.info {
  border-left: 4px solid var(--accent-cyan);
}

.toast.error {
  border-left: 4px solid var(--destructive);
}

@keyframes toast-in {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   Responsive Rules & Mobile Optimization (UI/UX Pro Max)
   ========================================================================== */

.mobile-only {
  display: none;
}

.btn-back-mobile {
  display: none !important;
}

.btn-close-sidebar-mobile {
  display: none !important;
}

.sidebar-backdrop {
  display: none !important;
}

@media (max-width: 1024px) {
  .inbox-list-pane {
    width: 320px;
  }
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex;
  }

  .btn-back-mobile {
    display: inline-flex !important;
  }

  .btn-close-sidebar-mobile {
    display: flex !important;
  }

  .sidebar-backdrop {
    display: block !important;
  }

  /* Page Shell & Viewport */
  body {
    overflow-y: auto;
  }

  .app-layout {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .main-container {
    height: auto;
    min-height: calc(100dvh - 60px);
    flex-direction: column;
    overflow: visible;
  }

  /* Compact Navbar */
  .app-header {
    height: 60px;
    padding: 0 12px;
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-icon {
    width: 34px;
    height: 34px;
  }

  .brand-text h1 {
    font-size: 1.1rem;
  }

  .badge-persistent {
    display: none !important;
  }

  .header-actions {
    gap: 6px;
  }

  .status-indicator {
    padding: 6px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.1);
  }

  .status-text {
    display: none;
  }

  #btnOpenNewModal {
    padding: 7px 10px;
    font-size: 0.78rem;
    min-height: 36px;
    gap: 4px;
  }

  #btnOpenNewModal span {
    display: inline;
  }

  #btnMobileSidebarToggle {
    width: 36px;
    height: 36px;
    padding: 6px;
  }

  /* Active Account Card */
  .active-account-card {
    padding: 14px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .active-label-badge {
    font-size: 0.75rem;
  }

  .email-display-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: rgba(11, 17, 32, 0.75);
    border: 1px solid var(--border-subtle);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
  }

  .active-email-address {
    font-size: clamp(0.92rem, 3.8vw, 1.15rem);
    word-break: break-all;
    line-height: 1.35;
    flex: 1;
    margin: 0;
  }

  .btn-copy {
    padding: 6px 12px;
    font-size: 0.75rem;
    min-height: 34px;
    flex-shrink: 0;
  }

  .account-meta-row {
    font-size: 0.75rem;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
  }

  .account-meta-divider {
    display: none;
  }

  .active-account-controls {
    width: 100%;
    margin-top: 2px;
  }

  .refresh-control-group {
    width: 100%;
    justify-content: space-between;
    padding: 6px 12px;
  }

  /* Mobile Master-Detail Inbox */
  .inbox-section {
    flex-direction: column;
    flex: 1;
    min-height: 380px;
    position: relative;
    overflow: visible;
  }

  /* Default view on mobile: Message List only */
  .inbox-list-pane {
    width: 100%;
    height: auto;
    min-height: 380px;
    border-right: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
  }

  .inbox-reader-pane {
    display: none;
    width: 100%;
    height: auto;
    min-height: 380px;
  }

  /* Reading Mode (Active Message Open) */
  .inbox-section.reading-mode .inbox-list-pane {
    display: none !important;
  }

  .inbox-section.reading-mode .inbox-reader-pane {
    display: flex !important;
    flex-direction: column;
  }

  .reader-header {
    padding: 16px 14px;
    gap: 12px;
  }

  .reader-subject {
    font-size: 1.1rem;
  }

  .btn-back-mobile {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    color: #60A5FA;
    background: rgba(37, 99, 235, 0.12);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    cursor: pointer;
    align-self: flex-start;
  }

  .btn-back-mobile:active {
    background: rgba(37, 99, 235, 0.25);
  }

  /* Sidebar Slide Drawer */
  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.85);
    background: #0E1526;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
  }

  .sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
  }

  .btn-close-sidebar-mobile {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    line-height: 1;
    padding: 4px 8px;
    cursor: pointer;
  }

  .btn-close-sidebar-mobile:hover {
    color: var(--text-main);
  }
}

