/* ── NovaMail Stylesheet ───────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500&display=swap');

/* ── Variables ────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0e0f11;
  --bg2:         #15171a;
  --bg3:         #1c1f24;
  --border:      #262a30;
  --text:        #e8e9eb;
  --text-muted:  #7a8090;
  --text-faint:  #454d5a;
  --accent:      #e8c56d;
  --accent-dim:  rgba(232,197,109,.12);
  --accent-glow: rgba(232,197,109,.06);
  --danger:      #e8706d;
  --success:     #6de8a0;
  --sidebar-w:   240px;
  --radius:      10px;
  --font-serif:  'DM Serif Display', Georgia, serif;
  --font-sans:   'DM Sans', system-ui, sans-serif;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-page {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 24px 0 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
}
.brand-icon {
  font-size: 1.4rem;
  color: var(--accent);
  line-height: 1;
}
.brand-name {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--text);
  letter-spacing: -.01em;
}

.compose-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 20px 16px 8px;
  padding: 11px 18px;
  background: var(--accent);
  color: #0e0f11;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: .875rem;
  letter-spacing: .01em;
  transition: opacity .15s;
}
.compose-btn:hover { opacity: .88; }
.compose-btn.active { opacity: .88; }

.nav-label {
  font-size: .7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-faint);
  padding: 16px 20px 6px;
}

.folder-nav { flex: 1; padding-bottom: 12px; }

.folder-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-radius: 8px;
  margin: 1px 8px;
  font-size: .875rem;
  color: var(--text-muted);
  transition: background .12s, color .12s;
  cursor: pointer;
}
.folder-link:hover { background: var(--bg3); color: var(--text); }
.folder-link.active { background: var(--accent-dim); color: var(--accent); }

.folder-icon { font-size: 1rem; line-height: 1; }
.folder-name { flex: 1; }

.badge {
  background: var(--accent);
  color: #0e0f11;
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  line-height: 1.5;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-email {
  font-size: .75rem;
  color: var(--text-muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.logout-btn {
  color: var(--text-faint);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.logout-btn:hover { color: var(--danger); background: rgba(232,112,109,.1); }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 28px 32px 40px;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
.folder-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
}
.mail-count { font-size: .85rem; color: var(--text-muted); }
.unread-count { font-style: normal; color: var(--accent); }

.btn-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.btn-icon:hover { background: var(--bg3); color: var(--text); }

/* ── Mail List ────────────────────────────────────────────────────────────── */
.mail-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
}

.mail-row {
  display: grid;
  grid-template-columns: 32px 200px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
  text-decoration: none;
}
.mail-row:last-child { border-bottom: none; }
.mail-row:hover { background: var(--bg3); }
.mail-row.unread { background: var(--accent-glow); }
.mail-row.unread:hover { background: var(--bg3); }

.mail-flag { text-align: center; font-size: .95rem; }
.star-on  { color: var(--accent); }
.star-off { color: var(--text-faint); }

.mail-from {
  font-size: .875rem;
  font-weight: 400;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-row.unread .mail-from {
  font-weight: 500;
  color: var(--text);
}

.mail-subject {
  font-size: .875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mail-row.unread .mail-subject { color: var(--text); }

.mail-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.mail-date {
  font-size: .78rem;
  color: var(--text-faint);
  white-space: nowrap;
}
.mail-size {
  font-size: .72rem;
  color: var(--text-faint);
}

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; line-height: 1; }
.empty-state p { font-size: .95rem; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}
.page-btn {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
  color: var(--text-muted);
  background: var(--bg2);
  transition: border-color .15s, color .15s;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-info { font-size: .85rem; color: var(--text-faint); }

/* ── Alert ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 16px;
  border: 1px solid;
}
.alert-error   { background: rgba(232,112,109,.1); border-color: rgba(232,112,109,.3); color: var(--danger); }
.alert-success { background: rgba(109,232,160,.1); border-color: rgba(109,232,160,.3); color: var(--success); }

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
}
.login-wrap { display: flex; width: 100%; min-height: 100vh; }

.login-art {
  flex: 1;
  background: linear-gradient(135deg, #13151a 0%, #1a1d24 50%, #0e1018 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 60px;
}
.login-art::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 60% at 40% 50%, rgba(232,197,109,.07) 0%, transparent 70%);
}
.art-circles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.art-circles span {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(232,197,109,.1);
}
.art-circles span:nth-child(1) {
  width: 380px; height: 380px;
  top: 50%; left: 45%;
  transform: translate(-50%,-50%);
}
.art-circles span:nth-child(2) {
  width: 560px; height: 560px;
  top: 50%; left: 45%;
  transform: translate(-50%,-50%);
}
.art-circles span:nth-child(3) {
  width: 740px; height: 740px;
  top: 50%; left: 45%;
  transform: translate(-50%,-50%);
}

.art-text { position: relative; z-index: 1; text-align: center; }
.art-text h1 {
  font-family: var(--font-serif);
  font-size: 3.5rem;
  color: var(--text);
  letter-spacing: -.02em;
  margin-bottom: 10px;
}
.art-text p {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 300;
}

.login-form-wrap {
  width: 420px;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
}

.login-form { width: 100%; }
.form-header { margin-bottom: 28px; }
.form-header h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 400;
  margin-bottom: 4px;
}
.form-header p { color: var(--text-muted); font-size: .875rem; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field input, .compose-field input:not([type="file"]), .compose-field textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: .9rem;
  transition: border-color .15s;
  outline: none;
}
.field input:focus,
.compose-field input:not([type="file"]):focus,
.compose-field textarea:focus {
  border-color: var(--accent);
}
.field input::placeholder,
.compose-field input::placeholder,
.compose-field textarea::placeholder { color: var(--text-faint); }

input[disabled] { opacity: .6; cursor: not-allowed; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--accent);
  color: #0e0f11;
  border: none;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .15s;
  margin-top: 8px;
  text-decoration: none;
}
.btn-primary:hover { opacity: .88; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 12px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: .9rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
  text-decoration: none;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

.login-hint {
  font-size: .75rem;
  color: var(--text-faint);
  margin-top: 20px;
  text-align: center;
}

/* ── View Page ────────────────────────────────────────────────────────────── */
.view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.btn-back {
  font-size: .875rem;
  color: var(--text-muted);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s, color .15s;
}
.btn-back:hover { border-color: var(--text-muted); color: var(--text); }

.view-actions { display: flex; gap: 8px; }
.btn-action {
  padding: 8px 14px;
  font-size: .8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  transition: border-color .15s, color .15s;
}
.btn-action:hover { border-color: var(--accent); color: var(--accent); }
.btn-action.btn-danger:hover { border-color: var(--danger); color: var(--danger); }

.mail-view {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.mail-view-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}
.mail-view-subject {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 16px;
  line-height: 1.3;
}
.mail-view-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.meta-from {
  display: flex;
  align-items: center;
  gap: 12px;
}
.avatar-circle {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1.5px solid var(--accent);
  color: var(--accent);
  font-size: .85rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.meta-email { font-size: .8rem; color: var(--text-muted); margin-left: 4px; }
.meta-date  { font-size: .82rem; color: var(--text-faint); }
.meta-to    { font-size: .82rem; color: var(--text-faint); margin-top: 4px; }
.meta-label { color: var(--text-muted); margin-right: 4px; }

.attachments-bar {
  padding: 12px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(232,197,109,.04);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.attach-label { font-size: .8rem; color: var(--text-muted); margin-right: 4px; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: .78rem;
  color: var(--text);
  transition: border-color .15s;
}
.attach-chip:hover { border-color: var(--accent); color: var(--accent); }
.attach-chip small { color: var(--text-faint); }

.mail-body { padding: 0; }
.mail-iframe {
  width: 100%;
  border: none;
  min-height: 300px;
  display: block;
  background: #fff;
}
.mail-text {
  padding: 24px 28px;
  font-size: .9rem;
  line-height: 1.8;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Compose ──────────────────────────────────────────────────────────────── */
.compose-form {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 32px;
  max-width: 860px;
}
.compose-field {
  margin-bottom: 14px;
}
.compose-field label {
  display: block;
  font-size: .75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.required { color: var(--danger); }
.compose-body-field textarea {
  resize: vertical;
  font-size: .875rem;
  line-height: 1.7;
}
.file-input {
  font-size: .875rem;
  color: var(--text-muted);
}
.file-hint { font-size: .75rem; color: var(--text-faint); margin-top: 4px; }
.compose-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .login-art { display: none; }
  .login-form-wrap { width: 100%; padding: 40px 28px; }
  :root { --sidebar-w: 200px; }
  .main-content { padding: 20px 16px 32px; }
  .mail-row { grid-template-columns: 32px 140px 1fr auto; }
}

@media (max-width: 640px) {
  .sidebar { display: none; }
  .mail-row { grid-template-columns: 1fr auto; }
  .mail-flag, .mail-from { display: none; }
}
