/* Admin Portal Styles */

/* Access Denied */
.access-denied-icon {
  text-align: center;
  margin-bottom: var(--space-md);
}

/* User Details in Sidebar */
.user-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-role-badge {
  font-size: var(--font-size-xs);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.1);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  width: fit-content;
}

/* Nav Divider */
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-md) 0;
}

.nav-item-secondary {
  color: var(--text-muted);
}

.nav-item-secondary:hover {
  color: var(--text);
}

/* Ticket Stats */
.ticket-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.stat-card.stat-warning {
  border-color: var(--warning);
}

.stat-card.stat-info {
  border-color: var(--info);
}

.stat-card.stat-success {
  border-color: var(--success);
}

.stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Ticket Filters */
.ticket-filters {
  margin-bottom: var(--space-md);
  padding: var(--space-md);
}

.filter-row {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.filter-group label {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group .form-select,
.filter-group .form-input {
  min-width: 150px;
}

.filter-search {
  flex: 1;
  min-width: 200px;
}

.filter-search .form-input {
  width: 100%;
}

/* Tickets List */
.tickets-list {
  min-height: 200px;
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.ticket-row:hover {
  background: var(--bg-hover);
}

.ticket-row:last-child {
  border-bottom: none;
}

.ticket-row-main {
  flex: 1;
  min-width: 0;
}

.ticket-subject {
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--space-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.ticket-category {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.ticket-id {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.ticket-row-side {
  text-align: right;
  flex-shrink: 0;
  margin-left: var(--space-md);
}

.ticket-requester .requester-name {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text);
}

.ticket-requester .requester-account {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.ticket-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-transform: capitalize;
}

.badge-primary {
  background: rgba(88, 166, 255, 0.2);
  color: var(--accent);
}

.badge-secondary {
  background: rgba(139, 148, 158, 0.2);
  color: var(--text-muted);
}

.badge-success {
  background: rgba(63, 185, 80, 0.2);
  color: var(--success);
}

.badge-warning {
  background: rgba(210, 153, 34, 0.2);
  color: var(--warning);
}

.badge-danger {
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
}

.badge-info {
  background: rgba(88, 166, 255, 0.1);
  color: var(--info);
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  color: var(--text-muted);
  text-align: center;
}

/* Ticket Detail View */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.ticket-detail-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-lg);
}

/* Ticket Info Panel */
.ticket-info-panel {
  padding: var(--space-lg);
  height: fit-content;
  position: sticky;
  top: var(--space-lg);
}

.ticket-meta .meta-row {
  margin-bottom: var(--space-md);
}

.ticket-meta .meta-row label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-xs);
}

.ticket-requester h4 {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.requester-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.requester-details {
  display: flex;
  flex-direction: column;
}

.requester-details .requester-name {
  font-weight: 500;
  color: var(--text);
}

.requester-details .requester-email {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.requester-details .requester-account {
  font-size: var(--font-size-xs);
  color: var(--accent);
}

.ticket-dates {
  border-top: 1px solid var(--border);
  padding-top: var(--space-md);
}

.ticket-dates .date-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-xs);
}

.ticket-dates .date-row label {
  color: var(--text-muted);
}

/* Ticket Conversation Panel */
.ticket-conversation-panel {
  min-width: 0;
}

.conversation-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.conversation-header h3 {
  font-size: var(--font-size-md);
  font-weight: 500;
  margin: 0;
}

.ticket-description {
  padding: var(--space-md);
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* Comments */
.comments-list {
  max-height: 400px;
  overflow-y: auto;
}

.comment {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.comment:last-child {
  border-bottom: none;
}

.comment-internal {
  background: rgba(210, 153, 34, 0.05);
  border-left: 3px solid var(--warning);
}

.comment-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.comment-author {
  font-weight: 500;
  color: var(--text);
}

.comment-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.comment-body {
  padding-left: 44px;
  color: var(--text);
  line-height: 1.6;
}

/* Reply Form */
.reply-form {
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.reply-type-toggle {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  cursor: pointer;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.toggle-option input[type="radio"] {
  accent-color: var(--accent);
}

.toggle-option:has(input:checked) {
  color: var(--text);
}

.form-textarea {
  width: 100%;
  min-height: 100px;
  padding: var(--space-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: inherit;
  font-size: var(--font-size-sm);
  resize: vertical;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.reply-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-sm);
}

/* Form Select */
.form-select {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Button Success State */
.btn-success {
  background: var(--success) !important;
  border-color: var(--success) !important;
}

/* Utility */
.p-lg {
  padding: var(--space-lg);
}

.p-md {
  padding: var(--space-md);
}

.text-center {
  text-align: center;
}

.text-danger {
  color: var(--danger);
}

/* Bug Tracking Section */
.ticket-bug-section {
  padding-top: var(--space-md);
}

.ticket-bug-section h4 {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

/* Bug link */
.bug-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  color: var(--danger);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all 0.2s ease;
}

.bug-link:hover {
  background: rgba(248, 81, 73, 0.2);
  text-decoration: none;
}

.bug-link svg {
  width: 14px;
  height: 14px;
}

/* Bug button */
.btn-bug {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.btn-bug svg {
  width: 14px;
  height: 14px;
}

/* Extra small button */
.btn-xs {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
}

/* GitHub issue creation button */
.btn-github-create {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: #238636;
  border-color: #238636;
  color: white;
}

.btn-github-create:hover {
  background: #2ea043;
  border-color: #2ea043;
}

.btn-github-create svg {
  width: 14px;
  height: 14px;
}

/* Small GitHub link */
.github-link-small {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(35, 134, 54, 0.1);
  border: 1px solid #238636;
  border-radius: var(--radius-md);
  color: #3fb950;
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 500;
  transition: all 0.2s ease;
}

.github-link-small:hover {
  background: rgba(35, 134, 54, 0.2);
  text-decoration: none;
}

.github-link-small svg {
  width: 14px;
  height: 14px;
}

/* Margin utilities */
.mt-sm {
  margin-top: var(--space-sm);
}

.mt-lg {
  margin-top: var(--space-lg);
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.data-table thead {
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}

.data-table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: var(--font-size-xs);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table .clickable-row {
  cursor: pointer;
  transition: background var(--transition-fast);
}

.data-table .clickable-row:hover {
  background: var(--bg-hover);
}

/* Table links */
.data-table .ticket-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.data-table .ticket-link:hover {
  text-decoration: underline;
}

/* Bugs View Specific */
#bugs-view .card {
  overflow: hidden;
}

#bugs-view .data-table td:first-child {
  font-family: var(--font-mono);
  color: var(--text-muted);
  font-size: var(--font-size-xs);
}

#bugs-view .data-table td:nth-child(2) {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

#bugs-view .data-table td:last-child {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Bug Detail Panel Improvements */
#bug-detail-view .ticket-detail-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--space-lg);
}

#bug-detail-view .ticket-info-panel {
  padding: var(--space-lg);
  height: fit-content;
  position: sticky;
  top: var(--space-lg);
}

#bug-detail-view .ticket-conversation-panel {
  min-width: 0;
}

/* View Header Improvements */
#bugs-view .view-header,
#bug-detail-view .view-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
  gap: var(--space-md);
}

#bug-detail-view .view-header {
  justify-content: flex-start;
}

#bug-detail-view .view-header h1 {
  flex: 1;
  margin-left: var(--space-md);
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/* Button Full Width */
.btn-full {
  width: 100%;
}

/* Responsive */
@media (max-width: 1024px) {
  .ticket-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .ticket-detail-container {
    grid-template-columns: 1fr;
  }

  .ticket-info-panel {
    position: static;
  }

  #bug-detail-view .ticket-detail-container {
    grid-template-columns: 1fr;
  }

  #bug-detail-view .ticket-info-panel {
    position: static;
  }

  .data-table {
    font-size: var(--font-size-xs);
  }

  .data-table th,
  .data-table td {
    padding: var(--space-xs) var(--space-sm);
  }
}

@media (max-width: 768px) {
  .ticket-stats {
    grid-template-columns: 1fr;
  }

  .filter-row {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group .form-select,
  .filter-group .form-input {
    width: 100%;
    min-width: auto;
  }
}

/* Bug Detail Enhancements */
.bug-id-badge {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.form-group {
  margin-bottom: var(--space-sm);
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-xs);
}

.form-textarea {
  width: 100%;
  padding: var(--space-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-size-sm);
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mt-md {
  margin-top: var(--space-md);
}

/* Bug Sections (Time Tracking, Comments) */
.bug-section {
  padding: var(--space-lg);
}

.bug-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border);
}

.bug-section-header h3 {
  margin: 0;
  font-size: var(--font-size-md);
  font-weight: 600;
}

.time-total {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}

.comments-count {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Time Entries List */
.time-entries-list {
  margin-bottom: var(--space-md);
  max-height: 300px;
  overflow-y: auto;
}

.time-entry {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  position: relative;
}

.time-entry-info {
  display: flex;
  gap: var(--space-md);
  flex-shrink: 0;
  min-width: 200px;
}

.time-entry-date {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  min-width: 50px;
}

.time-entry-user {
  font-size: var(--font-size-sm);
  font-weight: 500;
  min-width: 80px;
}

.time-entry-minutes {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
  min-width: 50px;
}

.time-entry-notes {
  flex: 1;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-delete-time {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-xs);
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: all var(--transition-fast);
}

.time-entry:hover .btn-delete-time {
  opacity: 1;
}

.btn-delete-time:hover {
  background: rgba(248, 81, 73, 0.2);
  color: var(--danger);
}

/* Time Entry Form */
.time-entry-form {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.time-entry-inputs {
  display: flex;
  gap: var(--space-sm);
  flex: 1;
}

.time-minutes-input {
  width: 80px !important;
  min-width: 80px !important;
}

.time-notes-input {
  flex: 1;
  min-width: 100px;
}

.time-date-input {
  width: 140px !important;
  min-width: 140px !important;
}

/* Comments List */
.comments-list {
  margin-bottom: var(--space-md);
  max-height: 400px;
  overflow-y: auto;
}

.comment {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-sm);
}

.comment-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
}

.comment-author {
  font-weight: 600;
  font-size: var(--font-size-sm);
}

.comment-date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.comment-content {
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* Comment Form */
.comment-form {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-end;
}

.comment-form .form-textarea {
  flex: 1;
  min-height: 60px;
}

.comment-form .btn {
  flex-shrink: 0;
}

/* Empty State Small */
.empty-state-small {
  padding: var(--space-md);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* Icon buttons */
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: var(--space-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Button small */
.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--font-size-sm);
  gap: var(--space-xs);
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

/* Responsive for bug detail */
@media (max-width: 768px) {
  .time-entry-form {
    flex-direction: column;
    align-items: stretch;
  }

  .time-entry-inputs {
    flex-direction: column;
  }

  .time-minutes-input,
  .time-date-input {
    width: 100% !important;
    min-width: auto !important;
  }

  .comment-form {
    flex-direction: column;
    align-items: stretch;
  }

  .time-entry {
    flex-direction: column;
  }

  .time-entry-info {
    flex-wrap: wrap;
    min-width: auto;
  }
}

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-lg {
  max-width: 700px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-header h2 {
  margin: 0;
  font-size: var(--font-size-lg);
}

.btn-close {
  background: transparent;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg-card);
}

/* Form Row for side-by-side inputs */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Margin bottom small */
.mb-sm {
  margin-bottom: var(--space-sm);
}

/* Checkbox label styling */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* Form input styling */
.form-input {
  width: 100%;
  padding: var(--space-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: var(--font-size-sm);
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input[readonly] {
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Pricing table specific */
#pricing-view .data-table td:first-child {
  font-weight: 600;
}

#pricing-view .data-table td:nth-child(3),
#pricing-view .data-table td:nth-child(4) {
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
}

/* Small text helper */
small.text-muted {
  display: block;
  font-size: var(--font-size-xs);
  margin-top: 2px;
}
