/*
 * Ticket System - Bootstrap 5 Custom Overrides
 */

/* === Status Badges === */
.badge-status-open { background-color: #dbeafe; color: #1e40af; }
.badge-status-in_progress { background-color: #fef3c7; color: #92400e; }
.badge-status-resolved { background-color: #d1fae5; color: #065f46; }
.badge-status-closed { background-color: #e5e7eb; color: #374151; }

/* === Priority Badges === */
.badge-priority-critical { background-color: #fee2e2; color: #991b1b; }
.badge-priority-high { background-color: #ffedd5; color: #9a3412; }
.badge-priority-medium { background-color: #fef3c7; color: #92400e; }
.badge-priority-low { background-color: #e5e7eb; color: #374151; }

/* === Sync Status Badges === */
.badge-sync-never { background-color: #e5e7eb; color: #374151; }
.badge-sync-syncing { background-color: #dbeafe; color: #1e40af; }
.badge-sync-synced { background-color: #d1fae5; color: #065f46; }
.badge-sync-failed { background-color: #fee2e2; color: #991b1b; }
.badge-sync-idle { background-color: #d1fae5; color: #065f46; }
.badge-sync-error { background-color: #fee2e2; color: #991b1b; }

/* === AI Review Status Badges === */
.badge-ai-pending { background-color: #e5e7eb; color: #374151; }
.badge-ai-analyzing { background-color: #dbeafe; color: #1e40af; }
.badge-ai-completed { background-color: #d1fae5; color: #065f46; }
.badge-ai-failed { background-color: #fee2e2; color: #991b1b; }

/* === Dark Mode Badge Variants === */
[data-bs-theme="dark"] .badge-status-open { background-color: #1e3a5f; color: #93c5fd; }
[data-bs-theme="dark"] .badge-status-in_progress { background-color: #4a3728; color: #fde68a; }
[data-bs-theme="dark"] .badge-status-resolved { background-color: #14432a; color: #6ee7b7; }
[data-bs-theme="dark"] .badge-status-closed { background-color: #374151; color: #9ca3af; }

[data-bs-theme="dark"] .badge-priority-critical { background-color: #4a1c1c; color: #fca5a5; }
[data-bs-theme="dark"] .badge-priority-high { background-color: #4a2c1a; color: #fdba74; }
[data-bs-theme="dark"] .badge-priority-medium { background-color: #4a3728; color: #fde68a; }
[data-bs-theme="dark"] .badge-priority-low { background-color: #374151; color: #9ca3af; }

[data-bs-theme="dark"] .badge-sync-never { background-color: #374151; color: #9ca3af; }
[data-bs-theme="dark"] .badge-sync-syncing { background-color: #1e3a5f; color: #93c5fd; }
[data-bs-theme="dark"] .badge-sync-synced,
[data-bs-theme="dark"] .badge-sync-idle { background-color: #14432a; color: #6ee7b7; }
[data-bs-theme="dark"] .badge-sync-failed,
[data-bs-theme="dark"] .badge-sync-error { background-color: #4a1c1c; color: #fca5a5; }

[data-bs-theme="dark"] .badge-ai-pending { background-color: #374151; color: #9ca3af; }
[data-bs-theme="dark"] .badge-ai-analyzing { background-color: #1e3a5f; color: #93c5fd; }
[data-bs-theme="dark"] .badge-ai-completed { background-color: #14432a; color: #6ee7b7; }
[data-bs-theme="dark"] .badge-ai-failed { background-color: #4a1c1c; color: #fca5a5; }

/* === Export Status Badges === */
.badge-export-pending { background-color: #e5e7eb; color: #374151; }
.badge-export-processing { background-color: #dbeafe; color: #1e40af; }
.badge-export-completed { background-color: #d1fae5; color: #065f46; }
.badge-export-failed { background-color: #fee2e2; color: #991b1b; }

[data-bs-theme="dark"] .badge-export-pending { background-color: #374151; color: #9ca3af; }
[data-bs-theme="dark"] .badge-export-processing { background-color: #1e3a5f; color: #93c5fd; }
[data-bs-theme="dark"] .badge-export-completed { background-color: #14432a; color: #6ee7b7; }
[data-bs-theme="dark"] .badge-export-failed { background-color: #4a1c1c; color: #fca5a5; }

/* === Bulk Select Bar === */
.bulk-select-bar {
  position: sticky;
  bottom: 0;
  background-color: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  padding: 0.75rem 1rem;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

/* === Label Badges === */
.label-badge {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 12px;
  color: #fff;
  white-space: nowrap;
}

/* === AI Review Summary Callout === */
.ai-review-summary {
  background-color: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.ai-review-summary h4 {
  margin: 0 0 0.25rem;
  color: #166534;
}

[data-bs-theme="dark"] .ai-review-summary {
  background-color: #14432a;
  border-color: #166534;
}

[data-bs-theme="dark"] .ai-review-summary h4 {
  color: #6ee7b7;
}

/* === Card Hover Transitions === */
.card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-hover:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .card-hover:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* === Flash Animation === */
@keyframes flash-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert[role="alert"] {
  animation: flash-in 0.3s ease;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
}

.empty-state .bi {
  font-size: 2.5rem;
  opacity: 0.4;
  display: block;
  margin-bottom: 0.75rem;
}

/* === Turbo Progress Bar === */
.turbo-progress-bar {
  background-color: #3b82f6;
}

/* === Stat Cards === */
.stat-card {
  text-align: center;
  color: inherit;
  transition: box-shadow 0.15s ease-in-out;
}

a.stat-card:hover {
  box-shadow: 0 .25rem .5rem rgba(0,0,0,.1);
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card-highlight {
  border-color: #3b82f6 !important;
}

.stat-card-highlight .stat-value {
  color: #3b82f6;
}

[data-bs-theme="dark"] .stat-card-highlight {
  border-color: #60a5fa !important;
}

[data-bs-theme="dark"] .stat-card-highlight .stat-value {
  color: #60a5fa;
}

/* === External Link Arrow === */
.external-link::after {
  content: " \2197";
  font-size: 0.8em;
}

/* === Auth Pages === */
.auth-card {
  max-width: 420px;
  margin: 3rem auto;
}

/* === Metadata Grid === */
.metadata-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* === Form Color Input === */
.form-control-color {
  width: 50px;
  height: 38px;
  padding: 2px;
}

/* === Clickable Table Rows === */
.cursor-pointer {
  cursor: pointer;
}

.table-hover tr.cursor-pointer:hover td {
  background-color: rgba(var(--bs-primary-rgb), 0.05);
}

[data-bs-theme="dark"] .table-hover tr.cursor-pointer:hover td {
  background-color: rgba(var(--bs-primary-rgb), 0.1);
}

/* === Ticket Body === */
.ticket-body {
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* === Group Header (Cross-Project View) === */
.group-header {
  border-bottom: 2px solid var(--bs-border-color);
  padding-bottom: 0.5rem;
}

/* === Sidebar Layout === */
:root {
  --sidebar-width: 220px;
}

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: #1a1d23;
  color: #c9d1d9;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  color: #c9d1d9;
  text-decoration: none;
  font-size: 0.875rem;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-link.active {
  background-color: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.sidebar-link .bi {
  font-size: 1rem;
  width: 1.25rem;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.5rem 0;
}

.sidebar-user {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  color: #8b949e;
}

.app-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* Mobile header */
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky;
  top: 0;
  z-index: 1030;
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1035;
}

/* Mobile responsive */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .app-content {
    margin-left: 0;
  }

  body.sidebar-open {
    overflow: hidden;
  }
}

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

/* Dark mode sidebar adjustment */
[data-bs-theme="dark"] .app-sidebar {
  background: #0d1117;
}

/* Print: hide sidebar */
@media print {
  .app-sidebar,
  .mobile-header,
  .sidebar-overlay {
    display: none !important;
  }

  .app-content {
    margin-left: 0 !important;
  }
}

/* === Compact Spacing Overrides === */
h1 { font-size: 1.5rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

.card-body { padding: 0.75rem; }

.table > :not(caption) > * > * {
  padding: 0.4rem 0.5rem;
}

.list-group-item {
  padding: 0.5rem 0.75rem;
}

.breadcrumb {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* === Tickets Sticky UI === */
.tickets-filter-sticky {
  position: sticky;
  top: var(--tickets-sticky-nav, 56px);
  z-index: 1020;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  padding: 0.5rem 0;
}

.tickets-table-wrapper {
  overflow-x: auto;
  overflow-y: hidden;
}

.tickets-table {
  table-layout: fixed;
  width: 100%;
}

.tickets-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tickets-sticky .tickets-table thead th {
  position: sticky;
  top: var(--tickets-sticky-nav, 56px);
  z-index: 1005;
  background: var(--bs-body-bg);
  box-shadow: inset 0 -1px 0 var(--bs-border-color);
}

/* === Column Resize Handles === */
.tickets-table th {
  position: relative;
}

.column-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  user-select: none;
}

.column-resize-handle:hover,
.column-resize-active .column-resize-handle {
  background: var(--bs-primary);
  opacity: 0.3;
}

body.column-resize-active {
  cursor: col-resize !important;
  user-select: none;
}

/* === Favorite Star === */
.favorite-star {
  color: var(--bs-secondary);
  transition: color 0.15s ease;
}

.favorite-star:hover {
  color: #f59e0b;
}

/* === Preview Pagination === */
.preview-pagination {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* === Sortable Column Headers === */
.sortable-header {
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.sortable-header:hover {
  color: var(--bs-primary);
}

.sortable-header .bi {
  font-size: 0.7rem;
}

/* === Breakdown Bars (Dashboard) === */
.breakdown-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  gap: 1px;
}

.breakdown-segment {
  min-width: 4px;
  transition: flex-basis 0.3s ease;
}

.breakdown-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* === Kanban Board === */
.kanban-board {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 400px;
}

.kanban-column {
  flex: 0 0 280px;
  background: var(--bs-tertiary-bg);
  border-radius: 0.5rem;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
}

.kanban-column-header {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.kanban-card-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  min-height: 60px;
  transition: background-color 0.15s ease;
}

.kanban-card {
  cursor: grab;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.5;
}

.kanban-card-list.drag-over {
  background-color: rgba(var(--bs-primary-rgb), 0.08);
  border-radius: 0.375rem;
}

/* === Inline Status Dropdown === */
.badge.dropdown-toggle {
  cursor: pointer;
}

.badge.dropdown-toggle::after {
  font-size: 0.6rem;
  vertical-align: middle;
  margin-left: 0.2rem;
  opacity: 0.6;
}

/* === Keyboard Shortcut Key Cap === */
.kbd {
  display: inline-block;
  font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.25rem;
  background: var(--bs-tertiary-bg);
  box-shadow: 0 1px 0 var(--bs-border-color);
  line-height: 1;
}

/* === FreshBooks Client Picker === */
.client-picker__menu {
  width: 320px;
  max-width: 90vw;
}

.client-picker__list {
  max-height: 17rem;
  overflow-y: auto;
}

.client-picker__item .dropdown-item {
  white-space: normal;
}

.client-picker__dot {
  flex-shrink: 0;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  display: inline-block;
}

.client-picker__dot.is-active {
  background-color: var(--bs-success);
  box-shadow: 0 0 0 0.15rem rgba(var(--bs-success-rgb), 0.18);
}

.client-picker__dot.is-archived {
  background-color: var(--bs-secondary-color);
  opacity: 0.55;
}
