/* ===== Arcada Mail — Design System ===== */
:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --primary-bg: #eef2ff;
  --accent: #f59e0b;
  --success: #10b981;
  --success-bg: #d1fae5;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --text: #111827;
  --text-secondary: #374151;
  --muted: #6b7280;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===== Navbar ===== */
.navbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  height: 60px;
  gap: 0.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.navbar .brand {
  color: var(--primary);
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  letter-spacing: -0.02em;
  margin-right: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.navbar .brand::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 28px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 4L8 56h48L32 4z' fill='%234f46e5'/%3E%3Cpath d='M32 4L20 56h24L32 4z' fill='%23818cf8'/%3E%3Cpath d='M32 4l-4 20 4 4 4-4-4-20z' fill='%23c7d2fe'/%3E%3Cline x1='26' y1='56' x2='32' y2='30' stroke='%233730a3' stroke-width='1.5'/%3E%3Cline x1='38' y1='56' x2='32' y2='30' stroke='%233730a3' stroke-width='1.5'/%3E%3Cline x1='32' y1='4' x2='32' y2='0' stroke='%233730a3' stroke-width='2' stroke-linecap='round'/%3E%3Cline x1='32' y1='4' x2='28' y2='0' stroke='%233730a3' stroke-width='1.5' stroke-linecap='round'/%3E%3Cline x1='32' y1='4' x2='36' y2='0' stroke='%233730a3' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center/contain;
}
.navbar a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  transition: all var(--transition);
}
.navbar a:hover {
  color: var(--primary);
  background: var(--primary-bg);
}
.navbar a.active {
  color: var(--primary);
  background: var(--primary-bg);
  font-weight: 600;
}

/* ===== Layout ===== */
.container {
  max-width: 1100px;
  margin: 1.75rem auto;
  padding: 0 1.5rem;
}

.page-header {
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
}
.page-header p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card h2 .icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.icon-blue { background: var(--primary-bg); color: var(--primary); }
.icon-amber { background: #fef3c7; color: #d97706; }
.icon-green { background: var(--success-bg); color: var(--success); }
.icon-red { background: var(--danger-bg); color: var(--danger); }

/* ===== Forms ===== */
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
select, textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  margin-bottom: 1rem;
  transition: all var(--transition);
  background: white;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
input::placeholder { color: #9ca3af; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.25rem;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0 1.25rem;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}
.toggle-wrap input[type="checkbox"] {
  width: 40px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: #d1d5db;
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  margin: 0;
  flex-shrink: 0;
}
.toggle-wrap input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-wrap input[type="checkbox"]:checked {
  background: var(--primary);
}
.toggle-wrap input[type="checkbox"]:checked::after {
  transform: translateX(18px);
}
.toggle-wrap label {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 1px 3px rgba(79,70,229,0.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}
.btn-success {
  background: var(--success);
  color: white;
  box-shadow: 0 1px 3px rgba(16,185,129,0.3);
}
.btn-success:hover { filter: brightness(0.92); }
.btn-danger {
  background: white;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.btn-danger:hover {
  background: var(--danger);
  color: white;
}
.btn-secondary {
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== Flash messages ===== */
.flash {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideDown 0.3s ease;
}
.flash-success {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.flash-success::before { content: '\2713'; font-weight: 700; }
.flash-error {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}
.flash-error::before { content: '\2717'; font-weight: 700; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SMTP status grid ===== */
.smtp-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}
.smtp-status-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--border-light);
  transition: all var(--transition);
}
.smtp-status-item:hover { background: #e5e7eb; }
.status-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.status-indicator.ok {
  background: var(--success-bg);
  color: var(--success);
}
.status-indicator.missing {
  background: var(--danger-bg);
  color: var(--danger);
}
.status-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}
.status-env {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: #e5e7eb;
  display: inline-block;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  margin-top: 0.15rem;
}
.status-value {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 0.15rem;
}

/* ===== Email layout: list + preview ===== */
.email-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1rem;
  min-height: 380px;
}

/* Email list */
.email-list {
  list-style: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  max-height: 480px;
  background: white;
}
.email-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
  gap: 0.75rem;
}
.email-item:hover { background: var(--primary-bg); }
.email-item.selected {
  background: var(--primary-bg);
  border-left: 3px solid var(--primary);
}
.email-item:last-child { border-bottom: none; }
.email-item .name { font-weight: 600; color: var(--text); }
.email-item .addr { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.email-item .vol {
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  white-space: nowrap;
}

/* Preview panel */
.preview-panel {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  max-height: 480px;
  background: white;
}
.preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 0.9rem;
  gap: 0.5rem;
}
.preview-empty::before {
  content: '\2709';
  font-size: 2.5rem;
  opacity: 0.25;
}
.preview-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafbff, white);
}
.preview-field {
  font-size: 0.85rem;
  padding: 0.2rem 0;
  display: flex;
  gap: 0.4rem;
}
.preview-label {
  font-weight: 700;
  color: var(--muted);
  min-width: 80px;
}
.preview-body {
  padding: 1.25rem;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* ===== Progress bar ===== */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  margin: 1rem 0;
  display: none;
}
.progress-bar .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  width: 0%;
  transition: width 0.4s ease;
  border-radius: 3px;
}

/* ===== Results ===== */
.result-sent {
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  background: var(--success-bg);
  border-radius: 8px;
  color: #065f46;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.result-error {
  font-size: 0.88rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.35rem;
  background: var(--danger-bg);
  border-radius: 8px;
  color: #991b1b;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ===== Rich editor ===== */
.editor-toolbar {
  display: flex;
  gap: 2px;
  padding: 8px;
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
  background: white;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.editor-toolbar button:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary-light);
}
.editor-box {
  border: 1.5px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  min-height: 320px;
  padding: 1.25rem;
  outline: none;
  font-size: 0.92rem;
  line-height: 1.7;
  background: white;
  color: var(--text-secondary);
}
.editor-box:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.08);
}

.placeholder-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.placeholder-hint code {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: 5px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ===== History table ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
thead { background: var(--border-light); }
th {
  text-align: left;
  padding: 0.7rem 0.75rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}
tbody tr {
  transition: background var(--transition);
}
tbody tr:hover { background: var(--primary-bg); }
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
}
.empty-state .empty-icon {
  font-size: 3rem;
  opacity: 0.2;
  margin-bottom: 0.5rem;
}
.empty-state p {
  font-size: 0.9rem;
}

/* ===== File upload ===== */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 1rem;
  background: var(--border-light);
}
.file-drop:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
  color: var(--primary);
}
.file-drop input[type="file"] { display: none; }
.file-drop .drop-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}
.file-drop p {
  font-size: 0.9rem;
  font-weight: 500;
}
.file-drop .drop-hint {
  font-size: 0.78rem;
  margin-top: 0.25rem;
  opacity: 0.7;
}

/* ===== Spinner ===== */
.spinner {
  display: none;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Auth lang bar ===== */
.auth-lang {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  gap: 0.25rem;
  z-index: 200;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 0.25rem;
}
.auth-lang a {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  transition: all var(--transition);
  letter-spacing: 0.04em;
}
.auth-lang a:hover {
  color: white;
  background: rgba(255,255,255,0.15);
}
.auth-lang a.active {
  color: white;
  background: rgba(255,255,255,0.25);
}

/* ===== Auth pages ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 40%, #4f46e5 100%);
  padding: 1rem;
}
.auth-card {
  background: white;
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.4s ease;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.auth-logo {
  width: 56px;
  height: 56px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M32 4L8 56h48L32 4z' fill='%234f46e5'/%3E%3Cpath d='M32 4L20 56h24L32 4z' fill='%23818cf8'/%3E%3Cpath d='M32 4l-4 20 4 4 4-4-4-20z' fill='%23c7d2fe'/%3E%3Cline x1='26' y1='56' x2='32' y2='30' stroke='%233730a3' stroke-width='1.5'/%3E%3Cline x1='38' y1='56' x2='32' y2='30' stroke='%233730a3' stroke-width='1.5'/%3E%3Cline x1='32' y1='4' x2='32' y2='0' stroke='%233730a3' stroke-width='2' stroke-linecap='round'/%3E%3Cline x1='32' y1='4' x2='28' y2='0' stroke='%233730a3' stroke-width='1.5' stroke-linecap='round'/%3E%3Cline x1='32' y1='4' x2='36' y2='0' stroke='%233730a3' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center/contain;
  margin: 0 auto 1.25rem;
}
.auth-title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
  color: var(--text);
  letter-spacing: -0.02em;
}
.auth-subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}

/* ===== Language selector ===== */
.lang-selector {
  margin-left: auto;
  position: relative;
}
.lang-current {
  background: var(--border-light);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: inherit;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.04em;
}
.lang-current:hover {
  border-color: var(--primary-light);
  color: var(--primary);
  background: var(--primary-bg);
}
.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 150px;
  z-index: 200;
  overflow: hidden;
  animation: fadeUp 0.15s ease;
}
.lang-dropdown.open { display: block; }
.lang-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem !important;
  font-size: 0.85rem !important;
  color: var(--text-secondary) !important;
  text-decoration: none;
  transition: background var(--transition);
  border-radius: 0 !important;
}
.lang-dropdown a:hover {
  background: var(--primary-bg) !important;
  color: var(--primary) !important;
}
.lang-dropdown a.active {
  background: var(--primary-bg) !important;
  color: var(--primary) !important;
  font-weight: 600;
}
.lang-code {
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--border-light);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.lang-dropdown a.active .lang-code {
  background: var(--primary);
  color: white;
}

/* ===== Navbar logout ===== */
.nav-logout {
  font-size: 0.82rem !important;
  color: var(--muted) !important;
}
.nav-logout:hover {
  color: var(--danger) !important;
  background: var(--danger-bg) !important;
}

/* ===== Section dividers ===== */
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .email-layout { grid-template-columns: 1fr; }
  .email-list, .preview-panel { max-height: 300px; }
  .navbar { padding: 0 1rem; }
}
@media (max-width: 640px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .navbar { gap: 0.15rem; padding: 0 0.5rem; }
  .navbar a { padding: 0.4rem 0.5rem; font-size: 0.82rem; }
  .navbar .brand { margin-right: 0.5rem; font-size: 1rem; }
  .container { padding: 0 1rem; }
}
