/* ==========================================================================
   Avosina IT User Onboarding Portal — Stylesheet
   Corporate theme inspired by Microsoft 365 / Azure Portal / Atlassian.
   Supports light and dark mode via [data-bs-theme] + CSS custom properties.
   ========================================================================== */

:root,
[data-bs-theme="light"] {
  --brand-primary: #2f6fed;
  --brand-primary-dark: #1e4fc4;
  --brand-accent: #7c3aed;

  --surface-0: #f4f6fb;   /* page background */
  --surface-1: #ffffff;   /* cards / panels */
  --surface-2: #f8f9fc;   /* subtle fill */
  --surface-border: #e3e7f0;

  --text-primary: #1b2430;
  --text-secondary: #667085;
  --text-muted: #98a2b3;

  --sidenav-bg: #ffffff;
  --topbar-bg: #ffffff;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, 0.08);

  --success: #12b76a;
  --warning: #f79009;
  --danger: #f04438;
  --info: #2f6fed;
}

[data-bs-theme="dark"] {
  --brand-primary: #5b8dfd;
  --brand-primary-dark: #3f6fe0;
  --brand-accent: #a78bfa;

  --surface-0: #0f1420;
  --surface-1: #161d2e;
  --surface-2: #1c2438;
  --surface-border: #2a3450;

  --text-primary: #e7ecf7;
  --text-secondary: #9aa7c2;
  --text-muted: #6b7690;

  --sidenav-bg: #131a2a;
  --topbar-bg: #131a2a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);

  --success: #32d583;
  --warning: #fdb022;
  --danger: #f97066;
  --info: #5b8dfd;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, sans-serif;
  transition: background-color .2s ease, color .2s ease;
}

/* ---------------------------------------------------------------------- */
/* Top bar                                                                 */
/* ---------------------------------------------------------------------- */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--surface-border);
  box-shadow: var(--shadow-sm);
  z-index: 1030;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }

.brand-text strong {
  color: var(--text-primary);
  font-size: 1rem;
  line-height: 1.1;
}

.brand-text small {
  color: var(--text-secondary);
  font-size: .72rem;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface-1);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .15s ease, transform .15s ease;
}
.btn-icon:hover { background: var(--surface-2); transform: translateY(-1px); }

/* ---------------------------------------------------------------------- */
/* App shell / layout                                                     */
/* ---------------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: calc(100vh - 60px);
}

.sidenav {
  width: 230px;
  flex-shrink: 0;
  background: var(--sidenav-bg);
  border-right: 1px solid var(--surface-border);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
}

.sidenav .nav-link {
  color: var(--text-secondary);
  border-radius: 10px;
  padding: .65rem .85rem;
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: .92rem;
  font-weight: 500;
  transition: background-color .15s ease, color .15s ease;
}
.sidenav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidenav .nav-link:hover { background: var(--surface-2); color: var(--text-primary); }
.sidenav .nav-link.active {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.app-main {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
  min-width: 0;
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidenav {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--surface-border);
  }
  .sidenav .nav { flex-direction: row !important; overflow-x: auto; flex-wrap: nowrap !important; }
  .sidenav .nav-link span { display: none; }
  .app-main { padding: 1.25rem 1rem 2rem; }
}

/* ---------------------------------------------------------------------- */
/* Page header / typography                                               */
/* ---------------------------------------------------------------------- */
.page-header { margin-bottom: 1.5rem; animation: fadeInUp .35s ease; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .15rem; }

.section-title {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text-primary);
}
.section-title i { color: var(--brand-primary); }

/* ---------------------------------------------------------------------- */
/* Cards / panels                                                         */
/* ---------------------------------------------------------------------- */
.panel {
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  animation: fadeInUp .35s ease;
}
.panel-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--surface-border);
}
.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.panel-body { padding: 1.25rem; }

/* Stat cards */
.stat-row { margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .9rem;
  height: 100%;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
  animation: fadeInUp .4s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  flex-shrink: 0;
}
.bg-blue { background: linear-gradient(135deg,#2f6fed,#1e4fc4); }
.bg-amber { background: linear-gradient(135deg,#f79009,#dc6803); }
.bg-green { background: linear-gradient(135deg,#12b76a,#079455); }
.bg-purple { background: linear-gradient(135deg,#7c3aed,#5b21b6); }

.stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .78rem; color: var(--text-secondary); }

.quick-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }

/* Empty states */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 2rem; display: block; margin-bottom: .5rem; }

/* ---------------------------------------------------------------------- */
/* Tables                                                                  */
/* ---------------------------------------------------------------------- */
.table { color: var(--text-primary); }
.table thead th {
  color: var(--text-secondary);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-weight: 600;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-2);
}
.table td, .table th { border-color: var(--surface-border); vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */
.form-label { font-weight: 500; font-size: .85rem; color: var(--text-secondary); }
.form-control, .form-select {
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
  border-radius: 8px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, .15);
  background: var(--surface-1);
  color: var(--text-primary);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--text-muted); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  border: none;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-primary-dark), var(--brand-primary-dark)); }

/* ---------------------------------------------------------------------- */
/* Employee / email tabs                                                  */
/* ---------------------------------------------------------------------- */
.employee-tabs, #emailPreviewTabs { border-bottom: 1px solid var(--surface-border); margin-bottom: 1rem; flex-wrap: wrap; }
.employee-tabs .nav-link, #emailPreviewTabs .nav-link {
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  font-size: .88rem;
  font-weight: 500;
  padding: .55rem .9rem;
}
.employee-tabs .nav-link.active, #emailPreviewTabs .nav-link.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  background: transparent;
}
.employee-tabs .nav-link .bi-x-circle { margin-left: .4rem; opacity: .6; }
.employee-tabs .nav-link .bi-x-circle:hover { opacity: 1; color: var(--danger); }

/* ---------------------------------------------------------------------- */
/* Access systems / checkboxes                                            */
/* ---------------------------------------------------------------------- */
.access-system-card {
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  padding: .85rem 1rem;
  margin-bottom: .6rem;
  background: var(--surface-2);
}
.access-system-card .form-check-label { font-weight: 600; }
.access-system-card .system-detail-grid {
  margin-top: .6rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .5rem;
}
.access-system-card .system-detail-grid .form-control,
.access-system-card .system-detail-grid .form-select { font-size: .85rem; }
.access-system-card.disabled { opacity: .55; }

.client-checkbox-grid, .hardware-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .35rem .75rem;
  max-height: 260px;
  overflow-y: auto;
  padding: .5rem;
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  background: var(--surface-2);
}
.hardware-checkbox-grid { max-height: none; }

/* ---------------------------------------------------------------------- */
/* Login screen                                                           */
/* ---------------------------------------------------------------------- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(47,111,237,.15), transparent 40%),
              radial-gradient(circle at 80% 80%, rgba(124,58,237,.12), transparent 40%),
              var(--surface-0);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 2rem;
  animation: fadeInUp .35s ease;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: 1.5rem;
}
.login-brand strong { font-size: 1.05rem; }

/* ---------------------------------------------------------------------- */
/* User menu (topbar)                                                     */
/* ---------------------------------------------------------------------- */
.btn-user-menu {
  display: flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid var(--surface-border);
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 999px;
  padding: .35rem .75rem;
  font-size: .85rem;
}
.btn-user-menu:hover { background: var(--surface-2); }
.btn-user-menu::after { display: none; }

/* ---------------------------------------------------------------------- */
/* Autocomplete (mirror user search)                                      */
/* ---------------------------------------------------------------------- */
.autocomplete-list {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  padding: .3rem;
}
.autocomplete-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: .45rem .6rem;
  border-radius: 8px;
  font-size: .85rem;
  color: var(--text-primary);
}
.autocomplete-item:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------------- */
/* Drop zone                                                               */
/* ---------------------------------------------------------------------- */
.drop-zone {
  border: 2px dashed var(--surface-border);
  border-radius: 14px;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
  transition: border-color .15s ease, background-color .15s ease;
}
.drop-zone i { font-size: 2.5rem; color: var(--brand-primary); display: block; margin-bottom: .75rem; }
.drop-zone.dragover { border-color: var(--brand-primary); background: rgba(47,111,237,.06); }

/* ---------------------------------------------------------------------- */
/* Toolbar                                                                 */
/* ---------------------------------------------------------------------- */
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------------------------------------------------------------------- */
/* Email preview document                                                 */
/* ---------------------------------------------------------------------- */
.email-doc {
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 1.75rem;
  max-width: 780px;
  box-shadow: var(--shadow-sm);
  animation: fadeInUp .3s ease;
}
.email-doc h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: .25rem; }
.email-doc .doc-meta { color: var(--text-secondary); font-size: .82rem; margin-bottom: 1rem; }
.email-doc table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.email-doc table th, .email-doc table td {
  border: 1px solid var(--surface-border);
  padding: .5rem .65rem;
  font-size: .87rem;
  text-align: left;
}
.email-doc table th { background: var(--surface-2); width: 220px; }
.email-doc .doc-section-title {
  font-weight: 700;
  font-size: .95rem;
  margin: 1.1rem 0 .5rem;
  color: var(--brand-primary);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.email-doc .signature { margin-top: 1.5rem; white-space: pre-line; color: var(--text-secondary); font-size: .88rem; }
.email-doc .invited-badge {
  display: inline-block;
  background: rgba(18,183,106,.12);
  color: var(--success);
  padding: .15rem .55rem;
  border-radius: 6px;
  font-size: .78rem;
  font-weight: 600;
}

/* ---------------------------------------------------------------------- */
/* Misc utility                                                           */
/* ---------------------------------------------------------------------- */
.badge-profile { background: rgba(47,111,237,.12); color: var(--brand-primary); font-weight: 600; }
.list-group-item { background: var(--surface-1); color: var(--text-primary); border-color: var(--surface-border); }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--surface-border); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

@media print {
  .topbar, .sidenav, .toolbar, .quick-actions, #emailPreviewTabs, .btn { display: none !important; }
  .app-main { padding: 0; }
  .email-preview-content .tab-pane { display: block !important; opacity: 1 !important; }
}
