/* ============================================================
   QR Carts — Mobile App Styles
   ============================================================ */

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ── Header ── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color-light);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.app-header .logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  color: white;
}

.app-header .logo-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-lg);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  background: var(--color-primary-alpha);
  color: var(--color-primary);
}

/* ── Main Content ── */
.app-content {
  flex: 1;
  padding: var(--space-lg);
  padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + var(--space-lg));
  overflow-y: auto;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-height) + var(--safe-area-bottom));
  padding-bottom: var(--safe-area-bottom);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color-light);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: var(--z-sticky);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-sm) var(--space-md);
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.nav-item .nav-icon {
  font-size: 22px;
  transition: transform var(--transition-fast);
}

.nav-item.active {
  color: var(--color-primary);
}

.nav-item.active .nav-icon {
  transform: scale(1.1);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--color-primary);
  border-radius: 0 0 var(--radius-full) var(--radius-full);
}

.nav-item:active {
  transform: scale(0.95);
}

/* ── Login View ── */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: var(--space-xl);
  text-align: center;
}

.login-hero {
  margin-bottom: var(--space-2xl);
}

.login-hero .hero-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: white;
  margin: 0 auto var(--space-lg);
  box-shadow: 0 8px 32px hsla(234, 85%, 55%, 0.3);
}

.login-hero h1 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-sm);
}

.login-hero p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.login-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.otp-input-group {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.otp-input-group input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.otp-input-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha);
  outline: none;
}

.otp-info {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.otp-resend {
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
}

.otp-resend:disabled {
  color: var(--text-tertiary);
  cursor: not-allowed;
}

/* ── Scanner View ── */
.scanner-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.scanner-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: hsl(0, 0%, 5%);
  box-shadow: var(--shadow-lg);
}

.scanner-viewport video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

.scanner-frame {
  width: 220px;
  height: 220px;
  position: relative;
}

.scanner-frame::before,
.scanner-frame::after {
  content: '';
  position: absolute;
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-primary);
}

.scanner-frame::before {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
  border-radius: 4px 0 0 0;
}

.scanner-frame::after {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
  border-radius: 0 4px 0 0;
}

.scanner-frame-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
}

.scanner-frame-bottom::before,
.scanner-frame-bottom::after {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-primary);
}

.scanner-frame-bottom::before {
  border-right: none;
  border-top: none;
  border-radius: 0 0 0 4px;
}

.scanner-frame-bottom::after {
  border-left: none;
  border-top: none;
  border-radius: 0 0 4px 0;
}

.scanner-line {
  position: absolute;
  left: 10%;
  right: 10%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
  animation: scanner-sweep 2s ease-in-out infinite;
  box-shadow: 0 0 8px var(--color-primary);
}

@keyframes scanner-sweep {
  0%, 100% { top: 20%; }
  50% { top: 80%; }
}

.scanner-hint {
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* ── Cart Preview (after scan) ── */
.cart-preview {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-primary);
  padding: var(--space-lg);
  animation: slide-up 300ms ease;
}

.cart-preview .cart-code {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-primary);
  letter-spacing: 0.1em;
}

.cart-preview .cart-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-xs) var(--space-md);
  margin: var(--space-md) 0;
  font-size: var(--text-sm);
}

.cart-preview .cart-details dt {
  color: var(--text-tertiary);
  font-weight: 500;
}

.cart-preview .cart-details dd {
  color: var(--text-primary);
}

.cart-preview .preview-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── History View ── */
.scan-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.scan-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color-light);
  transition: all var(--transition-fast);
}

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

.scan-item .scan-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-primary-alpha);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  flex-shrink: 0;
}

.scan-item .scan-info {
  flex: 1;
  min-width: 0;
}

.scan-item .scan-code {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.scan-item .scan-name {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-item .scan-time {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ── Stats View ── */
.stats-grid {
  display: grid;
  gap: var(--space-md);
}

.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color-light);
  padding: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  transition: all var(--transition-base);
}

.stat-card:first-child {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border-color: transparent;
  color: white;
}

.stat-card:first-child .stat-label {
  color: hsla(0, 0%, 100%, 0.8);
}

.stat-card:first-child .stat-count {
  color: white;
}

.stat-card:first-child .stat-icon {
  background: hsla(0, 0%, 100%, 0.2);
  color: white;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-primary-alpha);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.stat-info {
  flex: 1;
}

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

.stat-count {
  font-family: var(--font-heading);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-top: var(--space-xs);
}

/* ── Section headers ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.section-header h2 {
  font-size: var(--text-xl);
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-lg);
  text-align: center;
  color: var(--text-tertiary);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state p {
  font-size: var(--text-sm);
  max-width: 240px;
}

/* ── Success animation overlay ── */
.success-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-overlay);
  animation: fade-in 200ms ease;
}

.success-overlay .success-content {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  text-align: center;
  animation: pop-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-overlay .success-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-success-light);
  color: var(--color-success);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto var(--space-md);
}

.success-overlay h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-xs);
}

.success-overlay p {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}
