/* =======================================
   Mail System — Clean Minimal UI
   ======================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #F7F8FA;
  --surface:   #FFFFFF;
  --border:    #E2E5EA;
  --text:      #1A1D23;
  --muted:     #6B7280;
  --accent:    #2563EB;
  --accent-h:  #1D4ED8;
  --danger:    #DC2626;
  --success:   #16A34A;
  --radius:    10px;
  --shadow:    0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Login Page ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
}
.login-card .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-card .logo svg { color: var(--accent); }
.login-card .logo span { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.login-card h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-card p.sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }

/* ---- Form Elements ---- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
  background: #fff;
}
.form-group textarea { resize: vertical; min-height: 100px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-ghost    { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

/* ---- Alert ---- */
.alert { padding: 12px 16px; border-radius: 7px; font-size: 14px; margin-bottom: 18px; }
.alert-error   { background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: var(--success); border: 1px solid #BBF7D0; }

/* ---- Layout (Admin / User) ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.sidebar .brand svg { color: var(--accent); }
.sidebar .brand span { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: background .1s, color .1s;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: #EFF6FF;
  color: var(--accent);
}
.sidebar .logout-btn {
  margin-top: auto;
  padding: 0 20px;
}

.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 32px;
}

/* ---- Page Header ---- */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p  { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---- Cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 16px; font-weight: 600; }
.card-body { padding: 24px; }

/* ---- Table ---- */
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFBFC; }

/* ---- Badge ---- */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green  { background: #DCFCE7; color: var(--success); }
.badge-red    { background: #FEE2E2; color: var(--danger); }
.badge-blue   { background: #DBEAFE; color: var(--accent); }

/* ---- Mail Inbox ---- */
.mail-list { list-style: none; }
.mail-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
.mail-item:hover { background: var(--bg); }
.mail-item.unread { background: #EFF6FF; }
.mail-item.unread .mail-subject { font-weight: 700; }
.mail-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.mail-meta { flex: 1; min-width: 0; }
.mail-from  { font-size: 13px; font-weight: 600; }
.mail-subject { font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-preview { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-time  { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---- Stats (Admin) ---- */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.stat-card .label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 6px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; }
  .main-content { margin-left: 0; padding: 20px; }
  .layout { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
}
