/* ================================================================
   Visitenkarten Scanner – Styles
   ================================================================ */

:root {
  --color-primary: #FF6F43;
  --color-primary-dark: #e85a2f;
  --color-primary-light: #fff1ec;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-danger: #dc2626;
  --color-bg: #f1f5f9;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-text-secondary: #64748b;
  --color-border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: var(--color-text);
  background: var(--color-bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ----------------------------------------------------------------
   PIN screen
   ---------------------------------------------------------------- */
.pin-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px 32px calc(24px + var(--safe-bottom));
  background: var(--color-bg);
  text-align: center;
}

.pin-logo {
  height: 28px;
  width: auto;
  margin-bottom: 4px;
}

.pin-content h2 {
  font-size: 1.3rem;
}

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

.pin-dots {
  display: flex;
  gap: 16px;
  margin: 16px 0 20px;
}

.pin-dots.shake {
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
}

.pin-dot.filled {
  background: var(--color-primary);
  border-color: var(--color-primary);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 260px;
}

.pad-key {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  font-size: 1.4rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.pad-key:active {
  background: var(--color-border);
  transform: scale(0.95);
}

.pad-spacer {
  background: transparent;
  cursor: default;
}

.pad-spacer:active {
  background: transparent;
  transform: none;
}

.pad-delete {
  color: var(--color-text-secondary);
}

.pad-delete svg {
  width: 22px;
  height: 22px;
}

/* ----------------------------------------------------------------
   Screens
   ---------------------------------------------------------------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1;
  overflow-x: hidden;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

/* ----------------------------------------------------------------
   Top bar
   ---------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 20;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.topbar-logo {
  height: 20px;
  width: auto;
}

/* ----------------------------------------------------------------
   Icon buttons
   ---------------------------------------------------------------- */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  color: var(--color-text);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: var(--color-border);
}

/* ----------------------------------------------------------------
   Camera screen
   ---------------------------------------------------------------- */
.camera-container {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
}

#camera-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.scan-frame {
  position: relative;
  width: 85%;
  max-width: 400px;
  aspect-ratio: 1.75 / 1;
  border: none;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
  transition: box-shadow 0.3s ease;
}

/* Corner markers */
.scan-frame::before,
.scan-frame::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, 0.85);
  border-style: solid;
  transition: border-color 0.3s ease;
}

.scan-frame::before {
  top: 0;
  left: 0;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}

.scan-frame::after {
  top: 0;
  right: 0;
  border-width: 3px 3px 0 0;
  border-radius: 0 4px 0 0;
}

.scan-corners-bottom {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scan-corners-bottom::before,
.scan-corners-bottom::after {
  content: "";
  position: absolute;
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, 0.85);
  border-style: solid;
  transition: border-color 0.3s ease;
}

.scan-corners-bottom::before {
  bottom: 0;
  left: 0;
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 4px;
}

.scan-corners-bottom::after {
  bottom: 0;
  right: 0;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}

/* Scanning line animation */
.scan-line {
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
  opacity: 0.8;
  top: 0;
  animation: scanMove 2s ease-in-out infinite;
}

@keyframes scanMove {
  0%, 100% { top: 8px; }
  50% { top: calc(100% - 10px); }
}

/* Scan hint text */
.scan-hint {
  position: absolute;
  bottom: -32px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.3s ease;
}

/* Active detection state */
.scan-frame.detecting::before,
.scan-frame.detecting::after,
.scan-frame.detecting .scan-corners-bottom::before,
.scan-frame.detecting .scan-corners-bottom::after {
  border-color: var(--color-primary);
}

.scan-frame.detecting .scan-hint {
  color: var(--color-primary);
}

.scan-frame.captured::before,
.scan-frame.captured::after,
.scan-frame.captured .scan-corners-bottom::before,
.scan-frame.captured .scan-corners-bottom::after {
  border-color: var(--color-success);
}

.scan-frame.captured .scan-line {
  display: none;
}

.camera-controls {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 20px 32px calc(20px + var(--safe-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.capture-btn {
  position: relative;
  width: 68px;
  height: 68px;
  border: none;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  transition: transform 0.1s;
}

.capture-btn:active {
  transform: scale(0.92);
}

.capture-ring {
  position: absolute;
  inset: -5px;
  border: 3px solid rgba(255, 111, 67, 0.5);
  border-radius: 50%;
}

.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--color-text);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s;
}

.upload-btn:hover {
  background: var(--color-border);
}

/* ----------------------------------------------------------------
   Loading screen
   ---------------------------------------------------------------- */
.loading-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--color-bg);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 1.05rem;
  color: var(--color-text-secondary);
}

/* ----------------------------------------------------------------
   Results screen
   ---------------------------------------------------------------- */
.results-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  background: var(--color-bg);
}

.card-preview {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-preview img {
  width: 100%;
  display: block;
  max-height: 200px;
  object-fit: cover;
}

.results-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

.form-row.two-col .form-group {
  min-width: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-group input,
.form-group textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color 0.15s;
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-group textarea {
  resize: vertical;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

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

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

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

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

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

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.results-actions .btn {
  width: 100%;
}

/* ----------------------------------------------------------------
   Success screen
   ---------------------------------------------------------------- */
.success-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  background: var(--color-bg);
  text-align: center;
}

.success-icon {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-success-light);
  color: var(--color-success);
  border-radius: 50%;
}

.success-content h2 {
  font-size: 1.4rem;
}

.success-content p {
  color: var(--color-text-secondary);
  max-width: 280px;
}

.success-content .btn {
  margin-top: 8px;
}

/* ----------------------------------------------------------------
   Modal
   ---------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.modal-content {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: var(--color-surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.modal.open .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  font-size: 1.2rem;
}

.modal-body {
  margin-bottom: 20px;
}

.employee-info {
  text-align: center;
  padding: 12px 0;
}

.employee-label {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.employee-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.btn-logout {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

.btn-logout:hover {
  background: #fef2f2;
}

/* ----------------------------------------------------------------
   Compliment Easter Egg
   ---------------------------------------------------------------- */
#screen-compliment {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 30%, #f093fb 60%, #FF6F43 100%);
  background-size: 300% 300%;
  animation: gradientShift 6s ease infinite;
}

.compliment-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: sparkleFloat 3s ease-in-out infinite;
}

.sparkle-1 { top: 15%; left: 10%; animation-delay: 0s; width: 5px; height: 5px; }
.sparkle-2 { top: 25%; right: 15%; animation-delay: 0.5s; width: 4px; height: 4px; }
.sparkle-3 { top: 60%; left: 20%; animation-delay: 1s; width: 6px; height: 6px; }
.sparkle-4 { top: 70%; right: 10%; animation-delay: 1.5s; width: 3px; height: 3px; }
.sparkle-5 { top: 40%; left: 5%; animation-delay: 2s; width: 5px; height: 5px; }
.sparkle-6 { top: 85%; right: 25%; animation-delay: 2.5s; width: 4px; height: 4px; }

@keyframes sparkleFloat {
  0% { opacity: 0; transform: translateY(0) scale(0); }
  20% { opacity: 1; transform: translateY(-10px) scale(1); }
  50% { opacity: 1; transform: translateY(-25px) scale(1.2); }
  80% { opacity: 0.5; transform: translateY(-40px) scale(0.8); }
  100% { opacity: 0; transform: translateY(-60px) scale(0); }
}

.compliment-content {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 32px 24px calc(32px + var(--safe-bottom));
  text-align: center;
}

.compliment-photo {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 60px rgba(255, 255, 255, 0.15);
  animation: photoEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes photoEntrance {
  0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.compliment-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.compliment-bubble {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 24px 28px;
  max-width: 340px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  animation: bubbleEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s both;
  position: relative;
}

.compliment-bubble::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid rgba(255, 255, 255, 0.95);
}

@keyframes bubbleEntrance {
  0% { opacity: 0; transform: translateY(20px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.compliment-bubble p {
  font-size: 1.1rem;
  line-height: 1.6;
  color: #1a1a2e;
  font-weight: 500;
}

.compliment-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  animation: bubbleEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.5s both;
}

.compliment-btn {
  background: rgba(255, 255, 255, 0.95);
  color: #764ba2;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  animation: bubbleEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.7s both;
}

.compliment-btn:hover {
  background: #fff;
}

/* ----------------------------------------------------------------
   Toast
   ---------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  background: var(--color-text);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

.toast.success {
  background: var(--color-success);
}
