/* CSS Variables */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --success-color: #16a34a;
  --error-color: #dc2626;
  --warning-color: #d97706;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-color: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* Header */
header {
  text-align: center;
  margin-bottom: 30px;
  padding: 20px 0;
}

header h1 {
  font-size: 2rem;
  color: var(--text-color);
  margin-bottom: 8px;
}

header h1::before {
  content: '🏏 ';
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.25rem;
  margin-bottom: 16px;
  color: var(--text-color);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
}

/* Form Styles */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-color);
}

.form-group input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Button Styles */
button {
  cursor: pointer;
  font-size: 1rem;
  border: none;
  border-radius: var(--border-radius);
  transition: all 0.2s;
}

#submit-btn {
  width: 100%;
  padding: 14px 24px;
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
}

#submit-btn:hover:not(:disabled) {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

#submit-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-loading[hidden] {
  display: none;
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Result Styles */
.result {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--border-radius);
}

.result-success {
  background-color: #f0fdf4;
  border: 1px solid #86efac;
}

.result-success h3 {
  color: var(--success-color);
  margin-bottom: 8px;
}

.result-error {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
}

.result-error h3 {
  color: var(--error-color);
  margin-bottom: 8px;
}

.stream-url {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  margin: 12px 0;
  word-break: break-all;
}

.stream-url a {
  flex: 1;
  color: var(--primary-color);
  font-family: monospace;
  font-size: 0.95rem;
}

.copy-btn {
  padding: 6px 12px;
  background: var(--primary-color);
  color: white;
  font-size: 0.85rem;
}

.copy-btn:hover {
  background: var(--primary-hover);
}

.listen-instructions {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.note {
  margin-top: 8px;
  color: var(--warning-color);
  font-size: 0.85rem;
}

/* Matches List */
.matches-list {
  list-style: none;
}

.matches-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 8px;
  background: var(--bg-color);
}

.match-info {
  flex: 1;
}

.match-info .project-name {
  font-weight: 600;
  color: var(--text-color);
}

.match-info .match-details {
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.match-actions button {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.listen-btn {
  background: var(--success-color);
  color: white;
}

.listen-btn:hover {
  background: #15803d;
}

.stop-btn {
  background: var(--error-color);
  color: white;
}

.stop-btn:hover {
  background: #b91c1c;
}

.no-matches {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

.refresh-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-color);
}

.refresh-btn:hover {
  background: var(--border-color);
}

/* Loading State */
.loading[hidden] {
  display: none;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Configuration Section */
.config-section {
  background: #f8fafc;
}

.config-item {
  margin-bottom: 12px;
}

.config-item label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.config-item code {
  display: inline-block;
  background: white;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  color: var(--primary-color);
}

.config-item input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.9rem;
}

.config-item small {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Info Section */
.steps {
  padding-left: 20px;
}

.steps li {
  margin-bottom: 12px;
  color: var(--text-color);
}

.steps li strong {
  color: var(--primary-color);
}

.tech-note {
  margin-top: 16px;
  padding: 12px;
  background: #fef3c7;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  color: #92400e;
}

/* Footer */
footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.version-tag {
  font-size: 0.75rem;
  margin-top: 4px;
  opacity: 0.7;
}

footer a {
  color: var(--primary-color);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 12px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 16px;
  }

  .matches-list li {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .match-actions {
    justify-content: stretch;
  }

  .match-actions button {
    flex: 1;
  }
}
