/**
 * Secret Santa Styles
 * Responsive, festive design
 */

/* CSS Variables */
:root {
  --primary-color: #c41e3a;
  --primary-dark: #9a1829;
  --secondary-color: #165b33;
  --secondary-dark: #0f4024;
  --accent-color: #f4c430;
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --text-color: #212529;
  --text-muted: #6c757d;
  --border-color: #dee2e6;
  --error-color: #dc3545;
  /* Darkened from #28a745 so white text meets WCAG 1.4.3 AA (4.5:1); the old
     value was ~3.1:1. This variable is only ever used as a badge background. */
  --success-color: #157347;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

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

/* Visually hidden but available to screen readers — used for the live status
   region and any label text that should not be shown visually. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background: linear-gradient(135deg, var(--bg-color) 0%, #e9ecef 100%);
  min-height: 100vh;
  padding: 20px;
}

/* Container */
.container {
  max-width: 600px;
  margin: 0 auto;
}

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

header h1 {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 5px;
}

header h2 {
  font-size: 1.25rem;
  color: var(--text-muted);
  font-weight: 400;
}

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

.card h3 {
  color: var(--secondary-color);
  margin-bottom: 20px;
  font-size: 1.5rem;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-color);
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.3s;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

textarea {
  resize: vertical;
  font-family: 'Courier New', monospace;
  min-height: 100px;
}

.help-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* Radio Button Group */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.radio-option {
  background: var(--bg-color);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.radio-option:hover {
  background: #f0f8ff;
  border-color: var(--primary-color);
}

.radio-option input[type="radio"] {
  margin-top: 3px;
  cursor: pointer;
  flex-shrink: 0;
}

.radio-option input[type="radio"]:checked {
  accent-color: var(--primary-color);
}

.radio-option:has(input[type="radio"]:checked) {
  background: #e7f3ff;
  border-color: var(--primary-color);
}

.radio-option label {
  cursor: pointer;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  font-weight: normal;
}

.radio-option label strong {
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 600;
}

.radio-option .help-text {
  margin-top: 0;
}

/* Token Input */
.token-container {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.token-input {
  width: 50px;
  height: 60px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  text-transform: uppercase;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s;
}

.token-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(196, 30, 58, 0.1);
  transform: scale(1.05);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  font-family: inherit;
}

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

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

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

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

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

.btn-secondary:hover {
  background: var(--secondary-dark);
}

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

.btn-danger:hover {
  background: #c82333;
}

.button-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.button-group .btn {
  flex: 1;
  min-width: 150px;
}

/* Messages */
.error-message,
.success-message {
  padding: 12px;
  border-radius: 8px;
  margin-top: 15px;
  font-weight: 500;
}

.error-message {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.success-message {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

/* Info Box */
.info-box {
  background: #e7f3ff;
  border-left: 4px solid #0066cc;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.info-box h4 {
  color: var(--secondary-color);
  margin-bottom: 10px;
}

.info-box ul {
  margin-left: 20px;
}

.info-box li {
  margin-bottom: 8px;
}

.info-box code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}

/* Status Badge */
.status-badge {
  display: inline-block;
  background: var(--success-color);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  margin-bottom: 20px;
}

/* Event Info */
.event-info {
  background: var(--bg-color);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.event-info p {
  margin-bottom: 8px;
}

.event-info p:last-child {
  margin-bottom: 0;
}

/* Shareable URL Box */
.shareable-url-box {
  background: #e7f3ff;
  border: 2px solid #0066cc;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 30px;
}

.url-display {
  display: flex;
  gap: 10px;
  margin: 10px 0;
}

.url-display input {
  flex: 1;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  background: white;
}

.url-display input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.url-display button {
  white-space: nowrap;
}

/* Result Card */
.result-card {
  text-align: center;
}

.result-header {
  font-size: 1.75rem;
  color: var(--secondary-color);
  margin-bottom: 30px;
  font-weight: 600;
}

.result-body {
  margin-bottom: 30px;
}

.result-label {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 15px;
}

.result-name {
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--primary-color);
  padding: 20px;
  background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
  border-radius: 12px;
  border: 3px solid var(--primary-color);
}

/* Name Selection List (First-time setup) */
.name-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 15px;
}

.name-btn {
  padding: 12px;
  background: var(--bg-color);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
}

.name-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

/* Participant Password List (Admin) */
.participant-password-list {
  margin-top: 20px;
}

.participant-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  margin-bottom: 10px;
  background: var(--bg-color);
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
  gap: 15px;
}

.participant-name {
  font-weight: 600;
  font-size: 1.1rem;
  flex: 1;
}

.participant-status {
  flex: 1;
  text-align: center;
}

.status-badge-success {
  display: inline-block;
  background: var(--success-color);
  color: white;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.875rem;
  font-weight: 600;
}

.status-badge-pending {
  display: inline-block;
  background: #ffc107;
  color: #000;
  padding: 6px 12px;
  border-radius: 15px;
  font-size: 0.875rem;
  font-weight: 600;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.admin-result {
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  font-size: 1.25rem;
  text-align: center;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow: auto;
}

.modal-content {
  background-color: var(--card-bg);
  margin: 50px auto;
  padding: 0;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s;
}

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

.modal-header {
  padding: 20px 30px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: var(--secondary-color);
}

.close-btn {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text-color);
}

.modal-body {
  padding: 30px;
  max-height: 400px;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px 30px;
  border-top: 1px solid var(--border-color);
  text-align: right;
}

.assignments-list {
  list-style: none;
}

.assignment-item {
  padding: 15px;
  margin-bottom: 10px;
  background: var(--bg-color);
  border-radius: 8px;
  border-left: 4px solid var(--primary-color);
}

/* Footer */
footer {
  text-align: center;
  margin-top: 30px;
  color: var(--text-muted);
}

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

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

/* Responsive Design */
@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  header h1 {
    font-size: 2rem;
  }

  header h2 {
    font-size: 1rem;
  }

  .card {
    padding: 20px;
  }

  .token-input {
    width: 40px;
    height: 50px;
    font-size: 1.25rem;
  }

  .result-name {
    font-size: 2rem;
  }

  .participant-list {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    width: 100%;
  }

  .modal-content {
    width: 95%;
    margin: 20px auto;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
input:focus,
textarea:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
