/* ========== ROOT VARIABLES (CCR-DERIVED PALETTE) ========== */
:root {
  /* Core CCR brand anchor */
  --color-brand-red: #e53935;
  --color-brand-red-soft: #ff6b6b;
  --color-brand-red-dark: #b71c1c;

  /* Fresh complementary accents (still available but used sparingly) */
  --color-accent-teal: #06b6d4;
  --color-accent-teal-soft: #a5f3fc;
  --color-accent-green: #22c55e;
  --color-accent-green-soft: #dcfce7;

  /* --color-accent-purple: #8b5cf6;       
  --color-accent-purple-dark: #6d28d9;   
  --color-accent-purple-soft: #ede9fe;  */
  --color-accent-purple: #7c6f91;        /* muted grape/mauve */
  --color-accent-purple-dark: #5e5470;   /* deeper dusty plum */
  --color-accent-purple-soft: #f3eef9;   /* pale lavender-gray */
  --color-accent-mauve: #9b6b82;         /* soft warm mauve */
  --color-accent-mauve-dark: #7c5367;    /* deeper warm plum */
  --color-accent-mauve-soft: #f7eef2;    /* very pale mauve blush */

  /* Neutrals */
  --color-black-soft: #111827;
  --color-white: #ffffff;
  --color-gray-50: #f8fafc;
  --color-gray-100: #eef2ff;
  --color-gray-200: #e5e7eb;
  --color-gray-400: #9ca3af;
  --color-gray-600: #6b7280;
  --color-gray-800: #1f2933;

  /* Deep sidebar tones */
  --color-bg-sidebar-deep-1: #0b1120;
  --color-bg-sidebar-deep-2: #020617;

  /* Semantic */
  --color-success: #16a34a;
  --color-danger: #dc2626;

  /* Layout / components */
  --bg-main: var(--color-gray-50);
  --bg-navbar: var(--color-white);
  --bg-card: var(--color-white);
  --text-main: var(--color-black-soft);
  --text-muted: var(--color-gray-600);
  --text-on-dark: var(--color-white);

  --border-soft: rgba(148, 163, 184, 0.4);
  --border-strong: var(--color-gray-800);

  --accent-primary: var(--color-brand-red);
  --accent-primary-soft: var(--color-brand-red-soft);
  --accent-primary-dark: var(--color-brand-red-dark);

  --accent-secondary: var(--color-accent-purple);
  --accent-secondary-dark: var(--color-accent-purple-dark);
  --accent-secondary-soft: var(--color-accent-purple-soft);

  --shadow-soft: 0 10px 25px rgba(15, 23, 42, 0.08);
}

/* ========== GLOBAL ========== */

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(
    circle at top,
    rgba(229, 57, 53, 0.08) 0%,
    var(--bg-main) 40%,
    rgba(229, 57, 53, 0.04) 100%
  );
  color: var(--text-main);
  margin: 0;
}

a,
button {
  text-decoration: none;
}

/* ========== APP WRAPPER ========== */

.app-wrapper {
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}


/* ========== SIDEBAR ========== */

.sidebar {
  width: 240px;
  background: radial-gradient(
    circle at top left,
    var(--color-bg-sidebar-deep-1),
    var(--color-bg-sidebar-deep-2)
  );
  color: var(--text-on-dark);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 4px 0 20px rgba(15, 23, 42, 0.35);
}

.sidebar .brand {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.35);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar .brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: var(--accent-primary);
  box-shadow: 0 0 0 2px rgba(248, 250, 252, 0.08);
}

.sidebar .brand-title {
  font-size: 1.05rem;
  line-height: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #FFFFFF;
}

/* Sidebar nav */

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-section-title {
  padding: 0.75rem 1.5rem 0.3rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav .nav-link {
  border-radius: 0; /* no pill shape */
  margin-right: 0;
  padding: 0.55rem 1.4rem;
  font-size: 0.93rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(249, 250, 251, 0.9);
  opacity: 0.85;
  transition: background 0.18s ease-out, transform 0.18s ease-out, opacity 0.18s;
}

.sidebar-nav .nav-link .nav-icon {
  font-size: 1.1rem;
}

.sidebar-nav .nav-link:hover {
  background: rgba(229, 57, 53, 0.22);
  opacity: 1;
  transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
  background: var(--accent-primary);
  color: var(--color-white);
  opacity: 1;
  box-shadow: none;
}

/* Sidebar footer */

.sidebar-footer {
  padding: 0.75rem 1.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.75);
}

/* ========== MAIN PANEL & TOP NAVBAR ========== */

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-navbar {
  height: 64px;
  background: var(--bg-navbar);
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.top-navbar .search-box {
  max-width: 320px;
  width: 100%;
}

.top-navbar input.form-control {
  font-size: 0.9rem;
  border-color: var(--border-soft);
}

.top-navbar .nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.top-navbar .avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--color-gray-200);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-gray-800);
}

/* ========== HERO STRIPE ========== */

.hero-stripe {
  background: var(--accent-primary); /* solid CCR red */
  color: var(--color-white);
  padding: 1rem 1.5rem;
  border-bottom: none;
}

.hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hero-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-white);
}

.hero-subtitle {
  margin: 0.1rem 0 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
}

.hero-actions .btn {
  font-size: 0.8rem;
}

/* ========== CONTENT ========== */

.content-wrapper {
  padding: 1.5rem;
  flex: 1;
  min-height: 0;
}

.page-header h2 {
  font-size: 1.2rem;
}

.page-header .subtitle {
  font-size: 0.9rem;
}

/* ========== CARDS & KPI ========== */

.card {
  background-color: var(--bg-card);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: var(--shadow-soft);
  border-radius: 0.9rem;
}

.card-header {
  border-bottom-color: rgba(148, 163, 184, 0.25);
  font-weight: 600;
}

/* KPI card */

.kpi-card .card-body {
  padding: 1rem 1.1rem;
}

.kpi-card .label {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.kpi-card .value {
  font-size: 1.5rem;
  font-weight: 600;
}

.kpi-card .trend-up {
  color: var(--color-success);
  font-size: 0.85rem;
}

.kpi-card .trend-down {
  color: var(--color-danger);
  font-size: 0.85rem;
}

.kpi-card .kpi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background-color: rgba(229, 57, 53, 0.08);
  color: var(--accent-primary);
}

/* Badges / chips */

.badge-soft-red {
  background-color: rgba(229, 57, 53, 0.1);
  color: var(--accent-primary);
}

.badge-soft-secondary {
  background-color: var(--accent-secondary-soft);
  color: var(--accent-secondary);
}

.badge-soft-teal {
  background-color: rgba(6, 182, 212, 0.12);
  color: var(--color-accent-teal);
}

/* ========== TABLES (CCR THEMED) ========== */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text-main);
  --bs-table-border-color: rgba(148, 163, 184, 0.35);
  --bs-table-striped-bg: rgba(148, 163, 184, 0.06);
  --bs-table-striped-color: var(--text-main);
  --bs-table-hover-bg: rgba(229, 57, 53, 0.04);
  --bs-table-hover-color: var(--text-main);

  font-size: 0.9rem;
  margin-bottom: 0;
  border-color: var(--bs-table-border-color);
}

.table > :not(caption) > * > * {
  padding: 0.6rem 0.75rem;
  vertical-align: middle;
}

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom-width: 1px;
  border-color: var(--bs-table-border-color);
  background-color: rgba(229, 57, 53, 0.04);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: var(--bs-table-striped-bg);
}

.table-hover > tbody > tr:hover > * {
  background-color: var(--bs-table-hover-bg);
}

.table .status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.table .status-pill--open {
  background-color: rgba(6, 182, 212, 0.12);
  color: var(--accent-secondary);
}

.table .status-pill--closed {
  background-color: rgba(229, 57, 53, 0.1);
  color: var(--accent-primary);
}

.table .status-pill--pending {
  background-color: rgba(234, 179, 8, 0.14);
  color: #a16207;
}

/* Title toggle: no underline, wraps nicely */
.update-row-toggle {
  color: inherit;
  text-decoration: none;
  white-space: normal;
  line-height: 1.3;
}

.update-row-toggle:hover {
  text-decoration: none; /* keep it clean on hover */
}

/* Allow title text to wrap instead of stretching table */
.update-row-toggle span,
.update-row-toggle small {
  white-space: normal;
  word-wrap: break-word;
}

/* Chevron rotation */
.chevron-icon {
  font-size: 0.85rem;
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0.7;
}

.update-row-toggle[aria-expanded='true'] .chevron-icon {
  transform: rotate(180deg);
  opacity: 1;
}


/* ========== COMPACT TABLES (DENSE VIEW) ========== */

.table-compact > :not(caption) > * > * {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  font-size: 0.8rem;
}

.table-compact thead th {
  font-size: 0.7rem;
}

/* Subtle separation for dense card tables */
.table-compact tbody tr + tr td {
  border-top: 1px solid rgba(148, 163, 184, 0.25);
}

/* ========== BUTTONS ========== */

.btn-primary {
  background-color: var(--accent-primary);
  border: none;
  color: var(--color-white);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--accent-primary-dark);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.btn-outline-secondary {
  color: var(--color-gray-800);
  border-color: rgba(148, 163, 184, 0.8);
  background-color: transparent;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background-color: rgba(229, 57, 53, 0.06);
  border-color: var(--accent-primary);
}

/* Notification badge inherits CCR red */
.btn .badge.bg-danger {
  background-color: var(--accent-primary);
}

/* Dropdown menu */

.dropdown-menu {
  border-radius: 0.5rem;
  border-color: var(--border-soft);
  box-shadow: var(--shadow-soft);
}

/* ========== CRISPY FORMS / FORM LAYOUT ========== */

.card form {
  font-size: 0.9rem;
}

/* Labels */
.form-label,
.control-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-main);
}

/* Help text / hints */
.form-text,
.help-block {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Required marker */
.asteriskField {
  color: var(--accent-primary);
  margin-left: 0.15rem;
}

/* Inputs, selects, textareas */
.form-control,
.form-select {
  border-radius: 0.55rem;
  border-color: rgba(148, 163, 184, 0.7);
  background-color: var(--color-white);
  font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 0.15rem rgba(229, 57, 53, 0.25);
}

/* Checkbox & radio labels */
.form-check-label {
  font-size: 0.9rem;
  color: var(--text-main);
}

/* Field spacing */
.form-group,
.mb-3 {
  margin-bottom: 0.9rem !important;
}

/* Validation states */
.is-invalid {
  border-color: var(--color-danger) !important;
}

.is-valid {
  border-color: var(--color-success) !important;
}

.invalid-feedback,
.help-block.invalid-feedback {
  font-size: 0.75rem;
  color: var(--color-danger);
}

.valid-feedback {
  font-size: 0.75rem;
  color: var(--color-success);
}

/* Form actions row */
.form-actions,
.form-group.form-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}

/* Inline field icons (optional utility) */
.input-with-icon {
  position: relative;
}

.input-with-icon .form-control {
  padding-left: 2rem;
}

.input-with-icon .form-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ========== ALERTS / DJANGO MESSAGES ========== */

.alert {
  border-radius: 0.65rem;
  border-width: 1px;
  font-size: 0.85rem;
}

.alert-info {
  background-color: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.3);
  color: var(--accent-secondary);
}

.alert-success {
  background-color: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.3);
  color: var(--color-success);
}

.alert-warning {
  background-color: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.3);
  color: #92400e;
}

.alert-danger,
.alert-error {
  background-color: rgba(229, 57, 53, 0.08);
  border-color: rgba(229, 57, 53, 0.3);
  color: var(--accent-primary-dark);
}

/* ========== RESPONSIVE: SIDEBAR TOGGLE ========== */

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease-out;
  }

  .sidebar.show {
    transform: translateX(0);
  }
}

/* ========== UTILITIES ========== */

.text-muted-ccr {
  color: var(--text-muted) !important;
}

.text-ccr-red {
  color: var(--accent-primary) !important;
}

.bg-ccr-red {
  background-color: var(--accent-primary) !important;
  color: var(--color-white) !important;
}
