/**
 * MailShelter Super Admin Portal
 * VIPRE-inspired theme — single authoritative stylesheet
 * Consolidates app.css + mailshelter-vipre-theme.css
 */

/* ══════════════════════════════════════════════════════════
   CSS VARIABLES
   ══════════════════════════════════════════════════════════ */
:root {
  /* Brand blues */
  --vipre-dark:    #1A3A6B;
  --vipre-primary: #2C5AA0;
  --vipre-medium:  #3D6DB3;
  --vipre-light:   #5B8CD9;
  --vipre-pale:    #E8F0F9;

  /* Neutrals */
  --bg-white:    #FFFFFF;
  --bg-light:    #F5F7FA;
  --bg-gray:     #E4E9F0;
  --border-gray: #CDD5E0;
  --text-dark:   #2C3E50;
  --text-medium: #5A6C7D;
  --text-light:  #8B96A3;

  /* Status */
  --success: #28A745;
  --warning: #FFC107;
  --danger:  #DC3545;
  --info:    #17A2B8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(44, 90, 160, 0.10);
  --shadow-md: 0 4px 6px rgba(44, 90, 160, 0.15);
  --shadow-lg: 0 10px 25px rgba(44, 90, 160, 0.20);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
  font-size: 14px;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════ */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--vipre-dark) 0%, var(--vipre-primary) 100%);
}

.login-card {
  background: var(--bg-white);
  padding: 40px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}

.login-card h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--vipre-primary);
  text-align: center;
  margin-bottom: 8px;
}

.login-card p {
  text-align: center;
  color: var(--text-medium);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 12px;
  margin-bottom: 30px;
}

.fg { margin-bottom: 20px; }

.fg label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.fg input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fg input:focus {
  outline: none;
  border-color: var(--vipre-primary);
  box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.10);
}

.msg {
  padding: 10px;
  margin-top: 15px;
  border-radius: 4px;
  font-size: 13px;
  min-height: 20px;
}

.msg-error   { background: rgba(220,53,69,.08);  color: #721c24; border-left: 3px solid var(--danger); }
.msg-success { background: rgba(40,167,69,.08);  color: #155724; border-left: 3px solid var(--success); }
.msg-info    { background: rgba(23,162,184,.08); color: #0c5460; border-left: 3px solid var(--info); }

/* ══════════════════════════════════════════════════════════
   APP SHELL
   ══════════════════════════════════════════════════════════ */
.app { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Top Bar ── */
.topbar {
  background: linear-gradient(135deg, var(--vipre-dark) 0%, var(--vipre-primary) 100%);
  color: white;
  padding: 0 25px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand { font-size: 20px; font-weight: 600; letter-spacing: 0.5px; }

.topbar-right { display: flex; align-items: center; gap: 20px; }

.user-info { display: flex; align-items: center; gap: 10px; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--vipre-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
}

.user-email { font-size: 14px; font-weight: 500; }

/* ── Main layout ── */
.main { display: flex; flex: 1; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════ */
.sidebar {
  width: 280px;
  background: var(--bg-white);
  border-right: 1px solid var(--border-gray);
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: var(--bg-light); }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background: var(--vipre-primary); }

/* Nav items */
.nav-item {
  padding: 11px 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 3px solid transparent;
  color: var(--text-dark);
  font-size: 14px;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  background: var(--vipre-pale);
  color: var(--vipre-primary);
  border-left-color: var(--vipre-light);
}

.nav-item.active {
  background: var(--vipre-pale);
  color: var(--vipre-primary);
  border-left-color: var(--vipre-primary);
  font-weight: 600;
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

/* Nav groups */
.nav-group { margin-top: 8px; }

.nav-group-header {
  padding: 10px 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color 0.2s;
  user-select: none;
}

.nav-group-header:hover { color: var(--vipre-primary); }

.nav-toggle {
  font-size: 12px;
  font-weight: bold;
  background: rgba(44,90,160,.08);
  padding: 3px 8px;
  border-radius: 4px;
  transition: transform 0.2s ease;
  line-height: 1;
}

.nav-group.collapsed .nav-toggle { transform: rotate(-90deg); }

.nav-group-items {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.nav-group.collapsed .nav-group-items { max-height: 0; }

.nav-group-items .nav-item {
  padding-left: 48px;
  font-size: 13px;
}

/* ══════════════════════════════════════════════════════════
   CONTENT AREA
   ══════════════════════════════════════════════════════════ */
.content {
  flex: 1;
  padding: 25px 30px;
  overflow-y: auto;
  background: var(--bg-light);
  min-width: 0;
}

.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-track { background: var(--bg-light); }
.content::-webkit-scrollbar-thumb { background: var(--border-gray); border-radius: 3px; }
.content::-webkit-scrollbar-thumb:hover { background: var(--vipre-primary); }

.page { display: none; }
.page.active { display: block; }

/* ── Page header ── */
.page-header { margin-bottom: 25px; }

.page-header h2 {
  font-size: 24px;
  font-weight: 600;
  color: var(--vipre-dark);
  margin-bottom: 6px;
}

.page-header p { color: var(--text-medium); font-size: 14px; }

/* ══════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════ */
.card {
  background: var(--bg-white);
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--bg-gray);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--vipre-dark);
}

.card > div:not(.card-header) { padding: 20px; }

/* ══════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════ */
.btn {
  padding: 9px 18px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--vipre-primary);
  color: white;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn:hover { background: var(--vipre-medium); box-shadow: var(--shadow-md); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-secondary { background: var(--bg-gray); color: var(--text-dark); }
.btn-secondary:hover { background: var(--border-gray); box-shadow: none; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #c82333; }

.btn-success { background: var(--success); }
.btn-success:hover { background: #218838; }

.btn-mini {
  padding: 3px 10px;
  font-size: 12px;
  background: var(--vipre-primary);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-mini:hover { background: var(--vipre-medium); }

/* ══════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════ */
table { width: 100%; border-collapse: collapse; }

thead { background: var(--vipre-pale); }

th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--vipre-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--vipre-primary);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--bg-gray);
  color: var(--text-dark);
}

tbody tr:hover { background: var(--vipre-pale); }

td .btn { margin-right: 4px; }

.actions { display: flex; gap: 6px; justify-content: flex-end; }

/* data-table alias used by monitoring.js */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--vipre-pale); }
.data-table th { padding: 11px 14px; font-size: 11px; font-weight: 700; color: var(--vipre-primary);
  text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid var(--vipre-primary); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--bg-gray); }
.data-table tbody tr:hover { background: var(--vipre-pale); }

/* ══════════════════════════════════════════════════════════
   BADGES
   ══════════════════════════════════════════════════════════ */
.badge {
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-block;
  background: var(--bg-gray);
  color: var(--text-medium);
}

.badge-green  { background: rgba(40,167,69,.12);  color: #1a6e2e; }
.badge-red    { background: rgba(220,53,69,.12);  color: #8b1a24; }
.badge-yellow { background: rgba(255,193,7,.15);  color: #8a6100; }
.badge-blue   { background: rgba(44,90,160,.12);  color: var(--vipre-dark); }
.badge-gray   { background: rgba(139,150,163,.12); color: var(--text-medium); }

/* ══════════════════════════════════════════════════════════
   DASHBOARD STATS
   ══════════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--bg-white);
  padding: 20px;
  border-radius: 6px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--vipre-primary);
}

.stat-card.stat-success { border-left-color: var(--success); }
.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-danger  { border-left-color: var(--danger);  }

.stat-label {
  font-size: 11px;
  color: var(--text-medium);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-value { font-size: 30px; font-weight: 700; color: var(--vipre-dark); }

/* ══════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }

.form-group label, .form-label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
}

.form-control,
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="number"],
.modal-body input[type="date"],
.modal-body input[type="password"],
.modal-body input[type="url"],
.modal-body select,
.modal-body textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  font-size: 14px;
  color: var(--text-dark);
  background: var(--bg-white);
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: auto;
}

.form-control:focus,
.modal-body input:focus,
.modal-body select:focus,
.modal-body textarea:focus {
  outline: none;
  border-color: var(--vipre-primary);
  box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.10);
}

.modal-body input[type="checkbox"] {
  width: auto;
  margin-right: 6px;
  accent-color: var(--vipre-primary);
}

.modal-body select option { background: var(--bg-white); color: var(--text-dark); }

/* ══════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  background: var(--bg-white);
  padding: 18px 20px;
  border-bottom: 1px solid var(--bg-gray);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 { font-size: 17px; font-weight: 600; color: var(--vipre-dark); }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.modal-close:hover { color: var(--text-dark); background: var(--bg-gray); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body h4 {
  color: var(--vipre-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--bg-gray);
  padding-bottom: 6px;
  margin-top: 20px;
  margin-bottom: 12px;
}

.modal-body p      { color: var(--text-dark); }
.modal-body strong { color: var(--text-dark); font-weight: 600; }
.modal-body small  { color: var(--text-medium); font-size: 11px; }
.modal-body span   { color: var(--text-dark); }

.modal-footer {
  background: var(--bg-white);
  padding: 14px 20px;
  border-top: 1px solid var(--bg-gray);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-shrink: 0;
}

.modal-msg { padding: 0 20px 16px; font-size: 13px; color: var(--text-dark); }

/* ── Quarantine email preview (dark theme, scoped) ── */
.modal-body .header-content,
.modal-body .header-content * { color: #f1f5f9; }

.modal-body .header-content strong { color: #94a3b8; font-weight: 600; }

.modal-body .header-tab { color: #94a3b8; cursor: pointer; }
.modal-body .header-tab.active { color: #60a5fa; border-bottom-color: #60a5fa; }

.modal-content:has(.header-content) { background: #1e293b; color: #f1f5f9; }
.modal-content:has(.header-content) .modal-header { background: #0f172a; color: #f1f5f9; border-bottom-color: #334155; }
.modal-content:has(.header-content) .modal-header h3 { color: #f1f5f9; }
.modal-content:has(.header-content) .modal-body { background: #1e293b; color: #f1f5f9; }
.modal-content:has(.header-content) .modal-footer { background: #0f172a; border-top-color: #334155; }

/* ══════════════════════════════════════════════════════════
   TABS
   ══════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--bg-gray);
}

.tab {
  padding: 11px 22px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: var(--text-medium);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.2s;
  margin-bottom: -2px;
  user-select: none;
}

.tab:hover  { color: var(--vipre-primary); background: var(--vipre-pale); }
.tab.active { color: var(--vipre-primary); border-bottom-color: var(--vipre-primary); font-weight: 600; }

.tab-content         { display: none; }
.tab-content.active  { display: block; }

/* ══════════════════════════════════════════════════════════
   BREADCRUMB
   ══════════════════════════════════════════════════════════ */
.breadcrumb {
  padding: 10px 16px;
  background: var(--bg-white);
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.breadcrumb a { color: var(--vipre-primary); text-decoration: none; transition: color 0.2s; }
.breadcrumb a:hover { color: var(--vipre-medium); text-decoration: underline; }
.breadcrumb span { color: var(--text-medium); margin: 0 6px; }

/* ══════════════════════════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
  font-size: 14px;
}

/* ══════════════════════════════════════════════════════════
   MESSAGE LOG TABLE
   ══════════════════════════════════════════════════════════ */
#tblMessageLog { overflow-x: auto; }

#tblMessageLog table { width: 100%; font-size: 13px; }

#tblMessageLog th,
#tblMessageLog td { white-space: nowrap; padding: 8px 12px; }

/* Sender / recipient columns allowed to wrap */
#tblMessageLog td:nth-child(4),
#tblMessageLog td:nth-child(5) {
  max-width: 200px;
  white-space: normal;
  word-break: break-all;
}

/* ══════════════════════════════════════════════════════════
   LOGO UPLOAD WIDGET
   ══════════════════════════════════════════════════════════ */
.logo-upload-area {
  border: 2px dashed var(--border-gray);
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-light);
  position: relative;
}

.logo-upload-area:hover,
.logo-upload-area.dragover {
  border-color: var(--vipre-primary);
  background: var(--vipre-pale);
}

.logo-upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.logo-upload-area .upload-icon    { font-size: 32px; margin-bottom: 8px; color: var(--text-light); }
.logo-upload-area .upload-label   { font-size: 14px; color: var(--vipre-primary); font-weight: 600; }
.logo-upload-area .upload-hint    { font-size: 12px; color: var(--text-light); margin-top: 4px; }
.logo-upload-area .upload-guidelines {
  font-size: 11px;
  color: var(--text-medium);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-gray);
  text-align: left;
}

.logo-preview {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-white);
  border: 1px solid var(--border-gray);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-preview img {
  max-width: 160px;
  max-height: 60px;
  object-fit: contain;
  border-radius: 2px;
}

.logo-preview .logo-preview-info { font-size: 12px; color: var(--text-medium); }

.btn-remove-logo {
  margin-left: auto;
  padding: 4px 10px;
  font-size: 12px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

/* ══════════════════════════════════════════════════════════
   TREE VIEW (tenant hierarchy)
   ══════════════════════════════════════════════════════════ */
.tree-caret {
  width: 22px;
  height: 22px;
  font-size: 14px;
  font-weight: bold;
  background: rgba(44,90,160,.08);
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  cursor: pointer;
  flex-shrink: 0;
}

.tree-caret:hover { background: rgba(44,90,160,.18); }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { width: 240px; }
  .brand   { font-size: 18px; }
  .user-email { display: none; }
}

@media (max-width: 480px) {
  .sidebar {
    position: fixed;
    left: 0; top: 60px; bottom: 0;
    transform: translateX(-100%);
    transition: transform 0.3s;
    z-index: 999;
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .stats-grid { grid-template-columns: 1fr; }
}
