/* Modern Dashboard Styles */
:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --bg-gradient-start: #f8fafc;
  --bg-gradient-end: #e0e7ff;
  --card-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --card-shadow-hover: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

body {
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Header */
.dashboard-header {
  background: white;
  padding: 1.5rem 0;
  box-shadow: var(--card-shadow);
  margin-bottom: 2rem;
}

.dashboard-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1e293b;
}

/* Cards */
.card {
  border: none;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.control-panel {
  background: white;
}

.chart-container {
  background: white;
  min-height: 500px;
}

.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

/* Name Input Groups */
.name-input-group {
  position: relative;
  display: inline-block;
}

.name-input {
  min-width: 200px;
  padding-right: 32px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  transition: border-color 0.2s ease;
}

.name-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.btn-remove {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.btn-remove:hover {
  opacity: 1;
}

/* Buttons */
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-outline-success {
  border-radius: 8px;
  font-weight: 500;
}

/* Chart Placeholder */
#chart-placeholder {
  padding: 4rem 2rem;
}

#name-chart {
  min-height: 500px;
}

/* Stats Panel */
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

/* Form Elements */
.form-select, .form-control {
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  padding: 0.625rem 0.875rem;
}

.form-select:focus, .form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-label {
  color: #334155;
  margin-bottom: 0.5rem;
}

/* Chat Panel */
.chat-panel {
  background: white;
}

.chat-messages {
  max-height: 300px;
  overflow-y: auto;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.chat-message {
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease;
}

.chat-message:last-child {
  margin-bottom: 0;
}

.message-content {
  display: inline-block;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  max-width: 85%;
  word-wrap: break-word;
}

.user-message .message-content {
  background: var(--primary-color);
  color: white;
  margin-left: auto;
  float: right;
  clear: both;
}

.assistant-message .message-content {
  background: white;
  color: #334155;
  border: 1px solid #e2e8f0;
  float: left;
  clear: both;
}

.chat-input-container {
  position: relative;
}

#chat-input {
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  padding: 0.625rem 0.875rem;
}

#chat-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

#send-chat {
  border-radius: 0 8px 8px 0;
}

.chat-message.loading .message-content {
  background: white;
  border: 1px solid #e2e8f0;
}

.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 0.5rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-color);
  animation: typing 1.4s infinite;
}

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

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

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

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

/* Footer */
footer {
  padding-bottom: 2rem;
}

footer a {
  color: var(--primary-color);
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--primary-hover);
}

/* Year Range Slider */
#year-slider {
  height: 8px;
  margin: 0 10px;
}

.noUi-target {
  background: #e2e8f0;
  border: none;
  border-radius: 4px;
  box-shadow: none;
}

.noUi-connect {
  background: var(--primary-color);
  border-radius: 4px;
}

.noUi-handle {
  width: 20px !important;
  height: 20px !important;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--primary-color);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: grab;
  top: -6px !important;
  right: -10px !important;
}

.noUi-handle:before,
.noUi-handle:after {
  display: none;
}

.noUi-handle:hover {
  background: #f8fafc;
  transform: scale(1.1);
}

.noUi-handle:active {
  cursor: grabbing;
}

.noUi-horizontal .noUi-handle {
  right: -10px !important;
}

#year-range-label {
  font-weight: 600;
  color: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
  .dashboard-header h1 {
    font-size: 1.5rem;
  }

  .name-input {
    min-width: 100%;
  }

  #name-container {
    flex-direction: column;
  }

  .name-input-group {
    width: 100%;
  }
}
