/* ==========================================================================
   CacoMail — Minimal Dark
   Linear / Vercel inspired. Flat. Quiet. No gradients, no glow.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --surface-2: #161616;
  --surface-3: #1c1c1c;

  --border:        #1f1f1f;
  --border-strong: #2a2a2a;

  --t-0: #fafafa;
  --t-1: #d4d4d4;
  --t-2: #a1a1a1;
  --t-3: #737373;
  --t-4: #525252;

  --accent:    #a78bfa;
  --accent-bg: rgba(167, 139, 250, 0.12);

  --ok:   #22c55e;
  --warn: #eab308;
  --bad:  #ef4444;

  --radius:    8px;
  --radius-lg: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: 'cv11';
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--t-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

::selection { background: var(--accent); color: black; }

/* ===== Form controls ===== */
input, textarea, select {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--t-0) !important;
  border-radius: var(--radius);
  padding: 9px 12px;
  width: 100%;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.12s ease;
}
input::placeholder, textarea::placeholder { color: var(--t-4); }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong) !important; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.10);
}
textarea { font-family: 'JetBrains Mono', ui-monospace, monospace; line-height: 1.55; font-size: 12.5px; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23737373' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  padding-right: 32px !important;
}

label {
  font-size: 12px;
  color: var(--t-2);
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}

input[type="checkbox"].caco-check {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: border-color 0.12s ease, background-color 0.12s ease;
  padding: 0 !important;
  margin: 0 !important;
  flex-shrink: 0;
}
input[type="checkbox"].caco-check:hover { border-color: #383838 !important; }
input[type="checkbox"].caco-check:checked {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}
input[type="checkbox"].caco-check:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: solid black;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
input[type="checkbox"].caco-check:focus {
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.10) !important;
  outline: none;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  border: 1px solid transparent;
  font-family: inherit;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--t-0);
  color: var(--bg);
  font-weight: 600;
}
.btn-primary:hover { background: #e5e5e5; }

.btn-secondary {
  background: var(--surface);
  color: var(--t-1);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); border-color: #383838; color: var(--t-0); }

.btn-danger {
  background: transparent;
  color: var(--bad);
  border-color: rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.10); }

.btn-ghost {
  background: transparent;
  color: var(--t-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--t-0); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: border-color 0.12s ease;
}
.card:hover { border-color: var(--border-strong); }

/* ===== Chips ===== */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  height: 20px;
}
.chip-ok    { background: rgba(34, 197, 94, 0.10);  color: #4ade80; border-color: rgba(34, 197, 94, 0.20); }
.chip-bad   { background: rgba(239, 68, 68, 0.10);  color: #f87171; border-color: rgba(239, 68, 68, 0.20); }
.chip-warn  { background: rgba(234, 179, 8, 0.10);  color: #facc15; border-color: rgba(234, 179, 8, 0.20); }
.chip-info  { background: var(--accent-bg);         color: var(--accent); border-color: rgba(167, 139, 250, 0.22); }
.chip-muted { background: var(--surface-2);         color: var(--t-3); border-color: var(--border-strong); }

/* ===== Tables ===== */
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.tbl th {
  text-align: left;
  font-weight: 500;
  color: var(--t-3);
  font-size: 11.5px;
  letter-spacing: 0.005em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
table.tbl td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--t-1);
}
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl tr:last-child td { border-bottom: 0; }

/* ===== Modal ===== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade 0.12s ease;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: slide 0.16s ease;
}
.modal-lg { max-width: 1024px; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== Links ===== */
a { color: var(--accent); text-decoration: none; }
a:hover { color: #c4b5fd; }

/* ===== Code ===== */
.code {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  word-break: break-all;
  color: var(--t-1);
  line-height: 1.5;
}

/* ===== Toasts ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  max-width: 360px;
  font-size: 13px;
  color: var(--t-1);
  animation: toast 0.18s ease;
}
.toast-error { border-color: rgba(239, 68, 68, 0.5); }
.toast-ok    { border-color: rgba(34, 197, 94, 0.5); }
@keyframes toast {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== Vue transitions ===== */
.fade-enter-active, .fade-leave-active { transition: opacity 0.15s ease; }
.fade-enter-from, .fade-leave-to { opacity: 0; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 1px;
  color: var(--t-2);
  transition: background-color 0.1s ease, color 0.1s ease;
}
.nav-link:hover {
  background: var(--surface-2);
  color: var(--t-0);
}
.nav-link.active {
  background: var(--surface-2);
  color: var(--t-0);
}

/* ===== Headings ===== */
h1, h2, h3, h4 { color: var(--t-0); margin: 0; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }

/* ===== Stat tile ===== */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  transition: border-color 0.12s ease;
}
.stat-tile:hover { border-color: var(--border-strong); }
.stat-tile-label {
  font-size: 12px;
  color: var(--t-3);
  font-weight: 500;
}
.stat-tile-value {
  font-size: 28px;
  font-weight: 600;
  margin-top: 8px;
  color: var(--t-0);
  letter-spacing: -0.025em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-tile-meta {
  font-size: 12px;
  color: var(--t-3);
  margin-top: 8px;
}

/* ===== Brand badge ===== */
.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--t-0);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Login hero ===== */
.auth-hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 380px;
}

/* ===== Page header ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header h1 {
  margin: 0 0 4px;
}
.page-header p {
  color: var(--t-3);
  font-size: 13px;
  margin: 0;
}

/* ===== Mail item ===== */
.msg-item {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  transition: background-color 0.1s ease;
}
.msg-item:hover {
  background: var(--surface);
}
.msg-item.active {
  background: var(--surface-2);
  position: relative;
}
.msg-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
}
.msg-item.unread {
  background: rgba(167, 139, 250, 0.04);
}

/* ===== Misc ===== */
hr { border: 0; height: 1px; background: var(--border); margin: 16px 0; }

kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--t-1);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Spinner */
.spinner {
  width: 12px;
  height: 12px;
  border: 1.5px solid rgba(0, 0, 0, 0.2);
  border-top-color: var(--bg);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* Helpers */
.font-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
