/* ARCADA Время - PWA Styles */

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

:root {
  --bg-dark: #0b0c0d;
  --bg-card: #121316cc;
  --text-primary: #f2f2f3;
  --text-secondary: #b9bcc1;
  --accent: #1976d2;
  --accent-hover: #1565c0;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #f59e0b;
  --border: rgba(255,255,255,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255,255,255,0.06), transparent 0%),
    linear-gradient(160deg, #0b0c0d 100%, #17191b 100%, #2a2d31 100%);
  min-height: 100dvh;
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
}

/* Screens */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.container { max-width: 920px; margin: 0 auto; padding: 20px; }
.container.narrow { max-width: 640px; }

/* Logo */
.logo {
  text-align: center;
  margin: 40px 0 30px;
  color: var(--text-primary);
}

.logo-img {
  width: 100px;
  height: auto;
  margin-bottom: 16px;
  image-rendering: -webkit-optimize-contrast;
}

.logo h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 4px;
}

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

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  gap: 12px;
}

.user-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

.info .name {
  font-weight: 700;
  font-size: 1rem;
}

.info .meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  margin-top: 16px;
}

.card h3 {
  margin-bottom: 14px;
  font-size: 1.1rem;
  font-weight: 700;
}

.muted { opacity: 0.7; text-align: center; padding: 20px 0; }

/* Today status */
.today-status .status-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.status-item {
  text-align: center;
  padding: 12px 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
}

.status-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.status-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

/* Home actions */
.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

/* Buttons */
.btn-primary, .btn-secondary {
  width: 100%;
  padding: 14px 18px;
  background: #2d3035;
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}

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

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active, .btn-secondary:active { transform: scale(0.98); opacity: 0.9; }

.small { width: auto; padding: 8px 14px; border-radius: 10px; font-size: 0.9rem; }
.big { padding: 18px; font-size: 1.1rem; }

/* Auth form */
.auth-form {
  background: #fff;
  color: #111;
  padding: 28px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.input-group { margin-bottom: 20px; }
.input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #333;
}

.input-group input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid #e1e5e9;
  border-radius: 10px;
  font-size: 1rem;
  color: #111;
  background: #fff;
  transition: border-color 0.2s;
}

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

.auth-footer {
  text-align: center;
  margin-top: 20px;
  color: #cfd1d4;
}

.error-message {
  color: var(--error);
  font-size: 0.9rem;
}

/* Scan screen */
.scan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 0;
  margin-bottom: 10px;
}

.scan-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.camera-container {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 16px;
}

.camera-container.tight { margin-top: 10px; }

#camera-preview {
  display: block;
  width: 100%;
  max-width: 640px;
  border-radius: 12px;
  background: #000;
}

.scan-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.scan-frame {
  border: 3px solid var(--error);
  border-radius: 12px;
  width: min(80vmin, 320px);
  height: min(80vmin, 320px);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.scan-frame.ok {
  border-color: var(--success);
  box-shadow: 0 0 0 9999px rgba(34,197,94,0.15);
}

.scan-frame.err {
  border-color: var(--error);
  box-shadow: 0 0 0 9999px rgba(239,68,68,0.15);
}

#scan-hint {
  position: absolute;
  bottom: 30px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.scan-status {
  text-align: center;
  padding: 14px 16px 24px;
  color: var(--text-secondary);
}

/* Result screen */
.result-container {
  max-width: 480px;
  margin: 30px auto;
  background: #fff;
  color: #111;
  border-radius: 16px;
  padding: 30px 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  text-align: center;
}

.result-icon {
  font-size: 56px;
  margin-bottom: 14px;
}

.result-container h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.result-container > p {
  color: #666;
  margin-bottom: 20px;
}

.result-details {
  background: #f6f7f8;
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  margin-bottom: 20px;
}

.result-details p {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.result-details p:last-child { margin-bottom: 0; }

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.result-actions .btn-primary,
.result-actions .btn-secondary {
  color: #fff;
}

.result-actions .btn-secondary {
  background: #6b7280;
  border-color: #6b7280;
  color: #fff;
}

/* Recent / History list */
.recent-list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: 10px;
}

.recent-item .item-info {
  flex: 1;
}

.recent-item .item-gate {
  font-weight: 600;
  margin-bottom: 2px;
}

.recent-item .item-time {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.recent-item .item-status {
  font-size: 1.3rem;
}

.recent-item .item-action {
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.recent-item .item-action.arrived {
  background: rgba(34,197,94,0.2);
  color: var(--success);
}

.recent-item .item-action.departed {
  background: rgba(239,68,68,0.2);
  color: var(--error);
}

/* Версия приложения */
.app-version {
  position: fixed;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.2);
  pointer-events: none;
  z-index: 10;
}

/* Баннер обновления */
.update-banner {
  position: fixed;
  bottom: 28px;
  left: 16px;
  right: 16px;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 500;
  box-shadow: 0 8px 30px rgba(25,118,210,0.5);
  font-size: 0.9rem;
  font-weight: 500;
}

.update-btn {
  background: #fff;
  color: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

/* Cooldown modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-box {
  background: #1a1c1f;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px 24px;
  text-align: center;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-ok {
  width: 100%;
  padding: 14px;
}

/* Date separator in history */
.date-separator {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 2px;
  margin-top: 4px;
}

/* Offline notification */
.offline-notification {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(100px);
  background: #2d3035;
  color: var(--text-primary);
  border-left: 5px solid var(--warning);
  border-radius: 12px;
  padding: 14px 20px;
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 9999;
}

.offline-notification.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Loading spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 480px) {
  .logo { margin: 30px 0 24px; }
  .logo-img { width: 80px; }
  .logo h2 { font-size: 1.5rem; }

  .today-status .status-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
  }

  .status-label { margin-bottom: 0; }

  .home-actions {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-top)) {
  .topbar {
    padding-top: calc(16px + env(safe-area-inset-top));
  }

  .offline-notification {
    bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
