/* ==== GLOBAL ==== */
body {
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

:root {
  --bg: #f4f6f8;
  --text: #222;
  --card-bg: #fff;
  --accent: #1a73e8;
  --accent-hover: #1558b0;
  --border: #e0e0e0;
}

body.dark {
  --bg: #121212;
  --text: #f1f1f1;
  --card-bg: #1f1f1f;
  --accent: #4dabf7;
  --accent-hover: #1a8fe3;
  --border: #2a2a2a;
}

/* ==== HEADER ==== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

header h1 {
  margin: 0;
  font-size: 1.4em;
  font-weight: 600;
}

.theme-toggle {
  cursor: pointer;
  font-size: 1.3em;
}

#user-panel span {
  font-weight: 600;
  font-size: 0.95em;
}

/* ==== NAV ==== */
nav {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

nav .tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 0.95em;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text);
  transition: background 0.2s;
}

nav .tab.active,
nav .tab:hover {
  background: var(--accent);
  color: #fff;
}

/* ==== MAIL LIST ==== */
.mail-list {
  max-width: 900px;
  margin: auto;
  padding: 10px;
}

.mail-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.mail-card:hover {
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

body.dark .mail-card:hover {
  background: rgba(255, 255, 255, 0.05);
}

.avatar {
  min-width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1em;
}

.mail-main {
  flex: 1;
  min-width: 0;
}

.mail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mail-from {
  font-weight: 600;
  font-size: 0.95em;
}

.mail-date {
  font-size: 0.85em;
  color: gray;
}

.mail-subject {
  font-size: 1em;
  font-weight: 500;
  margin: 3px 0;
}

.mail-snippet {
  font-size: 0.88em;
  color: gray;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==== COMPOSE BUTTON ==== */
.compose-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.compose-btn:hover {
  background: var(--accent-hover);
}

/* ==== MODAL ==== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 8px;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

body.dark .modal-content {
  background: #1e1e1e;
}

/* ==== COMPOSE FORM ==== */
.compose-form input,
.compose-form textarea {
  width: 100%;
  margin-bottom: 12px;
  padding: 8px;
  font-size: 0.95em;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
}

.compose-form button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.compose-form button:hover {
  background: var(--accent-hover);
}

/* ==== PAGINATION ==== */
#pagination {
  text-align: center;
  margin: 20px 0;
}

.page-btn {
  border: none;
  background: none;
  color: var(--accent);
  padding: 5px 10px;
  cursor: pointer;
}

.page-btn.active {
  font-weight: bold;
  border-bottom: 2px solid var(--accent);
}

/* ==== MOBILE ==== */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  nav {
    flex-wrap: wrap;
  }
  .mail-card {
    padding: 12px 8px;
  }
}

