/* ─── Reset & Variables ──────────────────────────────────────────────────── */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg:          #0f0f1a;
  --surface:     #1a1a2e;
  --border:      #2a2a4a;
  --text:        #eaeaea;
  --text-muted:  #7777aa;
  --primary:     #6c63ff;
  --primary-glow:rgba(108,99,255,0.35);
  --green:       #4caf50;
  --orange:      #ff9800;
  --red:         #f44336;
}

html {
  height: 100%;
}

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

/* ─── Auth Page ──────────────────────────────────────────────────────────── */

.page-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.5rem;
  text-align: center;
}

.auth-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  display: block;
}

.auth-title {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.auth-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#code-input {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  padding: 1rem;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}

#code-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: none;
}

#code-input:focus {
  border-color: var(--primary);
}

.error-msg {
  color: var(--red);
  font-size: 0.88rem;
  min-height: 1.2em;
}

.btn-primary {
  background: var(--primary);
  border: none;
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1rem;
  transition: opacity 0.15s, transform 0.1s;
  width: 100%;
}

.btn-primary:active {
  opacity: 0.8;
  transform: scale(0.97);
}

/* ─── Counter Page ───────────────────────────────────────────────────────── */

.page-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  overflow: hidden;
}

.counter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  height: 100vh;
  width: 100%;
  max-width: 480px;
  padding: 2rem 1.5rem;
}

/* ─── Shared counter elements ────────────────────────────────────────────── */

.room-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.count-display {
  text-align: center;
  line-height: 1;
}

.count-number {
  font-size: 6rem;
  font-weight: 800;
  color: var(--text);
  display: block;
  line-height: 1;
  transition: transform 0.1s;
}

.count-fraction {
  font-size: 1.4rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

.gauge-container {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.35s ease, background-color 0.35s ease;
}

.gauge-fill.green  { background: var(--green); }
.gauge-fill.orange { background: var(--orange); }
.gauge-fill.red    { background: var(--red); }

.status {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  transition: color 0.3s;
}

.status.green  { color: var(--green); }
.status.orange { color: var(--orange); }
.status.red    { color: var(--red); }

.btn-row {
  display: flex;
  gap: 3rem;
  align-items: center;
  justify-content: center;
}

.btn-count {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 2.8rem;
  font-weight: 300;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.15s;
  user-select: none;
  touch-action: manipulation;
}

.btn-minus {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.btn-plus {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 24px var(--primary-glow);
}

.btn-count:active {
  transform: scale(0.88);
  box-shadow: none;
}

/* Ripple */
.btn-count::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  transform: scale(0);
  opacity: 0;
  transition: transform 0.5s ease-out, opacity 0.5s ease-out;
}

.btn-count:active::after {
  transform: scale(2.5);
  opacity: 0;
  transition: none;
}

.agents-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ─── Admin Page ─────────────────────────────────────────────────────────── */

.page-admin {
  overflow-y: auto;
  min-height: 100vh;
}

.admin-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Mini counter card in admin */
.admin-counter-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.count-display--sm {}

.count-number--sm {
  font-size: 4rem;
}

.btn-row--sm {
  gap: 2rem;
}

.btn-count--sm {
  width: 80px;
  height: 80px;
  font-size: 2.2rem;
}

/* Admin form sections */
.admin-section {
  background: var(--surface);
  border-radius: 16px;
  padding: 1.25rem;
}

.section-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.section-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  margin-top: -0.5rem;
}

.form-group {
  margin-bottom: 0.9rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-group input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition: border-color 0.2s;
}

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

/* Admin action buttons */
.admin-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.btn-save {
  background: var(--primary);
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.95rem;
  width: 100%;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-save:active {
  opacity: 0.8;
  transform: scale(0.98);
}

.btn-reset {
  background: transparent;
  border: 2px solid var(--red);
  border-radius: 12px;
  color: var(--red);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.85rem;
  width: 100%;
  transition: background 0.15s;
}

.btn-reset:active {
  background: rgba(244,67,54,0.12);
}

.btn-logout {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.5rem;
  text-decoration: underline;
  align-self: center;
}

/* ─── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(5rem);
  background: #2e2e4e;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  pointer-events: none;
  transition: transform 0.3s ease;
  white-space: nowrap;
  z-index: 999;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
