/* ==================================================================
   FILE: public_html/qemail.app/css/webmail.css
   ARCHITECTURE: WEBMAIL Layer - The Front Desk's Furniture
   ==================================================================
   STORY:
   QEmail's own standalone webmail chrome — dark, quiet, utilitarian,
   matching the tone of the old status page it replaces (same palette:
   near-black background, sky-blue accent) rather than any one tenant's
   brand. A tenant's own admin console is expected to wrap this in its
   own frame later; this file is QEmail's product, not anyone's skin.
   ================================================================== */

:root {
  --bg:        #0a0e1a;
  --panel:     #111827;
  --panel-alt: #0d1420;
  --border:    #1e293b;
  --accent:    #38bdf8;
  --accent-dim:#0f4c81;
  --green:     #22c55e;
  --red:       #ef4444;
  --amber:     #f59e0b;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --muted2:    #94a3b8;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

.logo {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  white-space: nowrap;
}
.logo span { color: var(--text); }

/* ── Login screen ─────────────────────────────────────────────── */
#login-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header .logo { font-size: 2.2rem; }
.tagline { margin-top: 0.4rem; color: var(--muted); font-size: 0.85rem; }

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
}
.login-card label { display: block; font-size: 0.8rem; color: var(--muted2); margin-bottom: 0.4rem; }
.login-card input {
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 0.9rem;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.pin-hint { color: var(--muted2); font-size: 0.85rem; margin-bottom: 0.9rem; }
.pin-hint strong { color: var(--text); }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #05202e;
  border: none;
  border-radius: 6px;
  padding: 0.7rem;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); }

.btn-link {
  background: none;
  border: none;
  color: var(--muted2);
  font-size: 0.8rem;
  text-decoration: underline;
  margin-top: 0.7rem;
  width: 100%;
  text-align: center;
}

.login-status { margin-top: 0.7rem; font-size: 0.82rem; min-height: 1.2em; }
.login-status.error   { color: var(--red); }
.login-status.success { color: var(--green); }

/* ── App shell ─────────────────────────────────────────────────── */
#app-shell { height: 100vh; display: flex; flex-direction: column; }

.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.2rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.header-spacer { flex: 1; }

#domain-picker {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  max-width: 220px;
}

.layout { flex: 1; display: flex; min-height: 0; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: 190px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 1rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.compose-btn {
  background: var(--accent);
  color: #05202e;
  border: none;
  border-radius: 8px;
  padding: 0.6rem;
  font-weight: 600;
  font-size: 0.88rem;
}
.compose-btn:hover { filter: brightness(1.1); }

.folder-tabs { display: flex; flex-direction: column; gap: 0.15rem; }
.folder-tab {
  background: none;
  border: none;
  color: var(--muted2);
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-radius: 6px;
  font-size: 0.88rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.folder-tab:hover  { background: var(--panel-alt); color: var(--text); }
.folder-tab.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.folder-tab .count { color: var(--muted); font-size: 0.78rem; font-weight: 400; }
.folder-tab.active .count { color: var(--accent); }

/* ── Message list ──────────────────────────────────────────────── */
.list-col {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.toolbar {
  display: flex;
  gap: 0.4rem;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.toolbar input {
  flex: 1;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
}
.toolbar button {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}

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

.msg-row {
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.msg-row:hover     { background: var(--panel-alt); }
.msg-row.selected  { background: var(--accent-dim); }
.msg-row.unread .msg-from,
.msg-row.unread .msg-subject { font-weight: 700; color: var(--text); }
.msg-top { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 0.2rem; }
.msg-from { color: var(--muted2); }
.msg-date { color: var(--muted); flex-shrink: 0; }
.msg-subject { font-size: 0.85rem; color: var(--muted2); margin-bottom: 0.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-badges { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.badge {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--panel-alt);
  color: var(--muted2);
  border: 1px solid var(--border);
}
.badge-domain    { color: var(--accent); border-color: var(--accent-dim); }
.badge-todo      { color: var(--amber); }
.badge-starred   { color: var(--amber); }
.badge-suspicious,
.badge-spam,
.badge-joker     { color: var(--red); }
.badge-friendly  { color: var(--green); }

.empty-state {
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
}
.load-more { padding: 0.8rem; text-align: center; }
.load-more button { background: none; border: 1px solid var(--border); color: var(--muted2); border-radius: 6px; padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ── Detail panel ──────────────────────────────────────────────── */
.detail-col { flex: 1; overflow-y: auto; padding: 1.2rem 1.5rem; min-width: 0; }

.detail-subject { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.6rem; }
.detail-meta { font-size: 0.82rem; color: var(--muted2); display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.8rem; }
.detail-meta strong { color: var(--muted); font-weight: 500; }

.action-bar { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.action-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--muted2);
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}
.action-btn:hover     { border-color: var(--accent); color: var(--text); }
.action-btn.active    { color: var(--amber); border-color: var(--amber); }

.action-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.78rem;
  text-decoration: underline;
  padding: 0.4rem 0.2rem;
  align-self: center;
}
.action-link:hover { color: var(--text); }

.body-text { font-size: 0.92rem; line-height: 1.55; color: var(--text); white-space: pre-wrap; margin-bottom: 1.2rem; }
.body-frame { width: 100%; min-height: 240px; border: 1px solid var(--border); border-radius: 6px; background: #fff; margin-bottom: 1.2rem; }

.thread-history { margin: 1rem 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.thread-history-label { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.6rem; text-transform: uppercase; letter-spacing: 0.04em; }
.thread-msg { background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.8rem; margin-bottom: 0.5rem; font-size: 0.85rem; }
.thread-msg.outbound { border-left: 3px solid var(--accent); }
.thread-msg.inbound  { border-left: 3px solid var(--muted); }
.thread-msg-header { display: flex; justify-content: space-between; color: var(--muted2); font-size: 0.78rem; margin-bottom: 0.25rem; }
.thread-msg-subject { color: var(--muted2); margin-bottom: 0.2rem; }
.thread-msg-body { color: var(--text); white-space: pre-wrap; }

.reply-area { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.reply-header { display: flex; justify-content: space-between; font-size: 0.82rem; color: var(--muted2); margin-bottom: 0.5rem; }
.reply-area input, .reply-area textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  margin-bottom: 0.5rem;
}
.reply-area textarea { min-height: 120px; resize: vertical; }
.reply-send-row { display: flex; align-items: center; gap: 0.7rem; }
.reply-send-row .btn-primary { width: auto; padding: 0.5rem 1.1rem; }
.send-status { font-size: 0.8rem; }
.send-status.error   { color: var(--red); }
.send-status.success { color: var(--green); }

.note-area { border-top: 1px solid var(--border); padding-top: 1rem; margin-top: 1rem; }
.note-area label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.4rem; }
.note-area textarea { width: 100%; min-height: 60px; background: var(--panel); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 0.5rem; font-size: 0.85rem; }
.note-save { margin-top: 0.4rem; background: none; border: 1px solid var(--border); color: var(--muted2); border-radius: 6px; padding: 0.35rem 0.8rem; font-size: 0.8rem; }

/* ── Compose modal ─────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.modal-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%; max-width: 480px;
  padding: 1.3rem 1.5rem;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted2); font-size: 1.1rem; }
.modal-panel label { display: block; font-size: 0.78rem; color: var(--muted); margin: 0.6rem 0 0.3rem; }
.modal-panel input, .modal-panel select, .modal-panel textarea {
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
}
.modal-panel textarea { min-height: 140px; resize: vertical; }
.modal-send-row { display: flex; align-items: center; gap: 0.8rem; margin-top: 1rem; }
.modal-send-row .btn-primary { width: auto; padding: 0.55rem 1.2rem; }

/* ── Members modal ─────────────────────────────────────────────── */
#members-list { max-height: 260px; overflow-y: auto; margin-bottom: 0.8rem; }
.member-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.member-row.pending { color: var(--muted); }
.member-email { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-row select {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  font-size: 0.8rem;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .folder-tab span:not(.count) { display: none; }
  .compose-btn { font-size: 1.2rem; padding: 0.5rem; }
  .list-col { width: 280px; }
}
@media (max-width: 680px) {
  .layout { position: relative; }
  .sidebar { display: none; }
  .list-col { width: 100%; }
  .detail-col.has-message { position: absolute; inset: 0; background: var(--bg); z-index: 10; }
}
