/* =============================================
   layout.css - App Shell & Page Layout
   Java Interview Questions Reader
   ============================================= */

/* --- App Container --- */
#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-primary);
}

/* --- Top Navigation Bar --- */
#top-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--color-border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.nav-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--color-accent-orange), #ef4444);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: var(--font-bold);
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(249,115,22,0.4);
}

.nav-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: -1px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.nav-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

.nav-btn:hover,
.nav-btn:active {
  background: var(--color-accent-orange-dim);
  border-color: var(--color-accent-orange);
  color: var(--color-accent-orange);
  transform: scale(1.05);
}

/* --- Page System --- */
.page {
  flex: 1;
  padding-bottom: calc(var(--bottom-bar) + var(--space-4));
  animation: fadeInUp 0.3s ease;
  display: none;
}

.page.active {
  display: block;
}

/* --- Main Content Area --- */
.content-area {
  padding: var(--space-4);
}

/* --- Section Header --- */
.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.section-icon {
  font-size: 20px;
  opacity: 0.9;
}

.section-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semi);
  color: var(--color-text-primary);
  flex: 1;
}

.section-badge {
  font-size: var(--text-xs);
  padding: 2px 8px;
  background: var(--color-accent-orange-dim);
  color: var(--color-accent-orange);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-accent);
  font-weight: var(--font-medium);
}

/* --- Bottom Navigation Bar --- */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-width);
  height: var(--bottom-bar);
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: var(--space-2) 0;
  z-index: var(--z-sticky);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  border: none;
  background: none;
  color: var(--color-text-muted);
  min-width: 60px;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.bottom-nav-item .nav-icon {
  font-size: 20px;
  transition: transform var(--transition-fast);
  line-height: 1;
}

.bottom-nav-item .nav-label {
  font-size: 10px;
  font-weight: var(--font-medium);
  letter-spacing: 0.02em;
  transition: color var(--transition-fast);
}

.bottom-nav-item.active {
  color: var(--color-accent-orange);
}

.bottom-nav-item.active .nav-icon {
  transform: translateY(-1px) scale(1.1);
}

.bottom-nav-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background: var(--color-accent-orange);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  transition: width var(--transition-normal);
}

.bottom-nav-item.active::before {
  width: 24px;
}

/* --- Reader Page Layout --- */
#reader-page {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

#reader-page.active {
  display: flex;
}

.reader-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--nav-height);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(16px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.08);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-3);
  gap: var(--space-3);
}

.reader-back-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-card);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.reader-back-btn:active {
  background: var(--color-accent-orange-dim);
  color: var(--color-accent-orange);
}

.reader-nav-info {
  flex: 1;
  min-width: 0;
}

.reader-nav-title {
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reader-nav-progress {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 1px;
}

/* --- Progress Bar --- */
.reading-progress-bar {
  height: 2px;
  background: var(--color-border);
  position: sticky;
  top: var(--nav-height);
  z-index: var(--z-sticky);
}

.reading-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent-orange), var(--color-accent-yellow));
  width: 0%;
  transition: width 0.1s linear;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* --- Spinner --- */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent-orange);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* --- Safe Area Support --- */
@supports (padding: max(0px)) {
  #bottom-nav {
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    height: calc(var(--bottom-bar) + env(safe-area-inset-bottom));
  }

  .page {
    padding-bottom: calc(var(--bottom-bar) + env(safe-area-inset-bottom) + var(--space-4));
  }
}
