/* ==========================================================================
   LAYOUT.CSS — Base Reset, Application Container & Responsive Layout
   Standardized based on mtips5s_30_VPS3_UX_UI_Design Curriculum
   ========================================================================== */

/* Universal Box Sizing & Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(circle at 10% 10%, rgba(36, 161, 222, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, rgba(99, 102, 241, 0.08) 0%, transparent 45%);
  background-attachment: fixed;
  color: var(--text-main);
  min-width: 440px;
  max-width: 520px;
  margin: 0 auto;
  min-height: 580px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* Standalone Web Dashboard Layout (Responsive Desktop Expansion) */
@media (min-width: 768px) {
  body {
    max-width: 780px;
    padding: var(--space-6) var(--space-4);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .app-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-6) !important;
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* App Main Container */
.app-wrapper {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
}

/* Web Notice Banner (Demo Mode) */
.web-notice {
  display: none;
  align-items: center;
  gap: var(--space-3);
  background: linear-gradient(135deg, rgba(36, 161, 222, 0.15), rgba(56, 189, 248, 0.08));
  border: 1px solid var(--border-accent);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-main);
  animation: fadeIn var(--transition-base);
}

.web-notice .notice-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--tg-blue);
}

.web-notice a {
  color: var(--tg-cyan);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Header Section */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-logo-wrap {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--grad-primary);
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--tg-blue-glow);
  flex-shrink: 0;
}

.brand-logo {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  object-fit: cover;
}

.brand-title-wrap h1 {
  font-size: var(--font-size-lg);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.version-tag {
  font-size: var(--font-size-xs);
  font-weight: 700;
  padding: 2px 8px;
  background: rgba(36, 161, 222, 0.16);
  color: var(--tg-blue);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.brand-subtitle {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: 500;
}

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

/* Connection Status Bar */
.connection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  box-shadow: var(--shadow-xs);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  color: var(--text-muted);
}

.status-badge.connected {
  color: var(--text-main);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.pulse-green {
  background-color: var(--accent-emerald);
  animation: pulseGreen 2s infinite;
}

.pulse-amber {
  background-color: var(--accent-amber);
  animation: pulseAmber 2s infinite;
}

/* Stats Metrics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-2);
  text-align: center;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-xs);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stat-num {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-card.video .stat-num { color: #60a5fa; }
.stat-card.image .stat-num { color: #34d399; }
.stat-card.total .stat-num { color: #a78bfa; }
.stat-card.selected .stat-num { color: #f472b6; }

.stat-label {
  font-size: var(--font-size-xs);
  color: var(--text-dim);
  margin-top: 3px;
  font-weight: 600;
}

/* Tab Navigation */
.tab-nav {
  display: flex;
  gap: var(--space-1);
  background: var(--bg-surface-elevated);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
  outline: none;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-subtle);
}

.tab-btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Tab Panes */
.tab-pane {
  display: none;
  flex-direction: column;
  gap: var(--space-3);
  animation: fadeIn var(--transition-base);
}

.tab-pane.active {
  display: flex;
}

/* Footer Section */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--text-dim);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-2);
}

.app-footer a {
  color: var(--tg-blue);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-fast);
}

.app-footer a:hover {
  color: var(--tg-cyan);
  text-decoration: underline;
}
