/**
 * HaxDB Main Stylesheet
 * Shared styles for the HaxDB application
 */

/* ==========================================================================
   CSS Variables / Design Tokens
   ========================================================================== */

:root {
  /* Background colors - darkest to lightest */
  --hax-bg-darkest: #0d0d0d;
  --hax-bg-darker: #151515;
  --hax-bg-dark: #1a1a1a;
  --hax-bg-card: #1e1e1e;
  --hax-bg-elevated: #252525;

  /* Border */
  --hax-border: #2d2d2d;

  /* Text */
  --hax-text: #e0e0e0;
  --hax-text-muted: #888;

  /* Accent colors */
  --hax-accent: #3b82f6;
  --hax-accent-hover: #2563eb;

  /* Status colors */
  --hax-success: #22c55e;
  --hax-danger: #ef4444;
  --hax-warning: #f59e0b;
  --hax-info: #3b82f6;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

body {
  background: var(--hax-bg-darkest);
  color: var(--hax-text);
}

a {
  color: var(--hax-accent);
}

a:hover {
  color: var(--hax-accent-hover);
}

hr {
  border-color: var(--hax-border);
  opacity: 1;
}

/* ==========================================================================
   Navbar
   ========================================================================== */

.navbar {
  background: var(--hax-bg-darker) !important;
  border-bottom: 1px solid var(--hax-border);
  z-index: 1030;
}

.navbar-brand {
  color: var(--hax-text) !important;
  font-weight: 600;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  background: var(--hax-bg-darker);
  border-right: 1px solid var(--hax-border);
}

.sidebar .nav-link {
  color: var(--hax-text-muted);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  margin: 0.125rem 0.5rem;
  transition: all 0.15s ease;
}

.sidebar .nav-link:hover {
  color: var(--hax-text);
  background: var(--hax-bg-elevated);
}

.sidebar .nav-link.active {
  color: #fff;
  background: var(--hax-accent);
}

.sidebar .nav-link i {
  width: 1.5rem;
}

/* Sidebar accordion sections */
.sidebar .sidebar-section {
  border-top: 1px solid var(--hax-border);
}

.sidebar .sidebar-section:first-child {
  border-top: none;
}

.sidebar .sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: transparent;
  border: none;
  color: var(--hax-text-muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s ease;
}

.sidebar .sidebar-toggle:hover {
  color: var(--hax-text);
}

.sidebar .sidebar-toggle i.toggle-icon {
  font-size: 0.6rem;
  transition: transform 0.2s ease;
}

.sidebar .sidebar-toggle.collapsed i.toggle-icon {
  transform: rotate(-90deg);
}

.sidebar .sidebar-content {
  padding-bottom: 0.5rem;
}

/* ==========================================================================
   Content Area
   ========================================================================== */

.content-wrapper {
  min-height: calc(100vh - 57px);
  background: var(--hax-bg-darkest);
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--hax-bg-card);
  border: 1px solid var(--hax-border);
  border-radius: 0.5rem;
}

.card-header {
  background: var(--hax-bg-elevated);
  border-bottom: 1px solid var(--hax-border);
}

.card.border-success {
  border-color: var(--hax-success) !important;
}

.card.border-secondary {
  border-color: var(--hax-border) !important;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--hax-text);
  --bs-table-border-color: var(--hax-border);
}

.table-light {
  --bs-table-bg: var(--hax-bg-elevated);
  --bs-table-color: var(--hax-text);
}

.table-hover > tbody > tr:hover {
  --bs-table-hover-bg: var(--hax-bg-elevated);
  --bs-table-hover-color: var(--hax-text);
}

/* Table dropdowns - allow overflow for action menus */
.table-responsive {
  overflow: visible !important;
}

.table-responsive .dropdown-menu {
  position: absolute;
  z-index: 1050;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-control,
.form-select {
  background: var(--hax-bg-dark);
  border-color: var(--hax-border);
  color: var(--hax-text);
}

.form-control:focus,
.form-select:focus {
  background: var(--hax-bg-dark);
  border-color: var(--hax-accent);
  color: var(--hax-text);
  box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.form-control::placeholder {
  color: var(--hax-text-muted);
}

.form-label {
  color: var(--hax-text);
}

.form-check-input {
  background-color: var(--hax-bg-dark);
  border-color: var(--hax-border);
}

.form-check-input:checked {
  background-color: var(--hax-accent);
  border-color: var(--hax-accent);
}

.input-group-text {
  background: var(--hax-bg-elevated);
  border-color: var(--hax-border);
  color: var(--hax-text-muted);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn-primary {
  background: var(--hax-accent);
  border-color: var(--hax-accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--hax-accent-hover);
  border-color: var(--hax-accent-hover);
  color: #fff;
}

.btn-outline-primary {
  color: var(--hax-accent);
  border-color: var(--hax-accent);
}

.btn-outline-primary:hover {
  background: var(--hax-accent);
  border-color: var(--hax-accent);
  color: #fff;
}

.btn-outline-secondary {
  color: var(--hax-text-muted);
  border-color: var(--hax-border);
}

.btn-outline-secondary:hover {
  background: var(--hax-bg-elevated);
  border-color: var(--hax-border);
  color: var(--hax-text);
}

.btn-outline-danger {
  color: var(--hax-danger);
  border-color: var(--hax-danger);
}

.btn-outline-danger:hover {
  background: var(--hax-danger);
  border-color: var(--hax-danger);
  color: #fff;
}

.btn-outline-dark {
  color: var(--hax-text);
  border-color: var(--hax-border);
  background: transparent;
}

.btn-outline-dark:hover {
  background: var(--hax-bg-elevated);
  border-color: var(--hax-text-muted);
  color: #fff;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert-success {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--hax-success);
}

.alert-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--hax-danger);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--hax-warning);
}

.alert-info {
  background: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--hax-accent);
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge.bg-primary {
  background: var(--hax-accent) !important;
}

.badge.bg-success {
  background: var(--hax-success) !important;
}

.badge.bg-danger {
  background: var(--hax-danger) !important;
}

.badge.bg-warning {
  background: var(--hax-warning) !important;
  color: #000;
}

.badge.bg-secondary {
  background: var(--hax-bg-elevated) !important;
  color: var(--hax-text-muted);
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.nav-tabs {
  border-bottom-color: var(--hax-border);
}

.nav-tabs .nav-link {
  color: var(--hax-text-muted);
  border: 1px solid transparent;
}

.nav-tabs .nav-link:hover {
  color: var(--hax-text);
  border-color: var(--hax-border) var(--hax-border) transparent;
}

.nav-tabs .nav-link.active {
  background: var(--hax-bg-card);
  border-color: var(--hax-border) var(--hax-border) var(--hax-bg-card);
  color: var(--hax-text);
}

/* ==========================================================================
   Dropdowns
   ========================================================================== */

.dropdown-menu {
  background: var(--hax-bg-card);
  border-color: var(--hax-border);
}

.dropdown-item {
  color: var(--hax-text);
}

.dropdown-item:hover {
  background: var(--hax-bg-elevated);
  color: var(--hax-text);
}

.dropdown-divider {
  border-color: var(--hax-border);
}

/* ==========================================================================
   Text Utilities
   ========================================================================== */

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

/* ==========================================================================
   Mobile Navigation
   ========================================================================== */

.mobile-nav {
  background: var(--hax-bg-darker);
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.mobile-nav .nav-link {
  color: var(--hax-text-muted);
  padding: 0.75rem 1rem;
}

.mobile-nav .nav-link:hover {
  color: var(--hax-text);
  background: var(--hax-bg-elevated);
}

.mobile-nav .nav-link.active {
  color: #fff;
  background: var(--hax-accent);
}

.mobile-nav .nav-link i {
  width: 1.5rem;
}

.mobile-nav .nav-divider {
  border-top: 1px solid var(--hax-border);
  margin: 0.5rem 0;
}

@media (min-width: 768px) {
  .mobile-nav {
    display: none !important;
  }
}

/* Body scroll lock when mobile menu is open */
body.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Logo sizing */
.logo-sm {
  max-height: 32px;
  max-width: 150px;
}

.logo-md {
  max-height: 48px;
  max-width: 200px;
}

.logo-lg {
  max-height: 60px;
  max-width: 250px;
}

/* Nav section labels */
.nav-section-label {
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 700;
}

/* Icon sizing */
.icon-sm {
  font-size: 1rem;
}

.icon-md {
  font-size: 1.5rem;
}

.icon-lg {
  font-size: 2rem;
}

.icon-xl {
  font-size: 3rem;
}

.icon-2xl {
  font-size: 4rem;
}

/* Aspect ratio containers */
.aspect-ratio-1-1 {
  position: relative;
  padding-top: 100%;
}

.aspect-ratio-16-9 {
  position: relative;
  padding-top: 56.25%;
}

.aspect-ratio-4-3 {
  position: relative;
  padding-top: 75%;
}

.aspect-ratio-3-2 {
  position: relative;
  padding-top: 66.67%;
}

.aspect-ratio-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Image cover utility */
.img-cover {
  object-fit: cover;
}

/* Thumbnail sizes */
.thumbnail-sm {
  width: 50px;
  height: 30px;
  object-fit: cover;
}

.thumbnail-md {
  width: 80px;
  height: 80px;
  object-fit: cover;
}

.thumbnail-lg {
  width: 150px;
  height: 150px;
  object-fit: cover;
}

/* Login card */
.login-card {
  max-width: 400px;
  margin: 2rem auto;
}

/* Modals */
.modal-content {
  background: var(--hax-bg-card);
  border-color: var(--hax-border);
}

.modal-header {
  border-bottom-color: var(--hax-border);
}

.modal-footer {
  border-top-color: var(--hax-border);
}

/* List groups */
.list-group-item {
  background: var(--hax-bg-card);
  border-color: var(--hax-border);
  color: var(--hax-text);
}

.list-group-item:hover {
  background: var(--hax-bg-elevated);
}

/* Pagination */
.page-link {
  background: var(--hax-bg-card);
  border-color: var(--hax-border);
  color: var(--hax-text);
}

.page-link:hover {
  background: var(--hax-bg-elevated);
  border-color: var(--hax-border);
  color: var(--hax-text);
}

.page-item.active .page-link {
  background: var(--hax-accent);
  border-color: var(--hax-accent);
}

.page-item.disabled .page-link {
  background: var(--hax-bg-dark);
  border-color: var(--hax-border);
  color: var(--hax-text-muted);
}

/* Breadcrumbs */
.breadcrumb {
  --bs-breadcrumb-divider: '\203A';
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 0.15rem;
  margin-bottom: 0;
  font-size: 1.5rem;
  line-height: 1.3;
}

@media (max-width: 575.98px) {
  .breadcrumb {
    font-size: 1.25rem;
  }
}

.breadcrumb-item + .breadcrumb-item::before {
  color: var(--hax-text-muted);
}

.breadcrumb-item a {
  color: var(--hax-accent);
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb-item a:hover {
  color: var(--hax-accent-hover);
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: var(--hax-text);
  font-weight: 600;
}

/* flash a field that was filled in for the user */
@keyframes hax-autofill-flash {
  from {
    background-color: var(--hax-accent);
    border-color: var(--hax-accent);
  }
  to {
    background-color: var(--hax-bg-dark);
    border-color: var(--hax-border);
  }
}

.form-control.hax-autofilled {
  animation: hax-autofill-flash 0.9s ease-out;
}

/* Ticket details: a two-column definition grid with banded rows.
   dt and dd of one pair are consecutive, so nth-of-type(odd) bands both
   halves of the same row -- and still does once they stack on narrow. */
.hax-details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  border: 1px solid var(--hax-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.hax-details > dt,
.hax-details > dd {
  margin: 0;
  padding: 0.625rem 1rem;
  min-width: 0;
}

.hax-details > dt {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hax-text-muted);
  white-space: nowrap;
  /* sits level with the first line of a value that wraps */
  padding-top: 0.75rem;
}

.hax-details > dd {
  color: var(--hax-text);
  overflow-wrap: anywhere;
}

.hax-details > dt:nth-of-type(odd),
.hax-details > dd:nth-of-type(odd) {
  background: var(--hax-bg-elevated);
}

@media (max-width: 575.98px) {
  .hax-details {
    grid-template-columns: minmax(0, 1fr);
  }

  .hax-details > dt {
    padding-bottom: 0.125rem;
    white-space: normal;
  }

  .hax-details > dd {
    padding-top: 0;
  }
}

/* Notification previews are whole email documents, which are cramped at
   modal-xl. modal-xl stays on the element as the fallback width. */
.modal-dialog.hax-modal-wide {
  --bs-modal-width: min(1600px, 94vw);
}

/* Ticket facts in the sidebar: one per line, separated by a rule rather than
   laid out in columns. */
.hax-stack .hax-fact + .hax-fact {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--hax-border);
}

.hax-stack dt {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hax-text-muted);
  margin-bottom: 0.25rem;
}

.hax-stack dd {
  margin: 0;
  color: var(--hax-text);
  overflow-wrap: anywhere;
}

/* The ticket's own words, sat at the top so the page opens with context. */
.hax-ticket-subject {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--hax-text);
}

.hax-ticket-description {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--hax-text);
}

/* Photos on an oops ticket. */
.oops-photos {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: 1rem;
}
.oops-photos img {
  width: 140px;
  height: 140px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--bs-border-color, #dee2e6);
}
.oops-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  background: rgba(0, 0, 0, .92);
}
.oops-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.oops-lightbox-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + .75rem);
  right: calc(env(safe-area-inset-right, 0px) + .75rem);
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .15);
  color: #fff;
  font-size: 1.75rem;
}
.oops-lightbox-close:hover,
.oops-lightbox-close:focus-visible {
  background: rgba(255, 255, 255, .3);
}
body.oops-lightbox-open {
  overflow: hidden;
}
.oops-activity .oops-photos {
  margin-top: .5rem;
}
.oops-activity .oops-photos img {
  width: 96px;
  height: 96px;
}
