/* ========================================
   MediaMagic PWA - Mobile Styles
   ======================================== */

:root {
  /* Colors */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Spacing */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-height: 56px;
  --nav-height: 64px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ========================================
   Header
   ======================================== */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.header-btn:active {
  background: var(--bg-card);
  transform: scale(0.95);
}

.header-btn.loading svg {
  animation: spin 1s linear infinite;
}

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

/* ========================================
   Main Content
   ======================================== */

.main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.view {
  display: none;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
  animation: fadeIn 0.2s ease;
}

.view.active {
  display: block;
}

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

/* ========================================
   Stats Grid
   ======================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ========================================
   Section Title
   ======================================== */

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  margin-top: 8px;
}

/* ========================================
   Filter Tabs
   ======================================== */

.filter-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  flex-shrink: 0;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: none;
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

.filter-tab.active {
  background: var(--accent);
  color: white;
}

/* ========================================
   Card List
   ======================================== */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
  transition: var(--transition-fast);
}

.card:active {
  transform: scale(0.98);
  background: var(--bg-card);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  flex: 1;
  margin-right: 8px;
}

.card-content {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.card-meta-item svg {
  width: 14px;
  height: 14px;
}

/* ========================================
   Status Badge
   ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-planning { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.badge-scheduled { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.badge-recording { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-editing { background: rgba(168, 85, 247, 0.2); color: #a855f7; }
.badge-review { background: rgba(236, 72, 153, 0.2); color: #ec4899; }
.badge-publishing { background: rgba(34, 197, 94, 0.2); color: #22c55e; }
.badge-published { background: rgba(34, 197, 94, 0.3); color: #4ade80; }
.badge-live { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-failed { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-draft { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }

/* Platform badges */
.badge-platform {
  background: var(--bg-card);
  color: var(--text-secondary);
}

/* ========================================
   Platform List (Analytics)
   ======================================== */

.platform-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.platform-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
}

.platform-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.platform-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.platform-name {
  font-size: 16px;
  font-weight: 500;
}

.platform-followers {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-light);
}

/* ========================================
   Chart Container
   ======================================== */

.chart-container {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  height: 200px;
}

/* ========================================
   Bottom Navigation
   ======================================== */

.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: var(--nav-height);
  background: var(--bg-secondary);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

.nav-item svg {
  width: 24px;
  height: 24px;
}

.nav-item:active {
  transform: scale(0.95);
}

/* ========================================
   Loading & Empty States
   ======================================== */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
  position: fixed;
  top: calc(var(--safe-top) + var(--header-height) + 16px);
  left: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
  pointer-events: auto;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.info { border-left: 4px solid var(--info); }

.toast-message {
  flex: 1;
  font-size: 14px;
}

@keyframes slideIn {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ========================================
   Modal
   ======================================== */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1001;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 400px;
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
  font-size: 20px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 16px;
  transition: var(--transition-fast);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.btn {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

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

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

.btn:active {
  transform: scale(0.98);
}

/* ========================================
   Utilities
   ======================================== */

.hidden {
  display: none !important;
}

/* Pull to refresh indicator */
.ptr-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px;
  color: var(--text-muted);
  font-size: 12px;
}
