/*
 * Vox – Email Communications Dashboard
 * Global stylesheet
 */

/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg:          #f4f5f7;
  --color-surface:     #ffffff;
  --color-border:      #dde1e7;
  --color-text:        #1a1d23;
  --color-text-muted:  #6b7280;
  --color-primary:     #4f46e5;
  --color-primary-h:   #4338ca;
  --color-success:     #16a34a;
  --color-danger:      #dc2626;
  --color-warn:        #d97706;
  --color-incoming-bg: #f0f4ff;
  --color-outgoing-bg: #f0fdf4;
  --radius:            6px;
  --shadow-sm:         0 1px 3px rgba(0,0,0,.08);
  --font:              system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:         "SF Mono", Consolas, monospace;
}

html, body { height: 100%; font-family: var(--font); font-size: 14px; color: var(--color-text); background: var(--color-bg); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App shell ────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  height: 48px;
  background: var(--color-text);
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header__brand { font-size: 1.1rem; font-weight: 700; letter-spacing: .02em; }
.app-header__nav   { display: flex; align-items: center; gap: .75rem; }
.app-header__user  { font-size: .8rem; color: #9ca3af; }

.app-main { height: calc(100vh - 48px); overflow: hidden; }

/* ── Flash messages ───────────────────────────────────────────── */
.flash {
  padding: .5rem 1rem;
  font-size: .85rem;
  border-left: 4px solid transparent;
}
.flash--notice { background: #ecfdf5; border-color: var(--color-success); color: var(--color-success); }
.flash--alert  { background: #fef2f2; border-color: var(--color-danger);  color: var(--color-danger); }
.flash--inline { margin-bottom: .5rem; padding: .35rem .6rem; border-radius: var(--radius); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn--primary   { background: var(--color-primary);   color: #fff; }
.btn--primary:hover { background: var(--color-primary-h); text-decoration: none; }
.btn--success   { background: var(--color-success);   color: #fff; }
.btn--success:hover { background: #15803d; text-decoration: none; }
.btn--secondary { background: transparent; color: var(--color-text); border-color: var(--color-border); }
.btn--secondary:hover { background: var(--color-bg); text-decoration: none; }
.btn--ghost     { background: transparent; color: #9ca3af; border: none; }
.btn--ghost:hover { color: #fff; text-decoration: none; }
.btn--sm        { padding: .3rem .65rem; font-size: .78rem; }
.btn input[type="submit"] { background: none; border: none; cursor: pointer; font: inherit; color: inherit; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group    { margin-bottom: .85rem; }
.form-label    { display: block; margin-bottom: .3rem; font-size: .78rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.form-input    { width: 100%; padding: .45rem .65rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: .85rem; outline: none; transition: border-color .15s; }
.form-input:focus  { border-color: var(--color-primary); }
.form-textarea     { width: 100%; padding: .45rem .65rem; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: .85rem; resize: vertical; outline: none; transition: border-color .15s; font-family: var(--font); }
.form-textarea:focus { border-color: var(--color-primary); }
.form-textarea--draft { min-height: 200px; font-family: var(--font-mono); font-size: .82rem; background: #fafafa; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge           { display: inline-block; padding: .15rem .5rem; border-radius: 100px; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.badge--unreplied{ background: #fef3c7; color: var(--color-warn); }
.badge--replied  { background: #dcfce7; color: var(--color-success); }
.badge--dismissed{ background: #f3f4f6; color: var(--color-text-muted); }

/* ── Inbox layout ─────────────────────────────────────────────── */
.inbox {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%;
}

/* ── Thread list (left panel) ─────────────────────────────────── */
.thread-list {
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  background: var(--color-surface);
}
.thread-list__header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--color-border);
  font-size: .82rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  position: sticky;
  top: 0;
  background: var(--color-surface);
}
.thread-list__empty { padding: 2rem 1rem; color: var(--color-text-muted); text-align: center; }

.thread-item { border-bottom: 1px solid var(--color-border); }
.thread-item--active { background: #eef2ff; }
.thread-item__link { display: block; padding: .75rem 1rem; color: inherit; }
.thread-item__link:hover { background: #f8f9ff; text-decoration: none; }
.thread-item__sender { font-weight: 600; font-size: .85rem; margin-bottom: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item__subject { font-size: .8rem; color: var(--color-text-muted); margin-bottom: .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item__meta { display: flex; align-items: center; justify-content: space-between; }
.thread-item__time { font-size: .72rem; color: var(--color-text-muted); }

/* ── Thread view (right panel) ────────────────────────────────── */
.thread-view { overflow-y: auto; background: var(--color-bg); }
.thread-view__empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--color-text-muted); }

turbo-frame#thread_view { display: block; height: 100%; }

.thread-detail { display: flex; flex-direction: column; height: 100%; }

.thread-detail__header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.25rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
}
.thread-detail__subject { font-size: 1rem; font-weight: 700; flex: 1; }
.thread-detail__sender  { font-size: .8rem; color: var(--color-text-muted); }
.thread-detail__actions { display: flex; gap: .5rem; margin-left: auto; }

/* ── Messages ─────────────────────────────────────────────────── */
.messages { padding: 1rem 1.25rem; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .75rem; }

.message { padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid var(--color-border); }
.message--incoming { background: var(--color-incoming-bg); }
.message--outgoing { background: var(--color-outgoing-bg); }

.message__meta { display: flex; justify-content: space-between; margin-bottom: .5rem; }
.message__direction { font-size: .75rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }
.message__time      { font-size: .72rem; color: var(--color-text-muted); }
.message__body      { font-size: .85rem; line-height: 1.6; white-space: pre-wrap; }
.message__body p    { margin-bottom: .5rem; }

/* ── Reply module ─────────────────────────────────────────────── */
.reply-module {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  padding: 1.25rem;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}
.reply-module__title { font-size: .9rem; font-weight: 700; margin-bottom: .75rem; }

.draft-form { margin-bottom: .75rem; display: flex; gap: .5rem; align-items: flex-end; }
.draft-form .form-group { flex: 1; margin-bottom: 0; }

.send-form { margin-top: .75rem; }

/* ── Sender panel ─────────────────────────────────────────────── */
.sender-panel { background: var(--color-bg); border-radius: var(--radius); padding: 1rem; border: 1px solid var(--color-border); }
.sender-panel__title { font-size: .82rem; font-weight: 700; margin-bottom: .85rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sender-form .form-textarea { min-height: 80px; }

/* ── Sent notice ──────────────────────────────────────────────── */
.sent-notice { padding: 2rem; text-align: center; color: var(--color-success); }
.sent-notice p { margin-bottom: 1rem; font-size: 1rem; font-weight: 600; }

/* ── Devise / auth ────────────────────────────────────────────── */
.auth-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--color-bg); }
.auth-card { background: var(--color-surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 2rem 2.5rem; width: 360px; }
.auth-card h2 { margin-bottom: 1.5rem; font-size: 1.2rem; text-align: center; }
.auth-card .form-actions { margin-top: 1.25rem; display: flex; flex-direction: column; gap: .75rem; align-items: center; }
.auth-card .btn { width: 100%; justify-content: center; }
.auth-card a { font-size: .82rem; }

