/* ==========================================================================
   AETHERMAIL — MODERN SAAS DESIGN SYSTEM
   ========================================================================== */

:root {
  --bg-main: #090d16;
  --bg-surface: #0f172a;
  --bg-elevated: #1e293b;
  --bg-subtle: #172033;
  --border-color: #334155;
  --border-subtle: #1e293b;

  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.25);

  --accent: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* ==========================================================================
   HEADER
   ========================================================================== */
.app-header {
  height: 64px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
}

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

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

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

.highlight {
  color: var(--primary);
}

.brand-badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-weight: 600;
}

/* Navigation Tabs */
.main-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-main);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface);
}

.tab-btn.active {
  color: #fff;
  background: var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Header Right */
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.server-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.7);
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pulse-green {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.pulse-blue {
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

.mailbox-select {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.mailbox-select:focus {
  border-color: var(--primary);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #fff;
  border: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  transform: translateY(-1px);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--border-color);
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.icon-btn:hover {
  color: var(--text-main);
  background: var(--bg-elevated);
}

.text-danger:hover {
  color: var(--danger);
}

/* ==========================================================================
   APP BODY & VIEW PANELS
   ========================================================================== */
.app-body {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
}

.view-panel {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
}

.view-panel.active {
  display: flex;
}

/* ==========================================================================
   WEBMAIL VIEW (3-COLUMN LAYOUT)
   ========================================================================== */
.webmail-container {
  display: grid;
  grid-template-columns: 220px 380px 1fr;
  width: 100%;
  height: calc(100vh - 64px);
}

/* Column 1: Sidebar */
.webmail-sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.folder-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
}

.folder-item:hover {
  background: var(--bg-elevated);
  color: var(--text-main);
}

.folder-item.active {
  background: var(--bg-elevated);
  color: var(--primary);
  font-weight: 600;
}

.folder-icon {
  display: flex;
  align-items: center;
}

.folder-name {
  flex: 1;
}

.folder-badge {
  background: var(--primary);
  color: #0f172a;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 12px;
}

.folder-badge:empty, .folder-badge[data-count="0"] {
  display: none;
}

.mailbox-info-card {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.info-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 4px;
}

.info-email {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 10px;
}

.quota-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.quota-bar {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  background: var(--primary);
}

.quota-text {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* Column 2: Email List Pane */
.email-list-pane {
  background: var(--bg-main);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  color: var(--text-dim);
}

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

.email-items-container {
  flex: 1;
  overflow-y: auto;
}

.email-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.email-card:hover {
  background: var(--bg-surface);
}

.email-card.active {
  background: var(--bg-elevated);
  border-left: 3px solid var(--primary);
}

.email-card.unread {
  background: rgba(56, 189, 248, 0.04);
}

.email-card.unread .card-sender {
  font-weight: 700;
  color: var(--text-main);
}

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

.card-sender {
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

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

.card-subject {
  font-size: 0.85rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-snippet {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unread-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
  margin-right: 6px;
}

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

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

.empty-icon {
  color: var(--border-color);
}

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

.reader-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-main);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.reader-subject {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.reader-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reader-meta-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.meta-details {
  flex: 1;
}

.sender-name-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.from-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

.from-addr {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.to-line {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.meta-sep {
  margin: 0 6px;
  color: var(--text-dim);
}

.security-badges {
  display: flex;
  gap: 6px;
}

.sec-badge {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.sec-pass {
  background: rgba(52, 211, 153, 0.12);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.reader-attachments-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
}

.att-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
}

.attachments-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment-chip {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.attachment-chip:hover {
  background: var(--border-color);
}

.reader-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg-surface);
}

.email-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
  border-radius: var(--radius-md);
}

/* ==========================================================================
   VIEW: DOMAINS & DNS
   ========================================================================== */
.view-inner-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
  width: 100%;
}

.view-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.view-header-row h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.domains-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.domain-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.domain-card-header {
  padding: 18px 24px;
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.domain-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.dns-table-wrap {
  padding: 20px 24px;
}

.dns-records-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.dns-records-table th {
  text-align: left;
  color: var(--text-dim);
  font-size: 0.72rem;
  text-transform: uppercase;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}

.dns-records-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.record-type-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
}

.record-val-code {
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-main);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--border-color);
}

/* ==========================================================================
   VIEW: MAILBOXES TABLE
   ========================================================================== */
.card-table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table th {
  text-align: left;
  background: var(--bg-main);
  padding: 14px 20px;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ==========================================================================
   VIEW: LIVE SMTP MONITOR CONSOLE
   ========================================================================== */
.console-box {
  background: #020617;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.console-header {
  padding: 12px 20px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.console-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

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

.console-content {
  padding: 16px 20px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  height: 520px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry {
  display: flex;
  gap: 14px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.log-time {
  color: var(--text-dim);
  flex-shrink: 0;
}

.log-type {
  font-weight: 700;
  flex-shrink: 0;
  width: 140px;
}

.log-type.DELIVERED { color: var(--success); }
.log-type.REJECTED { color: var(--danger); }
.log-type.AUTH { color: var(--accent); }
.log-type.SYSTEM { color: var(--primary); }
.log-type.QUEUED { color: var(--warning); }

.log-details {
  color: var(--text-muted);
  word-break: break-all;
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 560px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.close-modal-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

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

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

form {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-row {
  display: flex;
  gap: 16px;
}

.flex-1 {
  flex: 1;
}

label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

input, textarea, select {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}

.input-readonly {
  background: var(--bg-elevated);
  color: var(--text-dim);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}
