/* ==========================================================================
   Component Styles - Tickets Management System (SaaS)
   Solid/Semi-solid content surfaces for maximum legibility and usability
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), #6d28d9);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.38);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--surface-card);
  border: 1px solid var(--line-strong);
  color: var(--ink);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-canvas);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger-tint);
  border: 1px solid var(--danger-border);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #ffffff;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--surface-card);
  border: 1px solid var(--line);
  color: var(--ink-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
}

.btn-icon:hover {
  background: var(--bg-canvas);
  color: var(--primary);
  border-color: var(--line-strong);
}

/* --------------------------------------------------------------------------
   Form Inputs & Controls
   -------------------------------------------------------------------------- */
.field {
  margin-bottom: 16px;
  position: relative;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.input-text, select, textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface-input);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-text:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input {
  padding-right: 38px;
}

.toggle-password-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.toggle-password-btn:hover {
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   Badges & Indicators
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-priority-low, .priority-Low {
  background: var(--priority-low-bg);
  color: var(--priority-low-text);
  border: 1px solid var(--success-border);
}

.badge-priority-medium, .priority-Medium {
  background: var(--priority-med-bg);
  color: var(--priority-med-text);
  border: 1px solid var(--warning-border);
}

.badge-priority-high, .priority-High {
  background: var(--priority-high-bg);
  color: var(--priority-high-text);
  border: 1px solid var(--danger-border);
}

.badge-verified {
  background: var(--success-tint);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.badge-unverified {
  background: var(--warning-tint);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.badge-plan {
  background: var(--primary-tint);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.25);
}

/* --------------------------------------------------------------------------
   Cards & Surface Containers
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-header h2, .card-header h3 {
  font-size: 15px;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Kanban Columns & Cards
   -------------------------------------------------------------------------- */
.board-columns {
  display: grid;
  grid-template-columns: repeat(4, minmax(280px, 1fr));
  gap: 16px;
  align-items: flex-start;
}

.column {
  background: var(--column-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: background-color var(--transition-fast);
}

.column.drag-over {
  background: var(--column-drag-bg);
  border-color: var(--primary);
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.column-header .count {
  background: var(--surface-card);
  color: var(--ink);
  font-size: 11px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
}

.ticket-card {
  background: var(--surface-card-subtle);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.ticket-card.card-priority-Low { border-left-color: var(--priority-low-text); }
.ticket-card.card-priority-Medium { border-left-color: var(--priority-med-text); }
.ticket-card.card-priority-High { border-left-color: var(--priority-high-text); }

.ticket-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(79, 70, 229, 0.4);
}

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

.ticket-card.dragging {
  opacity: 0.4;
  transform: scale(0.96);
}

.ticket-card .ticket-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 8px;
  word-break: break-word;
}

.ticket-card .ticket-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.ticket-card .ticket-date {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--muted-light);
  margin-top: 8px;
}

.avatar, .mini-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-full);
  flex-shrink: 0;
  user-select: none;
}

.mini-avatar {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.avatar {
  width: 36px;
  height: 36px;
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   Modals & Accessible Overlays
   -------------------------------------------------------------------------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.modal-overlay.open {
  display: flex;
  opacity: 1;
}

.modal-dialog {
  background: var(--surface-modal);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-modal);
  width: 540px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.modal-overlay.open .modal-dialog {
  transform: scale(1);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2, .modal-header h3 {
  font-size: 16px;
  margin: 0;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-canvas);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--ink);
  background: var(--line);
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--line);
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.tab-btn:hover {
  color: var(--ink);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* --------------------------------------------------------------------------
   Dropdown Menus
   -------------------------------------------------------------------------- */
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface-dropdown);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  min-width: 280px;
  z-index: 50;
  overflow: hidden;
  animation: dropdownFade 180ms ease-out;
}

.dropdown-menu.open {
  display: block;
}

@keyframes dropdownFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Tables (Desktop & Responsive Mobile Cards)
   -------------------------------------------------------------------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.data-table th {
  background: var(--bg-canvas);
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tr:hover td {
  background: var(--table-hover-bg);
}

/* --------------------------------------------------------------------------
   Empty States
   -------------------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 44px;
  margin-bottom: 12px;
  display: inline-block;
}

.empty-state h3 {
  font-size: 17px;
  color: var(--ink);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 420px;
  margin: 0 auto 20px;
}

/* --------------------------------------------------------------------------
   Mobile Responsive Overrides (< 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .board-columns {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding-bottom: 12px;
  }

  .column {
    min-width: 82vw;
    scroll-snap-align: start;
    min-height: 400px;
  }

  .modal-dialog {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin-top: auto;
    margin-bottom: 0;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  /* Transform table to stacked cards on small screens */
  .responsive-table table, 
  .responsive-table thead, 
  .responsive-table tbody, 
  .responsive-table th, 
  .responsive-table td, 
  .responsive-table tr {
    display: block;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tr {
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-card);
    padding: 10px;
    box-shadow: var(--shadow-sm);
  }

  .responsive-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding: 8px 6px;
    font-size: 12px;
  }

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

  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
  }
}

/* --------------------------------------------------------------------------
   Dark Mode Toggle Button
   -------------------------------------------------------------------------- */
[data-theme-toggle] {
  font-size: 16px;
}

/* Fixed-position variant, for pages with no topbar (auth/login screens) */
.theme-toggle-fab {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 60;
}

@media (max-width: 640px) {
  .theme-toggle-fab {
    top: 12px;
    right: 12px;
  }
}

/* --------------------------------------------------------------------------
   Collapsible Sidebar (Projects panel)
   -------------------------------------------------------------------------- */
.app-sidebar {
  transition: width var(--transition-normal);
}

.sidebar-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 12px;
}

.sidebar-collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.sidebar-collapse-btn:hover {
  background: var(--bg-canvas);
  color: var(--primary);
}

.app-sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
  padding-left: 8px;
  padding-right: 8px;
}

.app-sidebar.collapsed .sidebar-title-text {
  display: none;
}

.app-sidebar.collapsed .sidebar-header-row {
  justify-content: center;
}

.app-sidebar.collapsed .sidebar-collapse-btn {
  transform: rotate(180deg);
}

.app-sidebar.collapsed .project-nav-item {
  justify-content: center;
  padding: 10px 0;
}

.app-sidebar.collapsed .project-nav-label,
.app-sidebar.collapsed .project-nav-count {
  display: none;
}

.app-sidebar.collapsed .project-nav-icon {
  font-size: 16px;
}

@media (max-width: 860px) {
  .app-sidebar.collapsed {
    width: 100%;
    max-height: 64px;
  }
}

/* Uploaded company logo, shown instead of the "TM" square when one is set.
   Sized to match .brand-logo so the topbar height never shifts. */
.brand-logo-img {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: var(--surface-card);
  border: 1px solid var(--line);
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   @mentions — highlight in rendered comments, and the typeahead picker
   -------------------------------------------------------------------------- */
.md-comment .mention {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  border-radius: 4px;
  padding: 0 3px;
  font-weight: 600;
}

.mention-suggestions {
  /* Anchored above the comment input so it never pushes the modal taller. */
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 20;
  width: min(280px, 100%);
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
}

.mention-suggestions[hidden] {
  display: none;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}

.mention-option:hover,
.mention-option.active {
  background: var(--bg-canvas);
}

/* --------------------------------------------------------------------------
   Board filters, bulk bar, overdue, tags, checklist, attachments
   -------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.filter-bar select {
  width: auto;
  min-width: 130px;
  padding: 6px 10px;
  font-size: 12px;
}

.bulk-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  background: var(--primary-tint);
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: var(--radius-md);
}

.bulk-bar.open {
  display: flex;
}

.bulk-bar select {
  width: auto;
  min-width: 120px;
  padding: 5px 8px;
  font-size: 12px;
}

.ticket-card.overdue {
  border-left-color: var(--danger) !important;
  box-shadow: inset 3px 0 0 var(--danger);
}

.ticket-card.selected {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

.ticket-card:has(.ticket-select) .ticket-title {
  padding-right: 22px;
}

.ticket-select {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 16px;
  height: 16px;
  cursor: pointer;
  z-index: 2;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  color: #fff;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
}

.attachment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
}

.md-comment a {
  color: var(--primary);
  text-decoration: underline;
}

.md-comment code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: var(--bg-canvas);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.badge-overdue {
  background: var(--danger-tint);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
