/* 
 * Layout
 * Mobile-first, functional structure
 */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  max-width: 100%;
  overflow: hidden;
}

/* Main Area - Takes remaining space */
#main-area {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Views */
.view {
  display: none;
  height: 100%;
  width: 100%;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.view.active {
  display: flex;
}

/* Input Area - Fixed at bottom (Mobile default) */
#input-area {
  --input-area-height: 130px; /* Used by chat overlay */
  display: flex;
  height: 60px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-top: var(--border-width) solid var(--border-color);
  background: var(--color-paper);
  padding: var(--space-3) var(--space-4);
  position: relative;
  z-index: 50; /* Above chat overlay */
}

.input_area_container {
  width: 100%;
  max-width: 1000px;
  display: flex;
  flex-direction: column;
}

/* Desktop Layout */
@media (min-width: 768px) {
  #app {
    flex-direction: row;
    margin: 0 auto;
    /* border-left: var(--border-width) solid var(--border-color); */
    /* border-right: var(--border-width) solid var(--border-color); */
  }

  #input-area {
    width: 60px;
    height: 100%;
    border-top: none;
    border-right: var(--border-width) solid var(--border-color);
    padding: var(--space-4) var(--space-2);
  }

  .input_area_container {
    height: 100%;
    max-width: none;
  }
}

@media (min-width: 1200px) {
  #app {
  }
}

/* =================================================================
   STANDARD LOADING STATE
   ================================================================= */

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 200px;
  background: var(--color-paper-warm);
  animation: loadingFadeIn 0.3s ease-out;
}

.loading-content {
  text-align: center;
  max-width: 300px;
  padding: var(--space-6);
}

.loading-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--color-ink-lighter);
  margin-bottom: var(--space-4);
  animation: loadingPulse 2s infinite ease-in-out;
}

.loading-icon svg {
  width: 48px;
  height: 48px;
  stroke-width: 1.5;
}

.loading-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--color-ink);
  margin-bottom: var(--space-2);
}

.loading-subtitle {
  font-size: var(--text-sm);
  color: var(--color-ink-lighter);
}

/* Size Variants */
.loading-state.loading-sm .loading-icon svg {
  width: 32px;
  height: 32px;
}
.loading-state.loading-sm .loading-title {
  font-size: var(--text-base);
}

/* Transparent Variant */
.loading-state.loading-transparent {
  background: transparent;
}

@keyframes loadingPulse {
  0% { opacity: 0.4; transform: scale(0.95); }
  50% { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0.4; transform: scale(0.95); }
}

@keyframes loadingFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* View Transitions */
.view-fade-in {
  animation: viewFadeIn 0.3s ease-out forwards;
}

/* Context Switch Loading Overlay */
.context-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
}

.context-loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.context-loading-content {
  background: var(--color-paper);
  padding: var(--space-6) var(--space-8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  border: var(--border-width) solid var(--border-color);
  animation: contextLoadingPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.context-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-ink);
  border-radius: 50%;
  animation: contextSpin 0.8s linear infinite;
}

.context-loading-text {
  font-weight: var(--weight-medium);
  color: var(--color-ink);
}

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

@keyframes contextLoadingPop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes viewFadeIn {
  from { 
    opacity: 0;
    transform: translateY(4px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}
