/* ═══════════════════════════════════════════════════════════════
   CONTENT MANAGER — Ad Content Management Panel
   ═══════════════════════════════════════════════════════════════ */

.cm-wrap { padding: var(--space-6); max-width: var(--content-max-width); }

/* ─── Stats Row ─── */
.cm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
.cm-stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--space-5);
  transition: border-color var(--duration-normal);
}
.cm-stat-card:hover { border-color: var(--border-default); }
.cm-stat-label { font-size: var(--text-xs); color: var(--text-tertiary); text-transform: uppercase;
  letter-spacing: 0.05em; font-weight: var(--weight-medium); margin-bottom: var(--space-1); }
.cm-stat-value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); }

/* ─── Toolbar ─── */
.cm-toolbar {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  margin-bottom: var(--space-6); padding: var(--space-4);
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.cm-search-wrap { position: relative; flex: 1; min-width: 200px; }
.cm-search-wrap input {
  width: 100%; padding: var(--space-2) var(--space-4) var(--space-2) var(--space-10);
  font-size: var(--text-sm);
}
.cm-search-icon { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: var(--text-sm); pointer-events: none; }
.cm-toolbar select { padding: var(--space-2) var(--space-3); font-size: var(--text-sm); min-width: 140px; }
.cm-toolbar-actions { display: flex; gap: var(--space-2); margin-left: auto; }

/* ─── View Tabs ─── */
.cm-view-tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-4); }
.cm-view-tab {
  padding: var(--space-2) var(--space-4); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--text-tertiary); background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-md); cursor: pointer; font-family: var(--font-sans);
  transition: all var(--duration-fast);
}
.cm-view-tab:hover { color: var(--text-secondary); background: var(--bg-hover); }
.cm-view-tab.active { color: var(--text-primary); background: var(--bg-surface);
  border-color: var(--border-default); }

/* ─── Card Grid ─── */
.cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--space-4); }
.cm-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); overflow: hidden; cursor: pointer;
  transition: border-color var(--duration-normal), transform var(--duration-normal);
}
.cm-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cm-card-thumb {
  width: 100%; height: 160px; object-fit: cover; background: var(--bg-elevated);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 48px;
}
.cm-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cm-card-body { padding: var(--space-4); }
.cm-card-title {
  font-size: var(--text-md); font-weight: var(--weight-semibold); color: var(--text-primary);
  margin-bottom: var(--space-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-card-badges { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-bottom: var(--space-2); }
.cm-card-meta { font-size: var(--text-xs); color: var(--text-tertiary); }

/* ─── Badges ─── */
.cm-badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  border-radius: var(--radius-full); white-space: nowrap;
}
.cm-badge-draft { background: var(--bg-elevated); color: var(--text-secondary); }
.cm-badge-in_progress { background: var(--warning-muted); color: var(--warning); }
.cm-badge-review { background: var(--info-muted); color: var(--info); }
.cm-badge-completed { background: var(--success-muted); color: var(--success); }
.cm-badge-pending { background: var(--bg-elevated); color: var(--text-secondary); }
.cm-badge-approved { background: var(--success-muted); color: var(--success); }
.cm-badge-rejected { background: var(--error-muted); color: var(--error); }
.cm-badge-education { background: var(--info-muted); color: var(--info); }
.cm-badge-tiktok { background: var(--purple-muted); color: var(--purple); }
.cm-badge-news { background: var(--accent-muted); color: var(--accent-text); }
.cm-badge-promo { background: var(--orange-muted); color: var(--orange); }
.cm-badge-other { background: var(--bg-elevated); color: var(--text-secondary); }
.cm-badge-english { background: rgba(59,130,246,0.1); color: #60a5fa; }
.cm-badge-spanish { background: rgba(245,158,11,0.1); color: #fbbf24; }
.cm-badge-bilingual { background: rgba(168,85,247,0.1); color: #c084fc; }

/* ─── Detail / Editor Panel ─── */
.cm-detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity var(--duration-normal);
}
.cm-detail-overlay.open { opacity: 1; pointer-events: auto; }
.cm-detail-panel {
  position: fixed; top: 0; right: -680px; width: 680px; max-width: 95vw; height: 100vh;
  background: var(--bg-surface); border-left: 1px solid var(--border-default);
  z-index: 91; overflow-y: auto; transition: right var(--duration-slow) var(--ease-out);
}
.cm-detail-panel.open { right: 0; }
.cm-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-6); border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; background: var(--bg-surface); z-index: 1;
}
.cm-detail-header h2 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.cm-detail-close {
  background: none; border: none; color: var(--text-tertiary); font-size: 24px;
  cursor: pointer; padding: var(--space-1);
}
.cm-detail-close:hover { color: var(--text-primary); }
.cm-detail-body { padding: var(--space-6); }

/* ─── Form Layout ─── */
.cm-form-section {
  margin-bottom: var(--space-6); padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
}
.cm-form-section:last-child { border-bottom: none; margin-bottom: 0; }
.cm-form-section h3 {
  font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-4);
}
.cm-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); margin-bottom: var(--space-4); }
.cm-form-field { margin-bottom: var(--space-4); }
.cm-form-field label {
  display: block; font-size: var(--text-xs); font-weight: var(--weight-medium);
  color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.cm-form-field input, .cm-form-field select, .cm-form-field textarea {
  width: 100%; padding: var(--space-2) var(--space-3); font-size: var(--text-sm);
}
.cm-form-field textarea { min-height: 100px; resize: vertical; font-family: var(--font-sans); }
.cm-form-actions {
  display: flex; gap: var(--space-3); justify-content: flex-end;
  padding-top: var(--space-4); border-top: 1px solid var(--border-subtle);
}

/* ─── Script Editor ─── */
.cm-script-tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-3); }
.cm-script-tab {
  padding: var(--space-1) var(--space-3); font-size: var(--text-xs); font-weight: var(--weight-medium);
  color: var(--text-tertiary); background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-family: var(--font-sans);
}
.cm-script-tab.active { color: var(--text-primary); background: var(--bg-elevated);
  border-color: var(--border-default); }
.cm-script-area { min-height: 160px; }
.cm-ai-btn {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: var(--space-1) var(--space-3); font-size: var(--text-xs);
  background: var(--accent-muted); color: var(--accent-text); border: 1px solid var(--accent);
  border-radius: var(--radius-md); cursor: pointer; font-family: var(--font-sans);
  transition: all var(--duration-fast);
}
.cm-ai-btn:hover { background: var(--accent); color: #fff; }

/* ─── Preview Section ─── */
.cm-preview-media { margin: var(--space-4) 0; }
.cm-preview-media video, .cm-preview-media audio {
  width: 100%; border-radius: var(--radius-md); background: var(--bg-base);
}

/* ─── Approval Actions ─── */
.cm-approval-row { display: flex; gap: var(--space-2); align-items: center; }
.cm-approval-row .cm-badge { font-size: var(--text-sm); padding: var(--space-1) var(--space-3); }

/* ─── Voices Tab ─── */
.cm-voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-4); }
.cm-voice-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: var(--space-4); display: flex; gap: var(--space-3); align-items: center;
}
.cm-voice-card:hover { border-color: var(--border-default); }
.cm-voice-avatar {
  width: 48px; height: 48px; border-radius: var(--radius-full);
  background: var(--bg-elevated); display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0; overflow: hidden;
}
.cm-voice-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cm-voice-name { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.cm-voice-lang { font-size: var(--text-xs); color: var(--text-tertiary); }

/* ─── Loading ─── */
.cm-loading { display: flex; align-items: center; justify-content: center; gap: var(--space-3);
  padding: var(--space-16); color: var(--text-tertiary); }
.cm-spinner {
  width: 24px; height: 24px; border: 2px solid var(--border-default);
  border-top-color: var(--accent); border-radius: 50%;
  animation: cmSpin 0.8s linear infinite;
}
@keyframes cmSpin { to { transform: rotate(360deg); } }

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .cm-stats { grid-template-columns: repeat(2, 1fr); }
  .cm-form-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .cm-wrap { padding: var(--space-4); }
  .cm-stats { grid-template-columns: 1fr; }
  .cm-grid { grid-template-columns: 1fr; }
  .cm-toolbar { flex-direction: column; }
  .cm-toolbar-actions { margin-left: 0; width: 100%; }
  .cm-detail-panel { width: 100%; right: -100%; }
}
