/* ===== Base ===== */
html {
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg-alt);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, .h1 { font-size: var(--font-size-2xl); font-weight: 600; }
h2, .h2 { font-size: var(--font-size-xl); font-weight: 600; }
h3, .h3 { font-size: var(--font-size-lg); font-weight: 600; }
h4, .h4 { font-size: var(--font-size-base); font-weight: 600; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--color-primary-light);
  text-decoration: underline;
}

/* ===== Layout ===== */
.wrapper {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.page-layout {
  display: flex;
  flex: 1;
}

/* ===== Header ===== */
.app-header {
  height: var(--header-height);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
  display: flex;
  align-items: center;
  padding: 0 var(--content-padding-x);
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-header .brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.app-header .brand:hover {
  text-decoration: none;
  color: var(--color-primary-dark);
}

.app-header .brand .brand-logo {
  width: 32px;
  height: 32px;
  background: var(--color-primary);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--color-border);
  padding: var(--sidebar-padding-y) var(--sidebar-padding-x);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
}

.sidebar .sidebar-user {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar .sidebar-section {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sidebar-section-color);
  padding: 0.75rem 0.75rem 0.25rem;
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  font-size: var(--sidebar-font-size);
  color: var(--sidebar-link-color);
  border-radius: var(--border-radius);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar .nav-link:hover {
  background: var(--sidebar-link-hover-bg);
  text-decoration: none;
  color: var(--color-primary);
}

.sidebar .nav-link.active {
  background: var(--sidebar-link-active-bg);
  color: var(--sidebar-link-active-color);
  font-weight: 500;
}

.sidebar .nav-link .nav-icon {
  width: 18px;
  text-align: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.sidebar .sidebar-contact {
  margin-top: auto;
  padding: 0.75rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
}

.sidebar .sidebar-contact a {
  color: var(--color-primary);
}

/* ===== Content Area ===== */
.content-area {
  flex: 1;
  padding: var(--content-padding-y) var(--content-padding-x);
  min-width: 0;
  background: var(--color-bg-alt);
}

.content-area > .container-fluid {
  max-width: 1200px;
}

/* ===== Cards ===== */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xs);
  border-left: 4px solid var(--color-primary);
  margin-bottom: 1.25rem;
}

.card-header {
  background: var(--color-primary-subtle);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.card-body {
  padding: 1.25rem;
}

/* ===== Tables ===== */
.table {
  font-size: var(--font-size-sm);
  margin-bottom: 0;
}

.table > :not(caption) > * > * {
  padding: 0.625rem 0.75rem;
  vertical-align: middle;
}

.table > thead {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.table > thead > tr > th {
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
}

.table-striped > tbody > tr:nth-of-type(odd) {
  background: var(--color-bg-alt);
}

.table-hover > tbody > tr:hover {
  background: var(--color-primary-subtle);
}

.table-bordered {
  border-color: var(--color-border);
}

/* ===== Buttons ===== */
.btn {
  font-size: var(--font-size-sm);
  border-radius: var(--border-radius);
  padding: 0.4rem 1rem;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}
.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: white;
}

.btn-outline-primary {
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline-primary:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

/* ===== Badges ===== */
.badge {
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0.25em 0.6em;
  border-radius: 9999px;
}

/* ===== Forms ===== */
.form-control, .form-select {
  font-size: var(--font-size-sm);
  border-radius: var(--border-radius);
  border-color: var(--color-border);
  padding: 0.45rem 0.75rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 0.2rem rgba(7, 79, 135, 0.15);
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.35rem;
}

/* ===== Alerts ===== */
.alert {
  border-radius: var(--border-radius-lg);
  border: none;
  font-size: var(--font-size-sm);
}

/* ===== Validation ===== */
.validation-message {
  color: var(--color-danger);
  font-size: var(--font-size-sm);
}

.valid.modified:not([type=checkbox]) {
  outline: 1px solid var(--color-success);
}

.invalid {
  outline: 1px solid var(--color-danger);
}

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--border-radius-lg);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--color-bg);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

/* ===== Page Title ===== */
.page-title {
  font-size: var(--font-size-2xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--color-primary);
}

/* ===== Section Label ===== */
.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* ===== Password strength ===== */
.password-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  overflow: hidden;
}

.password-strength .bar {
  height: 100%;
  border-radius: 2px;
  transition: width var(--transition), background var(--transition);
}

/* ===== Blazor Error UI ===== */
#blazor-error-ui {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  bottom: 0;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
  display: none;
  left: 0;
  padding: 0.6rem 1.25rem;
  position: fixed;
  width: 100%;
  z-index: 2000;
  font-size: var(--font-size-sm);
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
}

.blazor-error-boundary {
  background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nNDgnIGhlaWdodD0nNDgnIHZpZXdCb3g9JzAgMCA0OCA0OCcgZmlsbD0nbm9uZScgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJz48cGF0aCBkPSdNMjQgNEMxMi45NSA0IDQgMTIuOTUgNCAyNHM4Ljk1IDIwIDIwIDIwIDIwLTguOTUgMjAtMjBTMzUuMDUgNCAyNCA0em0wIDM2Yy04LjgyIDAtMTYtNy4xOC0xNi0xNlMxNS4xOCA4IDI0IDhzMTYgNy4xOCAxNiAxNi03LjE4IDE2LTE2IDE2em0tMi0yMmg0djE0aC00VjE4em0wLThoNHY0aC00di00eicgZmlsbD0nd2hpdGUnLz48L3N2Zz4=) no-repeat 1rem/1.8rem, var(--color-danger);
  padding: 1rem 1rem 1rem 3.7rem;
  color: white;
  border-radius: var(--border-radius-lg);
}

.blazor-error-boundary::after {
  content: "An error has occurred.";
}
