/* ============================================
   PDF Scanner - Desktop Styles
   Modern dark theme with glassmorphism
   ============================================ */

:root {
  /* Colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);

  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);

  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);

  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  --border-color: rgba(255, 255, 255, 0.08);
  --glow: 0 0 40px rgba(99, 102, 241, 0.3);

  /* Spacing */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background decoration */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.1) 0%, transparent 40%);
  animation: backgroundPulse 15s ease-in-out infinite alternate;
  pointer-events: none;
  z-index: -1;
}

@keyframes backgroundPulse {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  100% {
    transform: translate(-5%, -5%) rotate(5deg);
  }
}

/* App Container */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px);
  margin-bottom: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 600;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent-primary);
}

.session-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.connected {
  background: var(--success);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* Main Content */
.main-content {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 32px;
}

@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

/* QR Section */
.qr-section {
  position: sticky;
  top: 24px;
  height: fit-content;
}

.qr-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px;
  text-align: center;
  backdrop-filter: blur(20px);
}

.qr-card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.qr-subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 24px;
  line-height: 1.5;
}

.qr-container {
  width: 280px;
  height: 280px;
  margin: 0 auto 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.qr-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent-gradient);
  opacity: 0.1;
  border-radius: var(--radius-lg);
}

.qr-container img {
  width: 240px;
  height: 240px;
  position: relative;
  z-index: 1;
}

.qr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.mobile-url {
  font-size: 0.75rem;
  color: var(--text-muted);
  word-break: break-all;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
}

/* Gallery Section */
.gallery-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.image-count {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
}

.gallery-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 32px;
  min-height: 400px;
  backdrop-filter: blur(20px);
}

.gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-muted);
  text-align: center;
}

.gallery-empty svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.gallery-empty p {
  font-size: 1.125rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.gallery-empty span {
  font-size: 0.875rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  background: var(--bg-secondary);
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--glow);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: flex-end;
  padding: 12px;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-number {
  width: 28px;
  height: 28px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

/* PDF Controls */
.pdf-controls {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(99, 102, 241, 0.4);
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-muted);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.active {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

.modal-content {
  position: relative;
  max-width: 800px;
  max-height: 90vh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl);
  overflow: hidden;
  animation: modalIn 0.3s ease;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
  z-index: 10;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

#modal-image {
  max-width: 100%;
  max-height: 70vh;
  display: block;
}

.modal-actions {
  padding: 16px 24px;
  background: var(--bg-card);
  display: flex;
  justify-content: flex-end;
}

/* Animations */
.fade-in {
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

/* Mobile Scan Section */
.mobile-scan-section {
  grid-column: 1 / -1;
}

.mobile-scan-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 32px;
  text-align: center;
  backdrop-filter: blur(20px);
}

.mobile-scan-card h2 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.mobile-scan-card p {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 24px;
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.1rem;
}

.btn-large svg {
  width: 24px;
  height: 24px;
}

.mobile-hint {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 24px;
  margin-bottom: 0;
}

/* Hide QR on mobile */
@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .qr-section {
    position: static;
  }
}

/* Crop Modal Styles */
.crop-modal-content {
  max-width: 900px;
  width: 100%;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.crop-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

.crop-modal-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0;
}

.crop-container {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 400px;
}

.crop-container img {
  max-width: 100%;
  max-height: 100%;
}

.crop-tools {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  justify-content: center;
  border-top: 1px solid var(--border-color);
}

.modal-actions {
  padding: 16px 24px;
  background: var(--bg-card);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}