/* ============================================
   Content Studio - Design System
   ============================================ */

:root {
  /* Colors */
  --bg-primary: #0f0f13;
  --bg-secondary: #16161d;
  --bg-card: #1c1c26;
  --bg-hover: #242430;
  --bg-input: #12121a;

  --text-primary: #e8e8ed;
  --text-secondary: #8e8ea0;
  --text-muted: #5a5a6e;

  --accent-primary: #7c5cfc;
  --accent-primary-hover: #6a4ae8;
  --accent-shopee: #ee4d2d;
  --accent-shopee-hover: #d4411f;
  --accent-shopee-bg: rgba(238, 77, 45, 0.1);
  --accent-moda: #e91e8c;
  --accent-moda-hover: #c9167a;
  --accent-moda-bg: rgba(233, 30, 140, 0.1);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --border: #2a2a38;
  --border-light: #33334a;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);

  --sidebar-width: 240px;
  --transition: 0.2s ease;
}

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

body {
  font-family: 'Segoe UI', -apple-system, system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

#app {
  display: flex;
  height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-moda));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: white;
}

.sidebar-logo span {
  font-weight: 700;
  font-size: 16px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  width: 100%;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

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

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

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

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.status-dot.offline {
  background: var(--danger);
}

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

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.view-header h1 {
  font-size: 28px;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

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

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent-primary);
}

.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-danger .stat-value { color: var(--danger); }

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================
   Cards
   ============================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

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

/* ============================================
   Badges & Accents
   ============================================ */

.shopee-accent { color: var(--accent-shopee); }
.moda-accent { color: var(--accent-moda); }

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-shopee {
  background: var(--accent-shopee-bg);
  color: var(--accent-shopee);
  border: 1px solid rgba(238, 77, 45, 0.3);
}

.badge-moda {
  background: var(--accent-moda-bg);
  color: var(--accent-moda);
  border: 1px solid rgba(233, 30, 140, 0.3);
}

.badge-ready {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-generating {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.3);
  animation: pulse 1.5s ease infinite;
}

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

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover {
  background: var(--border);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

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

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

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

.btn-shopee:hover {
  background: var(--accent-shopee-hover);
}

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

.btn-moda:hover {
  background: var(--accent-moda-hover);
}

/* ============================================
   Forms
   ============================================ */

.form-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.form-group {
  flex: 1;
  min-width: 200px;
}

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

.form-input,
.form-select,
.form-textarea,
.input-week {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.input-week:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(124, 92, 252, 0.15);
}

.form-textarea {
  resize: vertical;
  font-family: inherit;
}

.input-week {
  width: auto;
  min-width: 180px;
  color-scheme: dark;
}

/* ============================================
   Project Info
   ============================================ */

.project-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.info-row span {
  color: var(--text-secondary);
}

/* ============================================
   Script Preview
   ============================================ */

.script-preview {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
}

.script-preview .script-title {
  color: var(--accent-primary);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 12px;
}

.script-preview .script-meta {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ============================================
   Videos Grid
   ============================================ */

.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.video-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  transition: var(--transition);
}

.video-card:hover {
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

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

.video-card-title {
  font-weight: 600;
  font-size: 14px;
}

.video-card-body {
  font-size: 13px;
  color: var(--text-secondary);
}

.video-card-body .meta-item {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
}

.video-card-footer {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ============================================
   Calendar
   ============================================ */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}

.calendar-day {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
}

.calendar-day-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  text-align: center;
}

.calendar-day-header .day-date {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.calendar-day-body {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar-item {
  padding: 8px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.calendar-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.calendar-item.shopee {
  background: var(--accent-shopee-bg);
  border-left: 3px solid var(--accent-shopee);
}

.calendar-item.moda {
  background: var(--accent-moda-bg);
  border-left: 3px solid var(--accent-moda);
}

.calendar-item-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.calendar-item-time {
  color: var(--text-muted);
  font-size: 11px;
}

/* ============================================
   Schedules List
   ============================================ */

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

.schedule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.schedule-row:hover {
  border-color: var(--accent-primary);
}

.schedule-row-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.schedule-row-stats {
  display: flex;
  gap: 12px;
}

.schedule-stat {
  font-size: 13px;
  font-weight: 500;
}

/* ============================================
   Activity Log
   ============================================ */

.activity-log {
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

.log-entry:hover {
  background: var(--bg-hover);
}

.log-time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  min-width: 60px;
}

.log-message {
  flex: 1;
}

.log-entry.success .log-message { color: var(--success); }
.log-entry.error .log-message { color: var(--danger); }
.log-entry.warning .log-message { color: var(--warning); }
.log-entry.info .log-message { color: var(--info); }

/* ============================================
   Analytics
   ============================================ */

.analytics-report {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.api-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.api-status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.api-status-item .status-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.api-status-item .status-icon.configured { background: var(--success); }
.api-status-item .status-icon.missing { background: var(--danger); }

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

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 20px;
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-primary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-moda));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-log {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

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

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

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

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   Empty State
   ============================================ */

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

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-light);
}

/* ============================================
   Login Screen
   ============================================ */

.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-logo h2 {
  font-size: 24px;
  font-weight: 700;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1200px) {
  .calendar-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    width: 60px;
  }
  .sidebar-logo span,
  .nav-btn span:not(svg) {
    display: none;
  }
  .sidebar-logo {
    justify-content: center;
  }
  .nav-btn {
    justify-content: center;
    padding: 12px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .calendar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   Pipeline Pixar
   ============================================ */

.pixar-etapa-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 6px;
  margin-bottom: 4px;
  transition: background 0.3s;
}

.pixar-etapa-item:has(.active) {
  background: var(--bg-input);
  font-weight: 600;
}

.pixar-etapa-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: all 0.3s;
}

.pixar-etapa-dot.pending {
  background: var(--border-color);
}

.pixar-etapa-dot.active {
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
  animation: pixarPulse 1.5s infinite;
}

.pixar-etapa-dot.done {
  background: var(--success);
}

@keyframes pixarPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

#pixar-log div {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
