/* ============================================================
   RWEB SERVICE EMAIL — Global Design System v2
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --brand-primary:   #6366f1;
  --brand-secondary: #8b5cf6;
  --brand-accent:    #a78bfa;
  --brand-glow:      rgba(99,102,241,0.3);
  --brand-dark:      #1e1b4b;

  --sidebar-bg:      #0d0c18;
  --sidebar-border:  rgba(255,255,255,0.06);
  --sidebar-hover:   rgba(99,102,241,0.14);
  --sidebar-active-from: #6366f1;
  --sidebar-active-to:   #8b5cf6;
  --sidebar-width:   260px;

  --bg-base:         #f0f4ff;
  --surface:         #ffffff;
  --surface-2:       #f8faff;
  --surface-3:       #eef2ff;
  --border:          #e4e8f5;
  --border-focus:    #6366f1;

  --text-primary:    #0f0d2a;
  --text-secondary:  #4a5070;
  --text-muted:      #8892b0;

  --radius-xs:  4px;
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --radius-xl:  24px;

  --shadow-sm:  0 1px 4px rgba(16,22,58,0.07);
  --shadow-md:  0 4px 24px rgba(16,22,58,0.09);
  --shadow-lg:  0 12px 48px rgba(16,22,58,0.14);
  --shadow-brand: 0 6px 24px rgba(99,102,241,0.35);

  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
  --transition-slow: 0.35s cubic-bezier(0.4,0,0.2,1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Layout ──────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
#sidebarMenu {
  background: var(--sidebar-bg) !important;
  border-right: 1px solid var(--sidebar-border) !important;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 22px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 22px;
  text-decoration: none;
}

.sidebar-brand img {
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.sidebar-brand-text {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.sidebar-brand-sub {
  font-size: 0.65rem;
  color: var(--brand-accent);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}

.nav-section-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.25);
  font-weight: 700;
  padding: 0 12px;
  margin: 18px 0 6px;
}

.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: rgba(255,255,255,0.58);
  font-size: 0.87rem;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.sidebar-nav-link:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.9);
  transform: translateX(2px);
}

.sidebar-nav-link.active {
  background: linear-gradient(135deg, var(--sidebar-active-from), var(--sidebar-active-to));
  color: #fff;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  font-weight: 600;
}

.sidebar-nav-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav-badge {
  margin-left: auto;
  background: var(--brand-primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 50px;
  min-width: 20px;
  text-align: center;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 10px;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-email {
  font-size: 0.76rem;
  color: rgba(255,255,255,0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.15);
  color: #fca5a5;
  font-size: 0.87rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
}

.sidebar-logout:hover {
  background: rgba(239,68,68,0.18);
  color: #fecaca;
  transform: translateX(2px);
}

/* ── Mobile Top Bar ──────────────────────────────────────── */
.mobile-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1050;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.mobile-topbar-brand img { height: 28px; border-radius: 7px; }
.mobile-topbar-brand span {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.mobile-menu-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background var(--transition);
}
.mobile-menu-btn:hover { background: rgba(255,255,255,0.16); color: #fff; }

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 32px 36px;
  min-width: 0;
  background: var(--bg-base);
}

@media (max-width: 991.98px) {
  .layout { flex-direction: column; }
  .main-content {
    margin-top: 60px;
    padding: 20px 16px;
    width: 100%;
  }
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.1;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 5px 0 0;
  font-weight: 400;
}

/* ── Stat Chips ──────────────────────────────────────────── */
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 5px 14px 5px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

.stat-chip i { font-size: 0.85rem; color: var(--brand-primary); }

.stat-chip.unread {
  background: rgba(99,102,241,0.08);
  border-color: rgba(99,102,241,0.2);
  color: var(--brand-primary);
}

/* ── Cards ───────────────────────────────────────────────── */
.card-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card-surface:hover { box-shadow: var(--shadow-lg); }

/* ── Search Bar ──────────────────────────────────────────── */
.search-bar {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

.search-bar:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.12);
}

.search-bar i { color: var(--text-muted); font-size: 0.9rem; }

.search-bar input {
  border: none;
  outline: none;
  background: transparent;
  width: 100%;
  padding: 13px 0;
  font-size: 0.9rem;
  color: var(--text-primary);
  font-family: inherit;
}

.search-bar input::placeholder { color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn-brand {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 10px 22px;
  font-weight: 600;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: var(--shadow-brand);
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: -0.01em;
}

.btn-brand:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(99,102,241,0.45);
}

.btn-brand:active { transform: translateY(0); }

.btn-ghost {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 50px;
  padding: 9px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn-ghost:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(99,102,241,0.05);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* ── Email Table ─────────────────────────────────────────── */
.email-table thead th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.email-row {
  cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}

.email-row:hover { background: var(--surface-3); }

.email-row.unread {
  background: rgba(99,102,241,0.05);
  border-left: 3px solid var(--brand-primary);
}

.email-row.unread:hover { background: rgba(99,102,241,0.1); }

.email-row td {
  padding: 14px 20px;
  vertical-align: middle;
  border-bottom: 1px solid #eef0f8;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.email-row.unread td { color: var(--text-primary); }

.email-subject { font-weight: 600; color: var(--text-primary); }
.email-subject a { color: inherit; text-decoration: none; }

.email-snippet {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.8rem;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 380px;
  display: block;
}

.email-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

/* ── Email Mobile Items ──────────────────────────────────── */
.email-mobile-item {
  display: block;
  padding: 15px 16px;
  text-decoration: none;
  border-bottom: 1px solid #eef0f8;
  background: var(--surface);
  transition: background var(--transition);
  position: relative;
}

.email-mobile-item:hover { background: var(--surface-2); }

.email-mobile-item.unread {
  background: rgba(99,102,241,0.04);
  border-left: 3px solid var(--brand-primary);
}

/* ── Badges ──────────────────────────────────────────────── */
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.badge-unread {
  background: rgba(99,102,241,0.12);
  color: var(--brand-primary);
}

/* ── Icon Buttons ────────────────────────────────────────── */
.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.icon-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(99,102,241,0.07);
  transform: scale(1.08);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 7px;
  display: block;
}

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: 'Inter', sans-serif;
  width: 100%;
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px rgba(99,102,241,0.1);
  outline: none;
}

/* ── Pagination ──────────────────────────────────────────── */
.page-link {
  border: 1.5px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 13px;
  margin: 0 2px;
  transition: all var(--transition);
  background: var(--surface);
}

.page-link:hover {
  border-color: var(--brand-primary) !important;
  color: var(--brand-primary);
  background: rgba(99,102,241,0.06);
}

.page-item.active .page-link {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-color: var(--brand-primary) !important;
  color: #fff;
  box-shadow: var(--shadow-brand);
}

/* ── Read Card ───────────────────────────────────────────── */
.read-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.read-card-header {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  padding: 32px 36px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.read-card-header::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
}

.read-card-header::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: 30%;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(255,255,255,0.04);
}

.read-avatar {
  width: 54px;
  height: 54px;
  border-radius: 15px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 800;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.read-card-body { padding: 32px 36px; }

@media (max-width: 767px) {
  .read-card-header { padding: 22px 20px; }
  .read-card-body { padding: 22px 20px; }
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success {
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  color: #15803d;
  border-left: 4px solid #22c55e;
}

.alert-danger {
  background: linear-gradient(135deg, #fef2f2, #fee2e2);
  color: #b91c1c;
  border-left: 4px solid #ef4444;
}

.alert-warning {
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

/* ── Contacts ────────────────────────────────────────────── */
.contacts-table td, .contacts-table th {
  vertical-align: middle;
  padding: 15px 18px;
  font-size: 0.875rem;
}

/* ── Settings Card ───────────────────────────────────────── */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 24px;
  transition: box-shadow var(--transition);
}

.settings-card:hover { box-shadow: var(--shadow-lg); }

.settings-card-header {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(99,102,241,0.3);
  flex-shrink: 0;
}

.settings-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.settings-card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.settings-card-body { padding: 26px; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3.5rem;
  opacity: 0.2;
  display: block;
  margin-bottom: 16px;
  line-height: 1;
}

.empty-state h5 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state p { font-size: 0.875rem; }

/* ── Attachment Cards ────────────────────────────────────── */
.attachment-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
}

.attachment-card:hover {
  border-color: var(--brand-primary);
  background: rgba(99,102,241,0.05);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.attachment-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(139,92,246,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-primary);
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ── Refresh Indicator ───────────────────────────────────── */
.refresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: pulse-dot 2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.4);
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

/* ── Sent Row ────────────────────────────────────────────── */
.sent-row {
  cursor: pointer;
  transition: background var(--transition);
}

.sent-row:hover { background: var(--surface-3); }

.sent-row td {
  padding: 14px 20px;
  vertical-align: middle;
  border-bottom: 1px solid #eef0f8;
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,0.4); }

/* ── Table Bootstrap override ────────────────────────────── */
.table > :not(caption) > * > * { background-color: transparent; }

/* ── Focus Ring ──────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}
