*,
*::before,
*::after {
  box-sizing: border-box;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes sendFloat {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

@keyframes printPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.08);
    opacity: 0.85;
  }
}

@keyframes dotPulse {
  0%,
  80%,
  100% {
    opacity: 0.25;
    transform: scale(0.85);
  }

  40% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes queueRefresh {
  from {
    opacity: 0.65;
  }

  to {
    opacity: 1;
  }
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: #f4f6f8;
  color: #1a1a1a;
  line-height: 1.5;
  animation: fadeIn 400ms ease-out;
}

.container {
  max-width: 480px;
  margin: 3rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  animation: fadeSlideUp 350ms ease-out;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: #555;
  font-size: 0.95rem;
}

.notice {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  color: #92400e;
  font-size: 0.9rem;
  animation: fadeSlideUp 300ms ease-out;
}

.notice-error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.printer-list {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.printer-list h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.printer-list ul {
  margin: 0;
  padding-left: 1.25rem;
}

.printer-list li {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
  word-break: break-all;
}

.container-wide {
  max-width: 900px;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.nav a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: color 200ms ease, opacity 200ms ease;
}

.nav a:hover {
  opacity: 0.8;
}

.nav a.active {
  color: #1a1a1a;
}

.nav-user {
  margin-left: auto;
  font-size: 0.8rem;
  color: #666;
  word-break: break-all;
}

.nav-logout {
  margin: 0;
}

.nav-logout-btn {
  margin: 0;
  padding: 0.25rem 0.625rem;
  background: transparent;
  color: #2563eb;
  border: 1px solid #2563eb;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 200ms ease, transform 200ms ease, box-shadow 200ms ease;
}

.nav-logout-btn:hover {
  background: #eff6ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}

.support-text {
  margin-top: 1.5rem;
  font-size: 0.85rem;
  color: #555;
}

.support-text a {
  color: #2563eb;
}

.login-form input[type="email"],
.login-form input[type="text"] {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.login-form input[type="email"]:focus,
.login-form input[type="text"]:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

.login-resend {
  margin: 1rem 0 0;
  font-size: 0.875rem;
}

.login-resend a {
  color: #2563eb;
}

.queue-filter {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.queue-group {
  margin-bottom: 1.5rem;
}

.queue-group h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  word-break: break-all;
}

.queue-table-wrap {
  overflow-x: auto;
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.queue-table th,
.queue-table td {
  padding: 0.5rem 0.625rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}

.queue-table th {
  background: #f9fafb;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #555;
}

.empty-state,
.queue-updated {
  margin: 0;
  color: #555;
  font-size: 0.9rem;
}

.queue-updated {
  margin-top: 1rem;
}

#queue-content.htmx-settling {
  animation: queueRefresh 300ms ease-out;
}

.print-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  font-weight: 600;
  font-size: 0.875rem;
}

input[type="file"],
select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

input[type="file"]:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

button {
  margin-top: 0.5rem;
  padding: 0.625rem 1rem;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 200ms ease, transform 200ms ease, box-shadow 200ms ease, opacity 200ms ease;
}

button:hover:not(:disabled) {
  background: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.htmx-request button[type="submit"] {
  opacity: 0.65;
  pointer-events: none;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.htmx-indicator {
  display: none;
  font-size: 0.875rem;
  color: #555;
}

.htmx-request .htmx-indicator {
  display: inline;
}

.status-indicator {
  display: none;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.625rem 0.875rem;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  color: #0369a1;
  font-size: 0.875rem;
}

.htmx-request .status-indicator {
  display: inline-flex;
}

.status-icon {
  display: inline-block;
  font-size: 1.1rem;
  line-height: 1;
}

.htmx-request .status-icon--send {
  animation: sendFloat 1.2s ease-in-out infinite;
}

.htmx-request .status-icon--verify {
  animation: printPulse 1.2s ease-in-out infinite;
}

.htmx-request .status-icon--print {
  animation: printPulse 1.2s ease-in-out infinite;
}

.status-text {
  font-weight: 600;
}

.status-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 0.125rem;
}

.status-dots i {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  font-style: normal;
  animation: dotPulse 1.2s ease-in-out infinite;
}

.status-dots i:nth-child(2) {
  animation-delay: 0.2s;
}

.status-dots i:nth-child(3) {
  animation-delay: 0.4s;
}

.htmx-swapping {
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.htmx-settling {
  animation: fadeSlideUp 250ms ease-out;
}

.result {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-size: 0.95rem;
  animation: fadeSlideUp 300ms ease-out;
}

.result p {
  margin: 0;
}

.result-success {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
}

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

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