/* =========================================================
   APP-LEVEL THEME TOKENS
   These are only for your app shell/layout, not Syncfusion controls.
   Syncfusion light/dark is handled by swapping its CSS file.
   ========================================================= */

:root {
  color-scheme: light;
  --app-bg: #f8fafc;
  --app-surface: #ffffff;
  --app-surface-2: #f1f5f9;
  --app-text: #0f172a;
  --app-text-muted: #475569;
  --app-border: #dbe3ee;
  --app-link: #2563eb;
  --app-link-hover: #1d4ed8;
  --app-sidebar-bg: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  --app-sidebar-text: #e2e8f0;
  --app-shadow: 0 1px 2px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
  --app-focus-ring: rgba(37, 99, 235, 0.35);
  --app-toggle-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

[data-theme="dark"] {
  color-scheme: dark;
  --app-bg: #0f172a;
  --app-surface: #111827;
  --app-surface-2: #1f2937;
  --app-text: #e5e7eb;
  --app-text-muted: #94a3b8;
  --app-border: #334155;
  --app-link: #60a5fa;
  --app-link-hover: #93c5fd;
  --app-sidebar-bg: linear-gradient(180deg, #020617 0%, #0f172a 100%);
  --app-sidebar-text: #e2e8f0;
  --app-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.28);
  --app-focus-ring: rgba(96, 165, 250, 0.4);
  --app-toggle-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

/* =========================================================
   BASE DOCUMENT STYLES
   ========================================================= */

html {
  font-size: 14px;
  min-height: 100%;
  background-color: var(--app-bg);
}

body {
  min-height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--app-bg);
  color: var(--app-text);
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
}

::selection {
  background: rgba(59, 130, 246, 0.22);
}

img,
svg {
  vertical-align: middle;
}

button,
input,
select,
textarea {
  font: inherit;
}

/* =========================================================
   TYPOGRAPHY
   Safe general typography only. No forced global recoloring.
   ========================================================= */

h1, h2, h3, h4, h5, h6 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: inherit;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.25rem;
}

h4 {
  font-size: 1.1rem;
}

h5 {
  font-size: 1rem;
}

h6 {
  font-size: 0.875rem;
}

p {
  margin-top: 0;
  margin-bottom: 1rem;
}
.page-header {
  /*border-color: gray;*/
  font-weight: 500;
  padding-bottom: 9px;
  margin: 40px 0 20px;
  border-bottom: 1px solid gray;
}
.page-header-close {
  font-weight: 500;
  padding-bottom: 0px;
  margin-bottom: 5px;
  margin-top: 0;
  padding-top: 0;
  border-bottom: 1px solid gray;
}
small,
.text-muted,
.app-text-muted {
  color: var(--app-text-muted);
}

a,
.btn-link {
  color: var(--app-link);
  text-decoration: none;
  transition: color 0.2s ease;
}

  a:hover,
  .btn-link:hover {
    color: var(--app-link-hover);
    text-decoration: underline;
  }

h1:focus {
  outline: none;
}

/* =========================================================
   LAYOUT
   ========================================================= */

html,
body,
#app {
  min-height: 100vh;
}

.page {
  min-height: 100vh;
  background-color: var(--app-bg);
  color: var(--app-text);
}

main {
  background-color: transparent;
  color: inherit;
}

.content {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  min-height: 100%;
  display: flow-root;
  box-sizing: border-box;
}

.app-shell {
  background-color: var(--app-bg);
  color: var(--app-text);
  min-height: 100vh;
}

.app-surface {
  background-color: var(--app-surface);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
  box-shadow: var(--app-shadow);
}

.app-surface-subtle {
  background-color: var(--app-surface-2);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
}

.app-section {
  padding: 1rem;
}

.app-page-header {
  margin-bottom: 1rem;
}

.app-page-title {
  margin-bottom: 0.25rem;
}

.app-page-subtitle {
  margin: 0;
  color: var(--app-text-muted);
}

.app-divider {
  border: 0;
  border-top: 1px solid var(--app-border);
  margin: 1rem 0;
}

/* =========================================================
   SIDEBAR / NAV SHELL
   These are safe if you use these classes in your own layout.
   ========================================================= */

.sidebar-shell {
  background: var(--app-sidebar-bg);
  color: var(--app-sidebar-text);
}

  .sidebar-shell a,
  .sidebar-shell .nav-link {
    color: var(--app-sidebar-text);
  }

    .sidebar-shell a:hover,
    .sidebar-shell .nav-link:hover {
      color: #ffffff;
      text-decoration: none;
    }

.top-row-shell {
  background-color: var(--app-surface);
  color: var(--app-text);
  border-bottom: 1px solid var(--app-border);
}

/* =========================================================
   GENERIC APP PANELS
   Use these for your own containers, not third-party controls.
   ========================================================= */

.app-card {
  background-color: var(--app-surface);
  color: var(--app-text);
  border: 1px solid var(--app-border);
  border-radius: 0.875rem;
  box-shadow: var(--app-shadow);
  margin-bottom: 1rem;
}

.app-card-header {
  padding: 0.875rem 1rem;
  background-color: var(--app-surface-2);
  border-bottom: 1px solid var(--app-border);
  border-top-left-radius: 0.875rem;
  border-top-right-radius: 0.875rem;
}

.app-card-body {
  padding: 1rem;
}

.app-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.app-card-footer {
  padding: 0.875rem 1rem;
  background-color: var(--app-surface-2);
  border-top: 1px solid var(--app-border);
  border-bottom-left-radius: 0.875rem;
  border-bottom-right-radius: 0.875rem;
}

/* =========================================================
   FORMS
   Keep this minimal and scoped to native inputs only.
   Do not attempt to recolor Syncfusion controls here.
   ========================================================= */

label,
.form-label {
  display: inline-block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: inherit;
}

input:not([type="checkbox"]):not([type="radio"]):not(.e-input),
select:not(.e-input):not(.e-dropdownlist),
textarea:not(.e-input) {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  background-color: var(--app-surface);
  color: var(--app-text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--app-text-muted);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--app-link);
  box-shadow: 0 0 0 0.2rem var(--app-focus-ring);
}

textarea {
  resize: vertical;
  min-height: 6rem;
}

/* =========================================================
   BUTTON HELPERS
   Only your custom/theme toggle buttons. Avoid overriding framework buttons.
   ========================================================= */

.app-button-reset {
  appearance: none;
  border: 0;
  background: none;
  color: inherit;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

/* =========================================================
   THEME TOGGLE
   ========================================================= */

.theme-toggle {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 1000;
  width: 3rem;
  height: 3rem;
  border: 1px solid var(--app-border);
  border-radius: 9999px;
  background-color: var(--app-surface);
  color: var(--app-text);
  box-shadow: var(--app-toggle-shadow);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

  .theme-toggle:hover {
    transform: translateY(-1px) scale(1.04);
  }

  .theme-toggle:focus-visible {
    outline: none;
    box-shadow: var(--app-toggle-shadow), 0 0 0 0.2rem var(--app-focus-ring);
  }

/* =========================================================
   TABLE HELPERS
   Only for YOUR custom/simple HTML tables when needed.
   Avoid targeting .e-grid / Syncfusion table internals.
   ========================================================= */

.app-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
  background-color: var(--app-surface);
  box-shadow: var(--app-shadow);
}

.app-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--app-text);
  background-color: var(--app-surface);
}

  .app-table th,
  .app-table td {
    padding: 0.75rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--app-border);
  }

  .app-table thead th {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background-color: var(--app-surface-2);
    color: var(--app-text-muted);
  }

  .app-table tbody tr:last-child td {
    border-bottom: 0;
  }

/* =========================================================
   BLazor VALIDATION
   Keep the built-in validation styles.
   ========================================================= */

.valid.modified:not([type="checkbox"]) {
  outline: 1px solid #26b050;
  outline-offset: 0;
}

.invalid {
  outline: 1px solid #e50000;
  outline-offset: 0;
}

.validation-message {
  color: #e50000;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* =========================================================
   ERROR BOUNDARY
   Keep the standard Blazor error UI usable in both themes.
   ========================================================= */

.blazor-error-boundary {
  background-color: #b32121;
  color: #ffffff;
  padding: 1rem 1rem 1rem 3.7rem;
  border-radius: 0.75rem;
  position: relative;
  margin: 1rem 0;
}

  .blazor-error-boundary::after {
    content: "An error has occurred.";
  }

  .blazor-error-boundary .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
    color: #ffffff;
  }

/* =========================================================
   CODE / PRE
   Based on your existing study-pre utility.
   ========================================================= */

pre,
code,
.study-pre {
  font-family: ui-monospace, SFMono-Regular, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.study-pre {
  max-width: 100%;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background-color: var(--app-surface-2);
  color: var(--app-text);
  border: 1px solid var(--app-border);
}

/* =========================================================
   UTILITIES
   ========================================================= */

.app-border {
  border: 1px solid var(--app-border);
}

.app-rounded {
  border-radius: 0.75rem;
}

.app-shadow {
  box-shadow: var(--app-shadow);
}

.app-bg {
  background-color: var(--app-bg);
}

.app-surface-bg {
  background-color: var(--app-surface);
}

.app-text {
  color: var(--app-text);
}

.app-text-muted {
  color: var(--app-text-muted);
}

/* =========================================================
   RESPONSIVE TWEAKS
   ========================================================= */

@media (max-width: 768px) {
  html {
    font-size: 13px;
  }

  .content {
    padding-top: 0.5rem;
  }

  .app-section,
  .app-card-body,
  .app-card-header,
  .app-card-footer {
    padding-left: 0.875rem;
    padding-right: 0.875rem;
  }

  .theme-toggle {
    right: 1rem;
    bottom: 1rem;
  }
}

/* =========================================================
   ADMIN NOTIFICATION BELL — popout (global, not scoped)
   ========================================================= */

.anb-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1049;
  background: transparent;
}

.anb-backdrop.anb-open {
  display: block;
}

.anb-popout {
  display: none;
  position: fixed;
  top: 48px;
  right: 1rem;
  width: 320px;
  max-height: 420px;
  flex-direction: column;
  z-index: 1050;
  border: 1px solid var(--app-border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--app-surface);
  color: var(--app-text);
  box-shadow: var(--app-shadow);
}

.anb-popout.anb-open {
  display: flex;
}

.anb-popout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
  flex-shrink: 0;
  background: var(--app-surface-2);
}

.anb-empty {
  padding: 1rem 0.75rem;
  text-align: center;
  color: var(--app-text-muted);
  font-size: 0.875rem;
}

.anb-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.anb-item {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--app-border);
  cursor: pointer;
  transition: background 0.12s;
}

  .anb-item:last-child {
    border-bottom: none;
  }

  .anb-item:hover {
    background: var(--app-surface-2);
  }

.anb-item-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.anb-author {
  font-weight: 600;
  font-size: 0.78rem;
}

.anb-time {
  font-size: 0.7rem;
  color: var(--app-text-muted);
  white-space: nowrap;
}

.anb-preview {
  font-size: 0.8rem;
  color: var(--app-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
