/* ============================================================
   M365 SoX Audit Portal – Custom Stylesheet
   Dark theme · Bootstrap 5 base · Mountain Time
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-base:       #0d1117;
  --bg-surface:    #161b22;
  --bg-elevated:   #1c2128;
  --bg-input:      #21262d;
  --border-subtle: #30363d;
  --border-muted:  #21262d;
  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #6e7681;
  --accent-blue:   #6366f1;
  --accent-green:  #22c55e;
  --accent-orange: #f97316;
  --accent-yellow: #f59e0b;
  --accent-red:    #ef4444;
  --accent-cyan:   #06b6d4;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.4);
  --shadow-md:     0 4px 16px rgba(0,0,0,.4);
}

/* ── Reset / Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ── Sidebar ───────────────────────────────────────────────── */
.sox-sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .25s ease;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.sidebar-brand {
  border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #1e40af, #7c3aed);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}

.sidebar-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding: .75rem 1rem .25rem;
  text-transform: uppercase;
}

.sidebar-link {
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .875rem;
  transition: background .15s, color .15s;
  display: flex; align-items: center;
}
.sidebar-link:hover  { background: var(--bg-elevated); color: var(--text-primary); }
.sidebar-link.active {
  background: rgba(99,102,241,.15);
  color: #818cf8;
  font-weight: 600;
}
.sidebar-link.active i { color: var(--accent-blue); }

.sidebar-user { background: var(--bg-elevated); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), #7c3aed);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.user-avatar-sm { width: 26px; height: 26px; font-size: .75rem; }

/* ── Main ──────────────────────────────────────────────────── */
.sox-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  background: var(--bg-base);
}

/* ── Topbar ────────────────────────────────────────────────── */
.sox-topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex; align-items: center;
}

/* ── Content ───────────────────────────────────────────────── */
.sox-content { min-height: calc(100vh - var(--topbar-height) - 40px); }

/* ── Footer ────────────────────────────────────────────────── */
.sox-footer {
  height: 40px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  font-size: .75rem;
}

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

.sox-card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  display: flex; align-items: center;
  font-size: .875rem;
}

.sox-card-body { padding: 1.25rem; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, box-shadow .2s;
}
.stat-card:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 1px var(--accent-blue), var(--shadow-sm);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}

.stat-value {
  font-size: 1.6rem; font-weight: 800;
  color: var(--text-primary); line-height: 1;
}

.stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .2rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Module Cards ───────────────────────────────────────────── */
.module-card {
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid transparent;
  transition: transform .2s, box-shadow .2s;
}
.module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.module-card-blue {
  background: linear-gradient(135deg, #1e3a8a 0%, #3730a3 100%);
  border-color: rgba(99,102,241,.3);
}
.module-card-green {
  background: linear-gradient(135deg, #14532d 0%, #065f46 100%);
  border-color: rgba(34,197,94,.3);
}

.module-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; color: #fff; flex-shrink: 0;
}

/* ── Tables ─────────────────────────────────────────────────── */
.sox-table { color: var(--text-primary); font-size: .83rem; }
.sox-table thead th {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .65rem 1rem;
  white-space: nowrap;
}
.sox-table tbody td {
  border-color: var(--border-muted);
  padding: .6rem 1rem;
  vertical-align: middle;
}
.sox-table tbody tr:hover td { background: var(--bg-elevated); }

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: .3rem .6rem;
}
.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_info { color: var(--text-secondary); }
.dataTables_wrapper { padding: 1rem; }

/* ── Tabs ───────────────────────────────────────────────────── */
.sox-tabs .nav-link {
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: .6rem 1rem;
  font-size: .875rem;
  transition: color .15s, border-color .15s;
}
.sox-tabs .nav-link:hover { color: var(--text-primary); }
.sox-tabs .nav-link.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
  background: transparent;
  font-weight: 600;
}
.sox-tabs { border-bottom-color: var(--border-subtle); }

/* ── Badges ─────────────────────────────────────────────────── */
.action-badge { font-weight: 700; letter-spacing: .03em; }
.action-login    { background: #1d4ed8; color: #bfdbfe; }
.action-logout   { background: #374151; color: #d1d5db; }
.action-export   { background: #065f46; color: #a7f3d0; }
.action-view     { background: #1e3a5f; color: #bae6fd; }
.action-add_app  { background: #14532d; color: #bbf7d0; }
.action-remove_app { background: #7f1d1d; color: #fecaca; }

.sso-badge { font-size: .72rem; }
.sso-saml { background: #1e3a8a; color: #bfdbfe; }
.sso-oidc { background: #14532d; color: #bbf7d0; }
.sso-password { background: #78350f; color: #fde68a; }
.sso-linked { background: #312e81; color: #ddd6fe; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn-xs {
  padding: .2rem .55rem;
  font-size: .75rem;
  border-radius: 4px;
}

.btn-msft {
  background: #2563eb;
  border: none;
  color: #fff;
  font-size: .95rem;
  border-radius: var(--radius-md);
  transition: background .2s, box-shadow .2s, transform .1s;
}
.btn-msft:hover {
  background: #1d4ed8;
  color: #fff;
  box-shadow: 0 4px 18px rgba(37,99,235,.45);
  transform: translateY(-1px);
}
.btn-msft:active { transform: none; }

/* ── Progress Modal ──────────────────────────────────────────── */
#progressModal .modal-content {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
#progressModal .progress { background: var(--bg-input); }

/* ── App icon ────────────────────────────────────────────────── */
.app-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ── Search result item ──────────────────────────────────────── */
.search-result-item {
  background: var(--bg-elevated);
  transition: border-color .15s;
}
.search-result-item:hover { border-color: var(--accent-green) !important; }

/* ── Toast ───────────────────────────────────────────────────── */
.sox-toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999; display: flex; flex-direction: column; gap: .5rem;
}
.sox-toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: .75rem 1.25rem;
  color: var(--text-primary);
  font-size: .85rem;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: .75rem;
  min-width: 280px; max-width: 380px;
  animation: toastIn .25s ease;
}
.sox-toast.toast-success { border-left: 3px solid var(--accent-green); }
.sox-toast.toast-danger  { border-left: 3px solid var(--accent-red); }
.sox-toast.toast-warning { border-left: 3px solid var(--accent-yellow); }
.sox-toast.toast-info    { border-left: 3px solid var(--accent-cyan); }
@keyframes toastIn {
  from { opacity:0; transform: translateX(20px); }
  to   { opacity:1; transform: none; }
}

/* ── Login page ──────────────────────────────────────────────── */
.login-body {
  background: var(--bg-base);
  overflow: hidden;
  height: 100vh;
  display: flex;
  align-items: stretch;
}

.login-bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.login-glow {
  position: fixed;
  top: -20%; left: 50%;
  transform: translateX(-50%);
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,.12) 0%, transparent 70%);
  pointer-events: none;
}

.login-container {
  display: flex;
  width: 100%; height: 100vh;
  position: relative; z-index: 1;
}

.login-panel-left {
  flex: 1;
  background: linear-gradient(150deg, #0f172a 0%, #1e1b4b 100%);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}

.login-panel-right {
  width: 480px;
  flex-shrink: 0;
  background: var(--bg-surface);
  overflow-y: auto;
}

.login-brand-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center;
}

.feature-bullet {
  display: flex; align-items: flex-start; gap: .875rem;
}
.feature-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #fff; flex-shrink: 0; margin-top: .1rem;
}

.login-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.login-avatar {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; color: #fff;
  margin: 0 auto;
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ── Utilities ───────────────────────────────────────────────── */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sox-sidebar {
    transform: translateX(-100%);
  }
  .sox-sidebar.show {
    transform: none;
  }
  .sox-main {
    margin-left: 0;
  }
  .login-panel-right {
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  .sox-content { padding: .75rem !important; }
  .sox-topbar  { padding: 0 .75rem !important; }
}
