/* ========== Page ========== */
.ticket-progress-page {
  padding: 1.5rem 2rem 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100%;
}

/* ========== Header ========== */
.ticket-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.ticket-progress-header h1 {
  font-size: 1.625rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary, #0f172a);
  letter-spacing: -0.02em;
}

.btn-raise {
  padding: 0.6rem 1.25rem;
  background: var(--primary, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}

.btn-raise:hover {
  background: var(--primary-hover, #2563eb);
  transform: translateY(-1px);
}

.btn-raise:active {
  transform: translateY(0);
}

/* ========== Loading ========== */
.ticket-progress-loading {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary, #64748b);
  font-size: 1rem;
}

.ticket-progress-loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 0.5rem;
  border: 2px solid var(--border-color, #e2e8f0);
  border-top-color: var(--primary, #3b82f6);
  border-radius: 50%;
  animation: ticket-progress-spin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes ticket-progress-spin {
  to { transform: rotate(360deg); }
}

/* ========== Stats ========== */
.ticket-progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1.25rem 1rem;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

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

.stat-card .stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.25rem;
  opacity: 0.9;
}

.stat-open {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
}

.stat-in-progress {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
}

.stat-resolved {
  background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
  color: #065f46;
}

/* ========== Filters ========== */
.ticket-progress-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.filter-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  margin-right: 0.25rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 9999px;
  background: var(--card-bg, #fff);
  color: var(--text-primary, #334155);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  background: var(--hover-bg, #f1f5f9);
  border-color: var(--text-secondary, #94a3b8);
}

.filter-btn.active {
  background: var(--primary, #3b82f6);
  color: #fff;
  border-color: var(--primary, #3b82f6);
}

/* ========== Error ========== */
.ticket-progress-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.875rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  border: 1px solid #fecaca;
}

/* ========== Table ========== */
.ticket-progress-table-wrap {
  overflow-x: auto;
  background: var(--card-bg, #fff);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border-color, #e2e8f0);
}

.ticket-progress-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}

.ticket-progress-table th,
.ticket-progress-table td {
  padding: 0.875rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color, #f1f5f9);
}

.ticket-progress-table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #64748b);
  background: var(--hover-bg, #f8fafc);
  white-space: nowrap;
}

.ticket-progress-table th:first-child {
  border-radius: 12px 0 0 0;
}

.ticket-progress-table tbody tr {
  transition: background 0.15s;
}

.ticket-progress-table tbody tr:hover {
  background: var(--hover-bg, #f8fafc);
}

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

.ticket-progress-table td {
  font-size: 0.9rem;
  color: var(--text-primary, #1e293b);
}

.ticket-progress-table .col-id {
  width: 56px;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
}

.ticket-progress-table .col-subject {
  max-width: 220px;
}

.ticket-progress-table .col-subject .subject-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-progress-table .col-created,
.ticket-progress-table .col-resolved {
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-secondary, #64748b);
}

.ticket-status {
  display: inline-block;
  padding: 0.3rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.ticket-status-open {
  background: #dbeafe;
  color: #1d4ed8;
}

.ticket-status-in-progress {
  background: #fef3c7;
  color: #b45309;
}

.ticket-status-resolved {
  background: #d1fae5;
  color: #047857;
}

.actions-cell {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-view {
  padding: 0.4rem 0.85rem;
  background: var(--primary, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-view:hover {
  background: var(--primary-hover, #2563eb);
}

.btn-working-on {
  padding: 0.4rem 0.85rem;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-working-on:hover:not(:disabled) {
  background: #fde68a;
}

.btn-working-on:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-close-ticket {
  padding: 0.4rem 0.85rem;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-close-ticket:hover:not(:disabled) {
  background: #e2e8f0;
  color: #334155;
}

.btn-close-ticket:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ========== Empty state ========== */
.tickets-empty {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-secondary, #64748b);
  font-size: 0.95rem;
}

.tickets-empty .link-btn {
  margin-top: 0.5rem;
  display: inline-block;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary, #3b82f6);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  padding: 0;
  font-size: inherit;
}

.link-btn:hover {
  color: var(--primary-hover, #2563eb);
  text-decoration: underline;
}

/* ========== Detail modal ========== */
.ticket-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  z-index: 1000;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  animation: ticket-detail-fadeIn 0.2s ease-out;
}

@keyframes ticket-detail-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ticket-detail-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card-bg, #fff);
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: ticket-detail-slideUp 0.25s ease-out;
}

@keyframes ticket-detail-slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) translateY(0);
  }
}

@keyframes ticket-detail-slideUpMobile {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.ticket-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: var(--hover-bg, #f8fafc);
}

.ticket-detail-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary, #0f172a);
}

.btn-close-modal {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-secondary, #64748b);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}

.btn-close-modal:hover {
  color: var(--text-primary, #1e293b);
  background: var(--hover-bg, #f1f5f9);
}

.ticket-detail-loading {
  padding: 3rem;
  text-align: center;
  color: var(--text-secondary, #64748b);
}

.ticket-detail-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.detail-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.875rem;
  align-items: baseline;
}

.detail-label {
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  min-width: 100px;
  font-size: 0.85rem;
}

.detail-value {
  color: var(--text-primary, #1e293b);
  font-size: 0.95rem;
}

.detail-block {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.detail-block .detail-label {
  display: block;
  margin-bottom: 0.5rem;
}

.detail-description {
  margin: 0;
  white-space: pre-wrap;
  color: var(--text-primary, #1e293b);
  font-size: 0.95rem;
  line-height: 1.6;
}

.detail-timeline .detail-label {
  margin-bottom: 0.75rem;
}

.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-item {
  padding: 0.6rem 0 0.6rem 1rem;
  border-left: 2px solid var(--primary, #3b82f6);
  margin-left: 4px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 1rem;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary, #3b82f6);
}

.timeline-date {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary, #64748b);
  margin-bottom: 0.2rem;
}

.timeline-desc {
  font-size: 0.9rem;
}

.timeline-user {
  font-size: 0.8rem;
  color: var(--text-secondary, #64748b);
  margin-left: 0.5rem;
}

.ticket-detail-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.ticket-detail-actions .btn-secondary {
  padding: 0.55rem 1.1rem;
  background: var(--card-bg, #fff);
  color: var(--text-primary, #1e293b);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.ticket-detail-actions .btn-secondary:hover {
  background: var(--hover-bg, #f1f5f9);
}

/* ========== Mobile responsive ========== */
@media (max-width: 768px) {
  .ticket-progress-page {
    padding: 1.25rem 1.25rem 2rem;
  }

  .ticket-progress-header {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 1.5rem;
  }

  .ticket-progress-header h1 {
    font-size: 1.4rem;
    text-align: center;
  }

  .ticket-progress-header .btn-raise {
    width: 100%;
    padding: 0.75rem 1rem;
    min-height: 48px;
  }

  .ticket-progress-stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 1rem 0.75rem;
  }

  .stat-card .stat-value {
    font-size: 1.5rem;
  }

  .stat-card .stat-label {
    font-size: 0.7rem;
  }

  .ticket-progress-filters {
    gap: 0.5rem;
  }

  .filter-label {
    width: 100%;
    margin-bottom: 0.25rem;
  }

  .filter-btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 640px) {
  .ticket-progress-page {
    padding: 1rem 1rem 1.75rem;
  }

  .ticket-progress-header h1 {
    font-size: 1.3rem;
  }

  .ticket-progress-stats {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    text-align: left;
  }

  .stat-card .stat-value {
    font-size: 1.75rem;
    margin-right: 0.75rem;
  }

  .stat-card .stat-label {
    margin-top: 0;
    font-size: 0.85rem;
    text-transform: none;
  }

  .ticket-progress-table-wrap {
    border-radius: 12px;
    overflow: visible;
  }

  .ticket-progress-table {
    min-width: 0;
    border: none;
  }

  .ticket-progress-table thead {
    display: none;
  }

  .ticket-progress-table tbody tr.ticket-progress-row {
    display: block;
    padding: 1rem 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--card-bg, #fff);
    border-radius: 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  }

  .ticket-progress-table tbody tr.ticket-progress-row:last-child {
    margin-bottom: 0;
  }

  .ticket-progress-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color, #f1f5f9);
    font-size: 0.9rem;
  }

  .ticket-progress-table tbody td:last-child {
    border-bottom: none;
    padding-top: 0.75rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--border-color, #e2e8f0);
  }

  .ticket-progress-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary, #64748b);
    flex-shrink: 0;
  }

  .ticket-progress-table tbody td.actions-cell::before {
    display: none;
  }

  .ticket-progress-table tbody td.actions-cell {
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 0.5rem;
  }

  .ticket-progress-table tbody td.actions-cell .btn-view,
  .ticket-progress-table tbody td.actions-cell .btn-working-on,
  .ticket-progress-table tbody td.actions-cell .btn-close-ticket {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.5rem;
    font-size: 0.8rem;
  }

  .ticket-progress-table .col-subject .subject-text {
    white-space: normal;
    text-overflow: unset;
  }

  .ticket-progress-table tbody tr:not(.ticket-progress-row) td {
    display: block;
    padding: 2rem 1rem;
    border: none;
    justify-content: center;
    text-align: center;
  }

  .ticket-progress-table tbody tr:not(.ticket-progress-row) td::before {
    display: none;
  }

  .tickets-empty {
    padding: 2rem 1rem;
  }

  /* Detail modal mobile */
  .ticket-detail-overlay {
    padding: 0;
  }

  .ticket-detail-modal {
    top: auto;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: ticket-detail-slideUpMobile 0.25s ease-out;
  }

  .ticket-detail-header {
    padding: 1rem 1.25rem;
  }

  .ticket-detail-header h2 {
    font-size: 1.1rem;
  }

  .ticket-detail-body {
    padding: 1.25rem;
  }

  .detail-row {
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
  }

  .detail-label {
    min-width: 0;
  }

  .ticket-detail-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .ticket-detail-actions button {
    width: 100%;
    min-height: 48px;
    justify-content: center;
  }
}

/* ================================ DARK THEME (night mode) ================================ */
body.night-mode .ticket-progress-page {
  background: rgba(58, 56, 56, 0.95);
  min-height: 100%;
}
body.night-mode .ticket-progress-header h1 {
  color: rgba(255, 255, 255, 0.98);
}
body.night-mode .btn-raise {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  color: #fff;
}
body.night-mode .ticket-progress-loading {
  color: rgba(255, 255, 255, 0.9);
}
body.night-mode .ticket-progress-loading::after {
  border-color: rgba(255, 255, 255, 0.2);
  border-top-color: #f87171;
}
body.night-mode .stat-card {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .stat-open {
  background: rgba(59, 130, 246, 0.25);
  color: #93c5fd;
}
body.night-mode .stat-in-progress {
  background: rgba(251, 191, 36, 0.3);
  color: #fcd34d;
}
body.night-mode .stat-resolved {
  background: rgba(52, 211, 153, 0.25);
  color: #6ee7b7;
}
body.night-mode .stat-card .stat-value,
body.night-mode .stat-card .stat-label {
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .filter-label {
  color: rgba(255, 255, 255, 0.85);
}
body.night-mode .filter-btn {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
}
body.night-mode .filter-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
body.night-mode .filter-btn.active {
  background: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
  color: #fff;
  border-color: #ef4444;
}
body.night-mode .ticket-progress-error {
  background: rgba(248, 113, 113, 0.15) !important;
  color: #fca5a5 !important;
  border-color: rgba(248, 113, 113, 0.4);
}
body.night-mode .ticket-progress-table-wrap {
  background: rgba(58, 56, 56, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .ticket-progress-table th {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .ticket-progress-table td {
  color: rgba(255, 255, 255, 0.9);
}
body.night-mode .ticket-progress-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.06);
}
body.night-mode .ticket-progress-table .col-id,
body.night-mode .ticket-progress-table .col-created,
body.night-mode .ticket-progress-table .col-resolved {
  color: rgba(255, 255, 255, 0.8);
}
body.night-mode .ticket-status-open {
  background: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}
body.night-mode .ticket-status-in-progress {
  background: rgba(251, 191, 36, 0.3);
  color: #fcd34d;
}
body.night-mode .ticket-status-resolved {
  background: rgba(52, 211, 153, 0.25);
  color: #6ee7b7;
}
body.night-mode .tickets-empty {
  color: rgba(255, 255, 255, 0.85);
}
body.night-mode .link-btn {
  color: #f87171;
}
body.night-mode .link-btn:hover {
  color: #fca5a5;
}
body.night-mode .btn-close-ticket {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.2);
}
body.night-mode .btn-close-ticket:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.18);
}
body.night-mode .ticket-detail-modal {
  background: rgba(58, 56, 56, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
body.night-mode .ticket-detail-header {
  background: rgba(255, 255, 255, 0.06);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .ticket-detail-header h2 {
  color: rgba(255, 255, 255, 0.98);
}
body.night-mode .btn-close-modal {
  color: rgba(255, 255, 255, 0.8);
}
body.night-mode .btn-close-modal:hover {
  color: #f87171;
  background: rgba(255, 255, 255, 0.1);
}
body.night-mode .ticket-detail-loading {
  color: rgba(255, 255, 255, 0.8);
}
body.night-mode .detail-label {
  color: rgba(255, 255, 255, 0.8);
}
body.night-mode .detail-value,
body.night-mode .detail-description {
  color: rgba(255, 255, 255, 0.95);
}
body.night-mode .detail-block {
  border-top-color: rgba(255, 255, 255, 0.1);
}
body.night-mode .timeline-date,
body.night-mode .timeline-user {
  color: rgba(255, 255, 255, 0.75);
}
body.night-mode .timeline-desc {
  color: rgba(255, 255, 255, 0.9);
}
body.night-mode .ticket-detail-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.95);
  border-color: rgba(255, 255, 255, 0.25);
}
body.night-mode .ticket-detail-actions .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f87171;
}
@media (max-width: 640px) {
  body.night-mode .ticket-progress-table tbody tr.ticket-progress-row {
    background: rgba(58, 56, 56, 0.8);
    border-color: rgba(255, 255, 255, 0.1);
  }
  body.night-mode .ticket-progress-table tbody td::before {
    color: rgba(255, 255, 255, 0.75);
  }
}
