/* === WM Webmail === */
:root {
  --sidebar-w:     220px;
  --sidebar-bg:    #1a1d23;
  --sidebar-text:  #c0c8d8;
  --sidebar-hover: #252932;
  --sidebar-active:#2563eb;
  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --bg:            #f3f4f6;
  --surface:       #ffffff;
  --text:          #111827;
  --text-muted:    #6b7280;
  --border:        #e5e7eb;
  --danger:        #dc2626;
  --danger-hover:  #b91c1c;
  --unread-bg:     #eff6ff;
  --radius:        6px;
  --shadow:        0 1px 3px rgba(0,0,0,.1);
}

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

html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif;
  font-size: 15px; color: var(--text); background: var(--bg); }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }

/* === Layout === */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* === Sidebar === */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .2s;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.app-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: #fff;
}

.btn-compose {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 1.1rem;
  transition: background .15s;
}
.btn-compose:hover, .btn-compose.active { background: var(--accent-hover); }

.folder-list { flex: 1; padding: 8px 0; }

.folder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: var(--sidebar-text);
  border-radius: 0;
  transition: background .12s;
  font-size: .9rem;
}
.folder-item:hover  { background: var(--sidebar-hover); }
.folder-item.active { background: var(--accent); color: #fff; }

.folder-icon { font-size: 1rem; width: 20px; text-align: center; }
.folder-label { flex: 1; }

.badge {
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.folder-item.active .badge { background: rgba(255,255,255,.25); }

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  font-size: .8rem;
}
.sidebar-user { color: var(--sidebar-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  color: var(--sidebar-text);
  font-size: 1.1rem;
  padding: 4px 6px;
  border-radius: var(--radius);
  transition: background .12s, color .12s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* === Main content === */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* === Toolbar === */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.toolbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
.toolbar-count { font-size: .85rem; color: var(--text-muted); }
.toolbar-actions { display: flex; gap: 6px; }

.btn-menu {
  display: none;
  font-size: 1.2rem;
  padding: 4px 8px;
  color: var(--text-muted);
  border-radius: var(--radius);
}
.btn-menu:hover { background: var(--border); }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger  { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; padding: 10px; font-size: 1rem; }

/* === Message list === */
.msg-actions {
  display: flex;
  gap: 8px;
  padding: 8px 20px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
}

.msg-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
}

.msg-item {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.msg-item:hover { background: #f9fafb; }
.msg-item.unseen { background: var(--unread-bg); }
.msg-item.unseen:hover { background: #dbeafe; }

.msg-check {
  padding: 0 10px 0 16px;
  display: flex;
  align-items: center;
}
.msg-check input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; }

.msg-link {
  flex: 1;
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 0;
  overflow: hidden;
}

.msg-from {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-item.unseen .msg-from { font-weight: 700; }

.msg-subject {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
  font-size: .9rem;
}
.msg-item.unseen .msg-subject { color: var(--text); font-weight: 600; }

.msg-date {
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* === Pagination === */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.page-info { font-size: .88rem; color: var(--text-muted); }

/* === Empty state === */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 40px;
}
.empty-icon { font-size: 3rem; }

/* === Message view === */
.msg-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--surface);
  margin: 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.msg-header { margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 16px; }
.msg-subject { font-size: 1.2rem; font-weight: 700; margin-bottom: 12px; }

.msg-meta { display: grid; grid-template-columns: 60px 1fr; gap: 4px 12px; font-size: .88rem; }
.msg-meta dt { color: var(--text-muted); font-weight: 500; }
.msg-meta dd { word-break: break-all; }

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  font-size: .88rem;
  align-items: center;
}
.attachment-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background .12s;
}
.attachment-link:hover { background: #e5e7eb; }
.att-size { color: var(--text-muted); font-size: .8rem; }

.msg-body { font-size: .95rem; line-height: 1.6; overflow-wrap: break-word; }
.msg-body img { max-width: 100%; height: auto; }
.plain-body { white-space: pre-wrap; font-family: inherit; font-size: .9rem; }

/* === Compose === */
.compose-wrap { flex: 1; overflow-y: auto; padding: 20px; }

.compose-form {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.compose-field {
  display: flex;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
}
.compose-field label {
  width: 70px;
  min-width: 70px;
  padding: 12px 16px;
  font-size: .88rem;
  color: var(--text-muted);
  font-weight: 500;
}
.compose-field input,
.compose-field textarea {
  flex: 1;
  padding: 12px 16px;
  border: none;
  outline: none;
  font: inherit;
  font-size: .95rem;
  background: transparent;
  resize: none;
}
.compose-body-field { align-items: stretch; }
.compose-body-field label { padding-top: 14px; }
.compose-form textarea { min-height: 320px; }

.compose-actions {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  background: #f9fafb;
}

/* === Login === */
.page-login {
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-wrap { width: 100%; max-width: 380px; padding: 20px; }

.login-box {
  background: var(--surface);
  border-radius: 10px;
  padding: 36px 32px;
  box-shadow: 0 4px 24px rgba(0,0,0,.25);
}

.login-logo {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: .1em;
  color: var(--accent);
  text-align: center;
  margin-bottom: 4px;
}

.login-sub {
  text-align: center;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 28px;
  letter-spacing: .04em;
}

.login-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: .88rem;
  margin-bottom: 18px;
}

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}
.field input:focus { border-color: var(--accent); }

/* === Responsive === */
@media (max-width: 680px) {
  .btn-menu { display: flex; }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.3); }

  .msg-link {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  .msg-from  { grid-column: 1; grid-row: 1; }
  .msg-date  { grid-column: 2; grid-row: 1; }
  .msg-subject { grid-column: 1/-1; grid-row: 2; }

  .msg-view { margin: 0; border-radius: 0; }
  .toolbar-actions { display: none; }
}
