/* Warwick Hockey Chatbot - Dark Theme */

/* Directions Card Styles */
.directions-match-info {
  background: rgba(204, 0, 0, 0.1);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(204, 0, 0, 0.3);
}

.match-teams {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  text-align: center;
}

.match-datetime {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: #e5e5e5;
}

.match-date {
  font-weight: 500;
}

.match-separator {
  color: #666;
  font-weight: bold;
}

.match-time {
  font-weight: 600;
  color: #cc0000;
}

.chatbot-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #cc0000 0%, #990000 100%);
  border: none;
  color: white;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(204, 0, 0, 0.4);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.chatbot-toggle::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.chatbot-toggle:hover::before {
  left: 100%;
}

.chatbot-toggle:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 32px rgba(204, 0, 0, 0.5);
}

.chatbot-toggle.hidden {
  display: none;
}

.chatbot-container {
  width: 380px;
  height: 600px;
  background: linear-gradient(135deg, #1a1a1a, #0f0f0f);
  border-radius: 12px;
  border: 1px solid #333;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.chatbot-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #cc0000, #990000);
}

.chatbot-container.hidden {
  display: none;
}

.chatbot-header {
  background: rgba(26, 26, 26, 0.95);
  backdrop-filter: blur(10px);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #333;
  position: relative;
  z-index: 1;
}

.chatbot-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
}

.chatbot-close-btn {
  background: transparent;
  border: 1px solid #333;
  color: #999;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.chatbot-close-btn:hover {
  background-color: rgba(204, 0, 0, 0.1);
  border-color: #cc0000;
  color: #cc0000;
  transform: rotate(90deg);
}

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #0f0f0f;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

.chatbot-message {
  display: flex;
  margin-bottom: 8px;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-content {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 8px;
  word-wrap: break-word;
  line-height: 1.6;
  position: relative;
}

.user-message {
  justify-content: flex-end;
}

.user-message .message-content {
  background: linear-gradient(135deg, #cc0000, #990000);
  color: white;
  border-bottom-right-radius: 2px;
  box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
}

.bot-message {
  justify-content: flex-start;
}

.bot-message .message-content {
  background: #1a1a1a;
  color: #d1d5db;
  border: 1px solid #333;
  border-bottom-left-radius: 2px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.bot-message .message-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, #cc0000, #990000);
  border-radius: 8px 0 0 8px;
}

.bot-message .message-content ul {
  margin: 8px 0;
  padding-left: 24px;
}

.bot-message .message-content li {
  margin: 6px 0;
  color: #d1d5db;
}

.bot-message .message-content p {
  color: #d1d5db;
  margin: 0;
}

.bot-message .message-content a {
  color: #cc0000;
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.bot-message .message-content a:hover {
  color: #ff0000;
  text-decoration: underline;
}

/* Markdown Table Styles - Mobile First */
.markdown-table-wrapper {
  width: 100%;
  margin: 16px 0;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.bot-message .message-content .markdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

/* Mobile: Compact table layout - Full width */
@media (max-width: 768px) {
  /* Remove max-width constraint from message-content when it has a table */
  .bot-message .message-content:has(.markdown-table-wrapper) {
    max-width: 100%;
    padding: 0;
    background: transparent;
  }

  /* Style text content before/after tables */
  .bot-message .message-content:has(.markdown-table-wrapper) > :not(.markdown-table-wrapper) {
    padding: 12px 16px;
    background: #1a1a1a;
    border-radius: 12px;
    margin: 8px 16px;
  }

  .markdown-table-wrapper {
    /* Proper full-width breakout technique */
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    border-radius: 0;
    background: rgba(15, 15, 15, 0.95);
    border-top: 2px solid rgba(204, 0, 0, 0.4);
    border-bottom: 2px solid rgba(204, 0, 0, 0.4);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
    padding: 12px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-top: 0;
    margin-bottom: 0;
  }

  .bot-message .message-content .markdown-table {
    font-size: 0.7rem;
    table-layout: auto;
    width: auto;
    min-width: 100%;
  }

  .bot-message .message-content .markdown-table th,
  .bot-message .message-content .markdown-table td {
    font-size: 0.7rem;
    padding: 0.5rem 0.4rem;
    white-space: nowrap;
    min-width: 45px;
  }

  /* First column - rank/number */
  .bot-message .message-content .markdown-table th:first-child,
  .bot-message .message-content .markdown-table td:first-child {
    min-width: 35px;
    padding-left: 0.5rem;
    text-align: center;
  }

  /* Second column - team name (allow wrapping) */
  .bot-message .message-content .markdown-table th:nth-child(2),
  .bot-message .message-content .markdown-table td:nth-child(2) {
    min-width: 120px;
    max-width: 150px;
    white-space: normal;
    padding-right: 0.6rem;
    word-break: break-word;
  }

  /* Header styling */
  .bot-message .message-content .markdown-table thead th {
    font-size: 0.62rem;
    padding: 0.6rem 0.4rem;
    font-weight: 700;
    letter-spacing: 0.3px;
  }
}

/* Desktop: Traditional table */
@media (min-width: 769px) {
  .bot-message .message-content .markdown-table thead {
    background: rgba(204, 0, 0, 0.15);
  }

  .bot-message .message-content .markdown-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    color: #fff;
    border-bottom: 2px solid rgba(204, 0, 0, 0.3);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .bot-message .message-content .markdown-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #e5e5e5;
  }

  .bot-message .message-content .markdown-table tbody tr:hover {
    background: rgba(204, 0, 0, 0.08);
  }

  .bot-message .message-content .markdown-table tbody tr:last-child td {
    border-bottom: none;
  }
}

/* Recommended Questions */
.recommended-questions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 0;
  animation: fadeIn 0.3s ease;
}

.recommended-question {
  background: #1a1a1a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  color: #e5e5e5;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid #cc0000;
}

.recommended-question:hover {
  background: rgba(204, 0, 0, 0.1);
  border-color: #cc0000;
  transform: translateX(4px);
}

.recommended-question:active {
  transform: translateX(2px);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chatbot-input-container {
  display: flex;
  padding: 16px;
  background: #1a1a1a;
  border-top: 1px solid #333;
  gap: 8px;
}

.chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #333;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  background: #0f0f0f;
  outline: none;
  transition: all 0.2s;
}

.chatbot-input::placeholder {
  color: #666;
}

.chatbot-input:focus {
  border-color: #cc0000;
  box-shadow: 0 0 0 2px rgba(204, 0, 0, 0.1);
  background: #1a1a1a;
}

.chatbot-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #cc0000, #990000);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
}

.chatbot-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(204, 0, 0, 0.4);
}

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

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cc0000;
  animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.5;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Tool Execution Timeline Styles */
.tool-timeline-container {
  margin: 12px 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border-left: 3px solid #cc0000;
  overflow: hidden;
}

.tool-timeline-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.tool-timeline-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tool-timeline-header.completed {
  border-left-color: #4ade80;
}

.tool-timeline-header.error {
  border-left-color: #f87171;
}

.tool-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #cc0000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.tool-checkmark {
  font-size: 18px;
  color: #4ade80;
  font-weight: bold;
  flex-shrink: 0;
  animation: checkmarkPop 0.3s ease;
}

.tool-error {
  font-size: 18px;
  color: #f87171;
  font-weight: bold;
  flex-shrink: 0;
  animation: errorShake 0.5s ease;
}

.tool-chevron {
  margin-left: auto;
  transition: transform 0.3s ease;
  color: #666;
  flex-shrink: 0;
}

.tool-chevron.open {
  transform: rotate(180deg);
}

.tool-text {
  font-size: 15px;
  font-weight: 500;
  color: #e5e5e5;
  flex: 1;
}

.tool-timeline-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 16px;
}

.tool-timeline-body.open {
  max-height: 500px;
  padding: 0 16px 12px 16px;
}

.tool-timeline-items {
  position: relative;
  padding-left: 24px;
}

.tool-timeline-item {
  position: relative;
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.tool-timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20px;
  bottom: -8px;
  width: 2px;
  background: rgba(255, 255, 255, 0.1);
}

.tool-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.tool-timeline-item.active .tool-timeline-dot {
  background: #cc0000;
  box-shadow: 0 0 0 4px rgba(204, 0, 0, 0.2);
}

.tool-timeline-item.completed .tool-timeline-dot {
  background: #4ade80;
}

.tool-timeline-item.error .tool-timeline-dot {
  background: #f87171;
}

.tool-timeline-description {
  font-size: 14px;
  color: #999;
  flex: 1;
}

.tool-timeline-item.active .tool-timeline-description {
  color: #e5e5e5;
  font-weight: 500;
}

.tool-timeline-item.completed .tool-timeline-description {
  color: #4ade80;
  opacity: 0.8;
}

.tool-timeline-item.error .tool-timeline-description {
  color: #f87171;
}

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

@keyframes checkmarkPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes errorShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* Widget Styles - Minimal Design */
.widget-content {
  padding: 8px !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.widget-message .message-content {
  max-width: 95% !important;
  width: 100% !important;
  box-sizing: border-box;
}

.widget-title {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #333;
}

/* Game Schedule Widget */
.widget-schedule {
  font-size: 13px;
}

.schedule-games {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.schedule-game {
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  border-left: 2px solid #555;
}

.game-date {
  font-size: 12px;
  color: #999;
  margin-bottom: 3px;
}

.game-opponent {
  font-weight: 500;
  color: #fff;
  margin-bottom: 2px;
}

.game-location {
  font-size: 12px;
  color: #aaa;
}

.game-result {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
}

.game-result.won {
  color: #4ade80;
}

.game-result.lost {
  color: #f87171;
}

/* Table Widget */
.widget-table {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.widget-table::-webkit-scrollbar {
  height: 6px;
}

.widget-table::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.widget-table::-webkit-scrollbar-thumb {
  background: #555;
  border-radius: 3px;
}

.widget-table::-webkit-scrollbar-thumb:hover {
  background: #777;
}

.widget-table table {
  width: 100%;
  min-width: 500px; /* Prevent table from being too cramped */
  border-collapse: collapse;
  font-size: 12px;
}

.widget-table th {
  text-align: left;
  padding: 6px 4px;
  background: rgba(255, 255, 255, 0.05);
  color: #ccc;
  font-weight: 500;
  font-size: 11px;
  border-bottom: 1px solid #333;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.widget-table td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #d1d5db;
  font-size: 11px;
}

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

/* Highlight the first column (usually rank or team name) */
.widget-table td:first-child,
.widget-table th:first-child {
  position: sticky;
  left: 0;
  background: #1a1a1a;
  z-index: 2;
  font-weight: 500;
}

.widget-table th:first-child {
  z-index: 3;
  background: rgba(255, 255, 255, 0.05);
}

/* Stats Widget */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-item {
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  text-align: center;
}

.stat-label {
  font-size: 11px;
  color: #999;
  margin-bottom: 3px;
}

.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

/* List Widget */
.widget-list ul {
  margin: 0;
  padding-left: 18px;
  list-style: disc;
}

.widget-list li {
  margin: 5px 0;
  color: #d1d5db;
  font-size: 13px;
}

/* Info Card Widget */
.widget-info-card {
  font-size: 13px;
}

.info-content {
  color: #d1d5db;
  line-height: 1.5;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  /* On mobile, widget opens in dedicated page */
  .chatbot-container {
    display: none !important;
  }

  .chatbot-toggle {
    width: 56px;
    height: 56px;
  }

  /* Mobile-specific table adjustments */
  .widget-table table {
    min-width: 400px;
    font-size: 10px;
  }

  .widget-table th,
  .widget-table td {
    padding: 4px 2px;
    font-size: 10px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Small container adjustments */
@media (max-width: 400px) {
  .chatbot-container {
    width: calc(100vw - 40px);
    height: calc(100vh - 40px);
  }

  .widget-table table {
    min-width: 300px;
  }
}
