/* ==========================================================================
   PlexMail - Modern Multi-Domain Mail Engine & Webmail UI
   ========================================================================== */

:root {
  --bg-base: #090d16;
  --bg-surface: #0f172a;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.65);
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --secondary: #8b5cf6;
  --accent: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --shadow-lg: 0 20px 30px -10px rgba(0, 0, 0, 0.5), 0 0 15px rgba(99, 102, 241, 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-base);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Glassmorphism generic */
.glassmorphism {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
}

/* Hidden elements */
.hidden {
  display: none !important;
}

/* Views switcher */
.view-container {
  display: none;
  width: 100%;
  min-height: 100vh;
}
.view-container.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   VIEW 1: LOGIN
   ========================================================================== */
.login-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
}

.login-mesh-bg {
  position: absolute;
  top: -20%;
  left: -10%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 30% 30%, rgba(99, 102, 241, 0.15), transparent 40%),
              radial-gradient(circle at 70% 70%, rgba(139, 92, 246, 0.15), transparent 45%),
              radial-gradient(circle at 50% 50%, rgba(236, 72, 153, 0.08), transparent 50%);
  filter: blur(60px);
  z-index: 0;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 44px 38px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: fadeIn 0.4s ease-out;
}

.brand-header {
  margin-bottom: 20px;
}

.brand-logo-glow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 0 25px var(--primary-glow);
  margin-bottom: 16px;
}

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

.brand-title {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-title span {
  background: linear-gradient(135deg, #a5b4fc, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #a5b4fc;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-bottom: 30px;
}

.login-form {
  text-align: left;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-dim);
  pointer-events: none;
}

.input-icon-wrapper input {
  width: 100%;
  padding: 13px 14px 13px 44px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  transition: var(--transition-fast);
}

.input-icon-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: var(--transition-normal);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-gradient {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-gradient:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}
.btn-outline:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger-hover:hover {
  color: var(--danger) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  background: rgba(239, 68, 68, 0.1) !important;
}

.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 7px 14px;
  font-size: 0.82rem;
}
.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}
.btn-icon:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}
.btn-icon svg {
  width: 18px;
  height: 18px;
}

.login-footer {
  margin-top: 32px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 20px;
}

.login-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--success);
  margin-bottom: 8px;
}

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

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

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.app-logo-icon {
  width: 26px;
  height: 26px;
  color: var(--primary);
}
.app-logo-text {
  font-size: 1.25rem;
  font-weight: 800;
}
.app-logo-text span {
  color: var(--secondary);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}
.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.nav-tab.active {
  color: #fff;
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
}
.nav-tab svg {
  width: 18px;
  height: 18px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 4px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
}

.user-meta {
  display: flex;
  flex-direction: column;
}
.user-email {
  font-size: 0.82rem;
  font-weight: 600;
}
.user-role-badge {
  font-size: 0.68rem;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Subview container */
.subview {
  display: none;
  width: 100%;
  flex: 1;
}
.subview.active {
  display: flex;
}

/* ==========================================================================
   SUBVIEW: WEBMAIL
   ========================================================================== */
#subview-webmail {
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Sidebar */
.webmail-sidebar {
  width: 250px;
  min-width: 250px;
  height: 100%;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
}

.btn-compose {
  margin-bottom: 24px;
}

.folder-list {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}
.folder-item:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}
.folder-item.active {
  color: #fff;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-weight: 600;
}

.folder-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.folder-item svg {
  width: 18px;
  height: 18px;
}

.badge-unread {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.quota-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 999px;
  transition: width 0.3s;
}

/* Webmail Content (Messages Pane + Reading Pane) */
.webmail-content {
  display: flex;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.messages-pane {
  width: 380px;
  min-width: 340px;
  height: 100%;
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.messages-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.search-box {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.search-box svg {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-dim);
}
.search-box input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.85rem;
  font-family: inherit;
}
.search-box input:focus {
  outline: none;
  border-color: var(--primary);
}

.messages-header-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}
.messages-header-info h2 {
  font-size: 1.1rem;
  font-weight: 700;
}
.messages-count-badge {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.messages-list-scroll {
  flex: 1;
  overflow-y: auto;
}

.mail-item {
  position: relative;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition-fast);
}
.mail-item:hover {
  background: rgba(255, 255, 255, 0.04);
}
.mail-item.selected {
  background: rgba(99, 102, 241, 0.12);
  border-left: 3px solid var(--primary);
}
.mail-item.unread .mail-item-sender {
  font-weight: 700;
  color: #fff;
}
.mail-item.unread .unread-indicator {
  display: block;
}

.mail-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.mail-item-sender {
  font-size: 0.88rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.unread-indicator {
  display: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
}

.mail-item-date {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.mail-item-subject {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Reading Pane */
.reading-pane {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgba(11, 15, 25, 0.5);
  overflow-y: auto;
}

.empty-reading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}
.empty-icon-bubble {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.empty-icon-bubble svg {
  width: 40px;
  height: 40px;
  color: var(--text-dim);
}
.empty-reading-state h3 {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.empty-reading-state p {
  font-size: 0.85rem;
  max-width: 360px;
  line-height: 1.5;
}

.message-view-active {
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.message-actions-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.message-view-subject {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.3;
}

.message-sender-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.sender-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.sender-details {
  flex: 1;
}
.sender-name-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.sender-email-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.sender-to-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.attachments-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
}
.attachments-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #a5b4fc;
}
.attachments-label svg {
  width: 16px;
  height: 16px;
}

.attachments-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-main);
  text-decoration: none;
  transition: var(--transition-fast);
}
.attachment-chip:hover {
  background: var(--primary);
}

.message-view-body {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #cbd5e1;
  padding-top: 10px;
}

/* ==========================================================================
   SUBVIEW: ADMIN HUB
   ========================================================================== */
#subview-admin {
  padding: 30px;
  overflow-y: auto;
}

.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  border-radius: var(--radius-lg);
}

.stat-icon-wrapper {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-icon-wrapper svg {
  width: 26px;
  height: 26px;
}
.stat-icon-wrapper.blue {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
}
.stat-icon-wrapper.green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}
.stat-icon-wrapper.purple {
  background: rgba(139, 92, 246, 0.15);
  color: var(--secondary);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
}

/* Admin Creator Card */
.admin-creator-card {
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid rgba(99, 102, 241, 0.3);
  box-shadow: 0 10px 30px -10px rgba(99, 102, 241, 0.15);
}

.card-header-gradient {
  padding: 26px 32px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.1));
  border-bottom: 1px solid var(--border-subtle);
}

.creator-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.25);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.creator-title-group h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.creator-title-group p {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.creator-form-grid {
  padding: 32px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.domain-select-row {
  display: flex;
  gap: 10px;
}
.domain-select-row select {
  flex: 1;
}

.email-input-addon {
  display: flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.email-input-addon input {
  flex: 1;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
}
.email-input-addon input:focus {
  outline: none;
}
.email-suffix {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  border-left: 1px solid var(--border-subtle);
}

.pass-input-row {
  display: flex;
  gap: 10px;
}
.pass-input-row input {
  flex: 1;
}

select, input[type="text"], input[type="email"], input[type="password"] {
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-checkbox-group {
  grid-column: span 2;
  display: flex;
  align-items: center;
}

.custom-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.custom-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.form-submit-row {
  grid-column: span 2;
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

/* Admin Sections Grid */
.admin-section-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

.section-card {
  border-radius: var(--radius-lg);
  padding: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.section-title p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.data-table th {
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
}
.data-table td {
  padding: 16px;
  font-size: 0.88rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.status-badge.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}
.status-badge.disabled {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-dialog {
  width: 100%;
  max-width: 540px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  animation: modalPop 0.2s ease-out;
}

.modal-lg {
  max-width: 820px;
}

.modal-compose-dialog {
  max-width: 720px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 26px;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}
.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-dim);
  cursor: pointer;
}
.btn-close-modal:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 26px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 26px;
  border-top: 1px solid var(--border-subtle);
}

/* DNS Cards Grid */
.dns-badge {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.dns-intro-note {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 20px;
}

.dns-records-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dns-card {
  padding: 16px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dns-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.dns-type-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}
.dns-card-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.dns-val-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}
.dns-val-text {
  font-family: monospace;
  font-size: 0.8rem;
  color: #e2e8f0;
  word-break: break-all;
}

/* Client config cards */
.client-config-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.client-box {
  padding: 18px;
  border-radius: var(--radius-md);
}
.client-box h4 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}
.config-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.config-line span {
  color: var(--text-dim);
}
.config-line strong {
  color: var(--text-main);
  font-family: monospace;
}

/* Compose modal styles */
.compose-header-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.compose-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.compose-row label {
  width: 50px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}
.compose-row input {
  flex: 1;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.82rem;
  cursor: pointer;
}
.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.compose-editor {
  min-height: 200px;
  max-height: 380px;
  overflow-y: auto;
  padding: 16px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.6;
}
.compose-editor:focus {
  outline: none;
}

.compose-attachments-tray {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.staged-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.staged-file-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 999px;
  font-size: 0.78rem;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  animation: toastIn 0.25s ease-out;
}
.toast.success {
  border-left: 4px solid var(--success);
}
.toast.error {
  border-left: 4px solid var(--danger);
}

/* Keyframes */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 900px) {
  .messages-pane {
    width: 100%;
  }
  .reading-pane {
    display: none;
  }
  .reading-pane.mobile-open {
    display: flex;
    position: fixed;
    top: 64px;
    left: 0;
    width: 100%;
    height: calc(100vh - 64px);
    z-index: 50;
  }
  .creator-form-grid {
    grid-template-columns: 1fr;
  }
  .form-checkbox-group, .form-submit-row {
    grid-column: span 1;
  }
  .client-config-cards {
    grid-template-columns: 1fr;
  }
}
