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

:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --success-color: #10b981;
  --success-bg: #d1fae5;
  --error-color: #ef4444;
  --error-bg: #fee2e2;
  --border-color: #e5e7eb;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --bg-gray: #f9fafb;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 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);
}

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

/* Container */
.container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-height: 500px;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: var(--bg-gray);
  padding: 30px;
  border-bottom: 2px solid var(--border-color);
}

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

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  flex-wrap: wrap;
}

.controls label {
  font-weight: 500;
  color: var(--text-secondary);
}

.controls select {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.95rem;
  background: white;
  cursor: pointer;
}

/* Main Content */
main {
  flex: 1;
  padding: 30px;
}

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

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

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

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

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
}

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

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-gray);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #f3f4f6;
}

.btn-complete {
  background: var(--success-color);
  color: white;
  padding: 8px 16px;
  font-size: 0.9rem;
}

.btn-complete:hover {
  background: #059669;
}

/* Messages */
.message {
  padding: 16px;
  border-radius: 8px;
  margin-top: 20px;
  font-weight: 500;
}

.message.hidden {
  display: none;
}

.message.success {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid var(--success-color);
}

.message.error {
  background: var(--error-bg);
  color: #991b1b;
  border: 1px solid var(--error-color);
}

/* Queue Status Indicator */
.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: white;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  animation: pulse 2s ease-in-out infinite;
}

.status-connected .status-dot {
  background: var(--success-color);
}

.status-disconnected .status-dot,
.status-error .status-dot,
.status-failed .status-dot {
  background: var(--error-color);
  animation: none;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.queue-count {
  font-weight: 600;
  color: var(--primary-color);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.empty-state small {
  font-size: 0.95rem;
}

/* Queue List */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.queue-list.hidden,
.empty-state.hidden {
  display: none;
}

.queue-item {
  background: var(--bg-gray);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  transition: all 0.2s;
}

.queue-item:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow);
}

.queue-item-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.queue-position {
  background: var(--primary-color);
  color: white;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
}

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

.queue-item-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.wait-time {
  font-weight: 600;
  color: var(--primary-color);
}

/* Notification */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--primary-color);
  color: white;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateX(400px);
  transition: transform 0.3s ease;
  z-index: 1000;
}

.notification.show {
  transform: translateX(0);
}

.notification-icon {
  font-size: 1.25rem;
}

/* Analytics */
.analytics-content.hidden,
.loading.hidden {
  display: none;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background: var(--bg-gray);
  border: 2px solid var(--border-color);
  border-radius: 10px;
  padding: 24px;
  text-align: center;
}

.metric-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--primary-color);
}

.analytics-section {
  margin-bottom: 40px;
}

.analytics-section h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.peak-hours-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.peak-hour-item {
  background: var(--bg-gray);
  border-radius: 8px;
  padding: 16px;
}

.peak-hour-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.peak-hour-rank {
  background: var(--primary-color);
  color: white;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}

.peak-hour-time {
  font-weight: 600;
  flex: 1;
}

.peak-hour-count {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.peak-hour-bar-container {
  background: #e5e7eb;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.peak-hour-bar {
  background: var(--primary-color);
  height: 100%;
  transition: width 0.3s ease;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-gray);
  border-radius: 8px;
  overflow: hidden;
}

.stats-table th,
.stats-table td {
  padding: 12px 16px;
  text-align: left;
}

.stats-table thead {
  background: var(--primary-color);
  color: white;
}

.stats-table tbody tr {
  border-bottom: 1px solid var(--border-color);
}

.stats-table tbody tr:last-child {
  border-bottom: none;
}

.stats-table tbody tr:hover {
  background: white;
}

.empty-message {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 20px;
  font-size: 1rem;
}

/* Footer */
footer {
  background: var(--bg-gray);
  padding: 20px 30px;
  border-top: 2px solid var(--border-color);
}

footer nav {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

footer nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s;
}

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

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

  header {
    padding: 20px;
  }

  header h1 {
    font-size: 1.5rem;
  }

  main {
    padding: 20px;
  }

  .metric-value {
    font-size: 2rem;
  }

  .queue-item-header {
    flex-wrap: wrap;
  }

  .notification {
    left: 20px;
    right: 20px;
    transform: translateY(-100px);
  }

  .notification.show {
    transform: translateY(0);
  }
}
