/* Telegram History Dashboard Styles */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  min-height: 100vh;
  color: #e0e0e0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.header h1 {
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: 4px;
}

.header p {
  color: #a0a0a0;
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #0088cc 0%, #0066aa 100%);
  color: white;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #0099dd 0%, #0077bb 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Statistics Section */
.stats-section {
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.stat-card.total .stat-icon {
  background: rgba(99, 102, 241, 0.2);
}

.stat-card.pending .stat-icon {
  background: rgba(245, 158, 11, 0.2);
}

.stat-card.acknowledged .stat-icon {
  background: rgba(34, 197, 94, 0.2);
}

.stat-card.response-time .stat-icon {
  background: rgba(59, 130, 246, 0.2);
}

.stat-card.last24h .stat-icon {
  background: rgba(168, 85, 247, 0.2);
}

.stat-card.chats .stat-icon {
  background: rgba(59, 130, 246, 0.2);
}

.stat-detail {
  font-size: 0.75rem;
  color: #888;
  margin-top: 2px;
}

/* Bot Tabs */
.bot-tabs {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.bot-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #a0a0a0;
  font-size: 1rem;
  font-weight: 500;
}

.bot-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #e0e0e0;
}

.bot-tab.active {
  background: linear-gradient(135deg, #0088cc 0%, #0066aa 100%);
  border-color: #0088cc;
  color: white;
}

.bot-tab.active[data-bot="redflag"] {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  border-color: #dc2626;
}

.tab-icon {
  font-size: 1.3rem;
}

.tab-label {
  font-weight: 500;
}

.tab-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

.tab-badge.redflag {
  background: rgba(220, 38, 38, 0.3);
}

.bot-tab.active .tab-badge {
  background: rgba(255, 255, 255, 0.3);
}

/* Bot Dashboard containers */
.bot-dashboard {
  display: none;
}

.bot-dashboard.active {
  display: block;
}

/* Red Flag specific styles */
.redflag-card {
  border-left: 3px solid #dc2626;
}

.redflag-card .stat-icon {
  background: rgba(220, 38, 38, 0.2);
}

.stat-card.today .stat-icon {
  background: rgba(245, 158, 11, 0.2);
}

.stat-card.week .stat-icon {
  background: rgba(139, 92, 246, 0.2);
}

.stat-card.month .stat-icon {
  background: rgba(6, 182, 212, 0.2);
}

.breakdown-item.redflag {
  border-left: 3px solid #dc2626;
}

.breakdown-item.redflag .breakdown-value {
  color: #f87171;
}

.status-badge.sent {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.status-badge.viewed {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.no-data {
  color: #666;
  font-style: italic;
}

.stat-card.unique .stat-icon {
  background: rgba(236, 72, 153, 0.2);
}

.stat-content {
  display: flex;
  flex-direction: column;
}

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

.stat-label {
  font-size: 0.85rem;
  color: #a0a0a0;
}

/* Alert Type Breakdown */
.breakdown-section {
  margin-top: 20px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.breakdown-section h3 {
  font-size: 0.95rem;
  color: #a0a0a0;
  margin-bottom: 16px;
  font-weight: 500;
}

.breakdown-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.breakdown-label {
  font-size: 0.9rem;
  color: #a0a0a0;
}

.breakdown-value {
  font-size: 1.2rem;
  font-weight: 600;
}

.breakdown-item.valid .breakdown-value {
  color: #10b981;
}

.breakdown-item.invalid .breakdown-value {
  color: #ef4444;
}

.breakdown-item.comment .breakdown-value {
  color: #3b82f6;
}

/* Filters Section */
.filters-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 0.85rem;
  color: #a0a0a0;
}

.filter-group select,
.filter-group input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #e0e0e0;
  font-size: 0.9rem;
  min-width: 150px;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: #0088cc;
}

.filter-actions {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

/* Table Section */
.table-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: rgba(0, 0, 0, 0.3);
}

th {
  padding: 14px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover {
  color: #fff;
}

th.sorted-asc::after {
  content: ' ▲';
}

th.sorted-desc::after {
  content: ' ▼';
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.9rem;
}

tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

tr.clickable {
  cursor: pointer;
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.status-badge.acknowledged {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

/* Type Badges */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.type-badge.comment {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

.type-badge.positive {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.type-badge.negative {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

/* Info Badge (for "Sent To" column) */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-info {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

/* Comment cell */
.comment-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.response-cell {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #60a5fa;
  font-style: italic;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px !important;
  color: #a0a0a0;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1a1a2e;
  border-radius: 16px;
  padding: 30px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 1.5rem;
  cursor: pointer;
  color: #a0a0a0;
}

.modal-close:hover {
  color: #fff;
}

.modal-content h2 {
  margin-bottom: 20px;
  color: #fff;
}

.alert-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-row {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.detail-label {
  font-weight: 600;
  color: #a0a0a0;
  min-width: 140px;
}

.detail-value {
  color: #e0e0e0;
  word-break: break-word;
}

.detail-value.comment-full {
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 6px;
  width: 100%;
}

/* View Responses link */
.view-responses {
  color: #60a5fa;
  cursor: pointer;
  text-decoration: underline;
}

.view-responses:hover {
  color: #93c5fd;
}

/* Responses list in modal */
.responses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  width: 100%;
}

.response-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 3px solid #4ade80;
}

.response-item.reply {
  border-left-color: #60a5fa;
}

.response-type {
  font-size: 1.1rem;
}

.response-user {
  font-weight: 600;
  color: #60a5fa;
}

.response-text {
  flex: 1;
  font-style: italic;
  color: #e0e0e0;
  min-width: 100%;
  margin-top: 4px;
  padding-left: 28px;
}

.response-time {
  color: #a0a0a0;
  font-size: 0.85rem;
  margin-left: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

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

  .filter-group {
    width: 100%;
  }

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

  .filter-actions {
    width: 100%;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
