/* ===========================================
   JAVY 5 - App View (Open App Screen)
   Chappy V2 Style - Glasmorphism
   Full screen below header, replaces home
   =========================================== */

/* ---- App View Container ---- */
.app-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: appViewIn 250ms ease;
}

.app-view.hidden {
  display: none;
}

@keyframes appViewIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---- App View Header (Back bar) ---- */
.app-view-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--glass-border);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, transparent 60%);
  flex-shrink: 0;
}

.app-view-back {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-base);
  color: var(--accent-purple);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  font-weight: 500;
}

.app-view-back:hover {
  background: var(--accent-purple-muted);
  transform: translateX(-2px);
}

.app-view-back svg {
  width: 16px;
  height: 16px;
}

.app-view-title {
  font-size: var(--font-lg);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.app-view-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ---- App View Content ---- */
.app-view-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-lg);
  position: relative;
}

/* ---- Web Preview Container ---- */
.app-preview-container {
  display: flex;
  flex-direction: column;
  padding: var(--space-md) !important;
  overflow: hidden !important;
  gap: 0;
}

.app-preview-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: rgba(18, 18, 35, 0.9);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  backdrop-filter: var(--glass-blur);
  flex-shrink: 0;
}

.app-preview-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.app-preview-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: block;
}

.app-preview-dots .dot-red {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.app-preview-dots .dot-yellow {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}

.app-preview-dots .dot-green {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.app-preview-url {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 4px var(--space-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.app-preview-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.app-preview-frame-wrapper {
  flex: 1;
  position: relative;
  border: 1px solid var(--glass-border);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  overflow: hidden;
  background: #0a0a14;
  min-height: 0;
}

.app-preview-iframe {
  width: 100%;
  height: 100%;
  border: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  display: block;
}

.app-preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  color: var(--text-muted);
  font-size: var(--font-sm);
  z-index: 2;
}

.app-preview-loading .spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Legacy content iframe */
.app-view-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-sm);
}

/* ---- Loading State ---- */
.app-view-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  color: var(--text-muted);
}

.app-view-loading .spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--glass-border);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---- Error State ---- */
.app-view-error {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-2xl);
  text-align: center;
}

.app-view-error-icon {
  font-size: 40px;
  opacity: 0.3;
}

.app-view-error-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--text-secondary);
}

.app-view-error-text {
  font-size: var(--font-sm);
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.6;
}

/* ---- Mobile ---- */
@media (max-width: 639px) {
  .app-view-header {
    padding: var(--space-xs) var(--space-md);
  }

  .app-view-content {
    padding: var(--space-md);
  }

  .app-preview-container {
    padding: var(--space-sm) !important;
  }

  .app-preview-toolbar {
    padding: var(--space-xs) var(--space-sm);
  }

  .app-preview-url {
    font-size: 9px;
  }

  .app-view-back svg {
    width: 12px;
    height: 12px;
  }
}
