/* AI Chess Teacher Styles - Mobile-First Design */

/* Chat Container */
.ai-chess-teacher-container {
  position: relative;
  width: 100%;
  max-height: 400px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  overflow: hidden;
  margin-bottom: 15px;
}

.ai-chess-teacher-container.collapsed {
  max-height: 48px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Header */
.ai-chess-teacher-header {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.ai-header-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.ai-icon {
  font-size: 22px;
}

.ai-title {
  font-weight: 600;
  font-size: 16px;
}

.ai-status {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.2);
  margin-left: auto;
}

.ai-status.connected {
  background: rgba(76, 175, 80, 0.3);
  color: #a8e6a3;
}

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

.ai-btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.ai-btn-icon:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Body */
.ai-chess-teacher-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.ai-chess-teacher-container.collapsed .ai-chess-teacher-body {
  display: none;
}

/* Chat Messages */
.ai-chess-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8f9fa;
  min-height: 200px;
  max-height: 350px;
}

.ai-message {
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease;
}

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

.ai-message-content {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ai-message-user .ai-message-content {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-content {
  background: white;
  color: #333;
  border: 1px solid #e0e0e0;
  border-bottom-left-radius: 4px;
}

.ai-message.error .ai-message-content {
  background: #ffebee;
  color: #c62828;
  border-color: #ef9a9a;
}

.ai-message.typing .ai-message-content {
  opacity: 0.7;
  font-style: italic;
}

/* Clickable chess moves in commentary */
.ai-clickable-move {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  background: #e3f2fd;
  color: #1976d2;
  font-weight: 700;
  font-family: 'SF Mono', Monaco, 'Consolas', monospace;
  transition: all 0.2s;
  display: inline-block;
  margin: 0 2px;
  border: 1px solid #90caf9;
  text-decoration: underline;
  text-decoration-color: rgba(25, 118, 210, 0.3);
  text-underline-offset: 2px;
  /* Better touch target */
  min-width: 32px;
  text-align: center;
  /* Touch feedback */
  -webkit-tap-highlight-color: rgba(102, 126, 234, 0.3);
  user-select: none;
  -webkit-user-select: none;
}

.ai-clickable-move:hover {
  background: #667eea;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
  border-color: #667eea;
  text-decoration-color: rgba(255, 255, 255, 0.5);
}

.ai-clickable-move:active {
  transform: translateY(0);
  background: #5568d3;
  box-shadow: 0 1px 3px rgba(102, 126, 234, 0.5);
}

/* Quick Actions */
.ai-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.ai-quick-btn {
  padding: 8px 12px;
  border: 1px solid #667eea;
  background: white;
  color: #667eea;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-quick-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-1px);
}

#explain-position-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  grid-column: 1 / -1;
}

#explain-position-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Input Container */
.ai-input-container {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.ai-chess-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border 0.2s;
}

.ai-chess-input:focus {
  border-color: #667eea;
}

.ai-send-btn {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.ai-send-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Modal Styles */
.ai-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s;
}

.ai-modal-content {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.ai-modal-header {
  background: linear-gradient(135deg, #2c3e50, #34495e);
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 16px 16px 0 0;
}

.ai-modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.ai-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ai-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.ai-modal-body {
  padding: 20px;
}

.ai-setting-group {
  margin-bottom: 20px;
}

.ai-setting-group label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
  color: #333;
}

.ai-setting-group h4 {
  font-size: 15px;
  margin-bottom: 10px;
  color: #333;
}

.ai-select, .ai-input-text {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border 0.2s;
}

.ai-select:focus, .ai-input-text:focus {
  outline: none;
  border-color: #667eea;
}

.ai-help-text {
  display: block;
  font-size: 12px;
  color: #666;
  margin-top: 6px;
  line-height: 1.4;
}

.ai-help-list {
  margin: 10px 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.8;
}

.ai-help-list a {
  color: #667eea;
  text-decoration: none;
}

.ai-help-list a:hover {
  text-decoration: underline;
}

.ai-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.ai-btn {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
}

.ai-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.ai-btn-secondary:hover {
  background: #d0d0d0;
}

/* Backdrop for mobile */
.ai-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s;
}

.ai-backdrop.visible {
  display: block;
  opacity: 1;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .ai-chess-teacher-container {
    width: 100%;
    max-height: 60vh;
    margin-bottom: 10px;
  }
  
  .ai-chess-teacher-container.collapsed {
    max-height: 48px;
  }
  
  .ai-chess-teacher-header {
    padding: 10px 12px;
  }
  
  .ai-title {
    font-size: 14px;
  }
  
  .ai-icon {
    font-size: 20px;
  }
  
  .ai-status {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  .ai-chess-chat-messages {
    max-height: 50vh;
    padding: 12px;
  }
  
  .ai-message-content {
    font-size: 13px;
    padding: 8px 12px;
  }
  
  .ai-quick-actions {
    padding: 10px 12px;
    gap: 6px;
  }
  
  .ai-quick-btn {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  .ai-input-container {
    padding: 10px 12px;
  }
  
  .ai-chess-input {
    font-size: 16px;
    padding: 8px 10px;
  }
  
  .ai-send-btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .ai-modal-content {
    width: 95%;
  }
  
  .ai-modal-header {
    padding: 12px 16px;
  }
  
  .ai-modal-header h3 {
    font-size: 16px;
  }
  
  .ai-modal-body {
    padding: 16px;
  }
}

/* Very small mobile screens */
@media (max-width: 480px) {
  .ai-quick-actions {
    grid-template-columns: 1fr;
  }
  
  #explain-position-btn {
    grid-column: 1;
  }
}
