/* theme-vars.css — Theme variable definitions */
/* This file is imported BEFORE tailwind so variables are available */

/* Light mode (default) */
:root {
  --bg-base: #f4f4f5;
  --bg-chrome: #ebebed;
  --bg-raised: #ebebed;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f4f4f5;
  --bg-overlay: #f9f9fa;
  --bg-inset: #e4e4e7;

  --border-default: #e4e4e7;
  --border-subtle: #f4f4f5;

  --text-primary: #09090b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  --text-inverse: #ffffff;

  --input-bg: #ffffff;
  --input-border: #d4d4d8;
  --input-text: #18181b;
  --input-placeholder: #a1a1aa;

  --success: #059669;
  --success-bg: rgba(5, 150, 105, 0.08);
  --success-border: rgba(5, 150, 105, 0.2);
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.06);
  --danger-border: rgba(220, 38, 38, 0.15);

  --shadow-color: rgba(0, 0, 0, 0.08);

  /* Default accent (emerald) — overridden by JS */
  --accent: #10b981;
  --accent-hover: #059669;
  --accent-subtle: rgba(16, 185, 129, 0.12);
  --accent-text: #ffffff;

  --selected: #f43f5e;
  --selected-subtle: rgba(244, 63, 94, 0.12);

  /* Layout */
  --topnav-height: 62px;
}

/* Dark mode */
.dark {
  --bg-base: #09090b;
  --bg-chrome: #111113;
  --bg-raised: #1e1e22;
  --bg-surface: #27272a;
  --bg-surface-hover: #323235;
  --bg-overlay: #111113;
  --bg-inset: #1a1a1e;

  --border-default: #323235;
  --border-subtle: #232327;

  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --text-inverse: #ffffff;

  --input-bg: #18181b;
  --input-border: #3f3f46;
  --input-text: #e4e4e7;
  --input-placeholder: #52525b;

  --success: #34d399;
  --success-bg: rgba(52, 211, 153, 0.12);
  --success-border: rgba(52, 211, 153, 0.2);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.1);
  --danger-border: rgba(248, 113, 113, 0.2);

  --shadow-color: rgba(0, 0, 0, 0.4);

  /* Smooth scrollbar for dark mode */
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: var(--bg-raised);
  }

  ::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: 4px;

    &:hover {
      background: #3f3f46;
    }
  }
}

/* ===== Base Styles ===== */
html {
  color-scheme: light;

  &.dark {
    color-scheme: dark;
  }
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ===== Theme utility classes ===== */
/* These exist because Tailwind v4 @theme inline var() references */
/* don't generate working utility classes for bg/border/text colors. */

/* Backgrounds */
.theme-bg-base { background-color: var(--bg-base); }
.theme-bg-chrome { background-color: var(--bg-chrome); }
.theme-bg-raised { background-color: var(--bg-raised); }
.theme-bg-surface { background-color: var(--bg-surface); }
.theme-bg-overlay { background-color: var(--bg-overlay); }
.theme-bg-inset { background-color: var(--bg-inset); }

/* Hover backgrounds */
.theme-hover-raised:hover { background-color: var(--bg-raised); }
.theme-hover-surface:hover { background-color: var(--bg-surface-hover); }

/* Text */
.theme-text-primary { color: var(--text-primary); }
.theme-text-secondary { color: var(--text-secondary); }
.theme-text-tertiary { color: var(--text-tertiary); }
.theme-text-accent { color: var(--accent); }

/* Hover text */
.theme-hover-text-primary:hover { color: var(--text-primary); }

/* Borders */
.theme-border { border-color: var(--border-default); }
.theme-border-subtle { border-color: var(--border-subtle); }

/* Selected state */
.theme-text-selected { color: var(--selected); }
.theme-bg-selected-subtle { background-color: var(--selected-subtle); }

/* ===== Popup / Modal utilities ===== */

/* Full-screen modal overlay (backdrop) */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
}

/* Modal card (centered content panel) */
.modal-card {
  background-color: var(--bg-surface);
  border-radius: 1rem;
  box-shadow: 0 12px 40px var(--shadow-color);
  overflow: hidden;
  width: 100%;
}

/* In-place dropdown popup (menus, pickers) — rendered via React Portal */
.dropdown-popup {
  position: fixed;
  background-color: var(--bg-surface);
  border-radius: 0.75rem;
  box-shadow: 0 8px 30px var(--shadow-color);
  z-index: 9999;
  overflow: hidden;
}

/* ===== Shared sidebar layout ===== */
/* Centralized left-menu styling used across Status, Wiki, and other pages. */

.sidebar-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar-panel {
  width: 260px;
  min-width: 260px;
  background: var(--bg-chrome);
  border-right: 1px solid var(--border-subtle);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--topnav-height);
  max-height: calc(100vh - var(--topnav-height));
  overflow-y: auto;
}

.sidebar-header {
  padding: 0 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;

  &:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
  }

  &.active {
    color: var(--accent);
    background: var(--accent-subtle);
    border-left-color: var(--accent);

    i,
    .sidebar-link-icon {
      color: var(--accent);
    }
  }

  i,
  .sidebar-link-icon {
    width: 1.25rem;
    text-align: center;
    font-size: 0.95rem;
  }
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
}

.sidebar-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.5rem 1.25rem;
}

.sidebar-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  min-height: 0;
  position: relative;
  background-color: var(--bg-base);
}

/* ===== Standard page content width ===== */
/* Use on full-width pages (no sidebar) to keep content centered and readable. */
/* Industry standard max-width for dashboard/admin content. */

.page-content {
  max-width: 1200px;
  width: 100%;
  flex: 1;
  margin: 0 auto;
  padding: 1.5rem 2rem;
  background-color: var(--bg-base);
}


/* Container for aligning content inside sidebar-content without adding its own padding/scroll */
.sidebar-page-content {
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 640px) {
  .sidebar-layout {
    flex-direction: column;
  }

  .sidebar-panel {
    width: 100%;
    min-width: auto;
    max-height: 200px;
  }

  .sidebar-content {
    padding: 1.5rem 1.25rem;
  }

  .page-content {
    padding: 1rem;
  }
}

/* ===== Global Table Styles ===== */
/* Use .theme-table on <table> elements instead of page-specific classes. */
.theme-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;

  th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-overlay);
    white-space: nowrap;
  }

  td {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
  }

  tbody tr {
    transition: background 0.15s ease;

    &:hover:not(.no-hover) {
      background: var(--bg-surface-hover);
    }

    &:last-child td {
      border-bottom: none;
    }
  }
}

/* ===== Global Card Styles ===== */
/* Use .theme-card for standard content boxes, metric cards, role cards, etc. */
.theme-card {
  background: var(--bg-surface);
  border-radius: 0.75rem;
  padding: 1.25rem;
  box-shadow: 0 2px 12px var(--shadow-color, rgba(0,0,0,0.05));
  border: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

/* Optional hover effect for interactive cards */
.theme-hover-card:hover {
  background: var(--bg-surface-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--shadow-color, rgba(0,0,0,0.08));
  border-color: var(--border-default);
}
