:root {
  --bg-dark: #05070A;
  --graphite: #111827;
  --accent: #00E0B8;
  --white: #F9FAFB;
  --gray: #9CA3AF;
  --gray-dark: #374151;
  --orange: #FF8A3D;
  --red: #EF4444;
  --blue: #3B82F6;
  --green: #10B981;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--white);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--graphite);
  border-right: 1px solid var(--gray-dark);
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  display: flex; flex-direction: column;
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--gray-dark);
  margin-bottom: 16px;
}

.sidebar-brand h1 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
}

.sidebar-brand span {
  font-size: 11px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sidebar-nav { flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.nav-item:hover { color: var(--white); background: rgba(255,255,255,0.03); }
.nav-item.active {
  color: var(--accent);
  background: rgba(0,224,184,0.05);
  border-left-color: var(--accent);
}

.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-dark);
  font-size: 12px;
  color: var(--gray);
}

/* Main */
.main {
  margin-left: 240px;
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-header h2 {
  font-size: 28px;
  font-weight: 800;
}

/* Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--graphite);
  border: 1px solid var(--gray-dark);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card .label {
  font-size: 12px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

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

.stat-card .sub {
  font-size: 12px;
  color: var(--gray);
  margin-top: 4px;
}

/* Content Cards */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.content-card {
  background: var(--graphite);
  border: 1px solid var(--gray-dark);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.content-card:hover { border-color: var(--accent); }

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

.content-card-header h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  flex: 1;
}

.content-card-body {
  font-size: 13px;
  color: var(--gray);
  line-height: 1.6;
  margin-bottom: 16px;
  max-height: 120px;
  overflow: hidden;
}

.content-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.content-card-actions {
  display: flex;
  gap: 6px;
}

/* Badges */
.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-linkedin { background: #0077B520; color: #0A66C2; }
.badge-instagram { background: #E4405F20; color: #E4405F; }
.badge-tiktok { background: #00F2EA20; color: #00F2EA; }

.badge-idea { background: var(--gray-dark); color: var(--gray); }
.badge-draft { background: #3B82F620; color: var(--blue); }
.badge-approved { background: #10B98120; color: var(--green); }
.badge-scheduled { background: #F59E0B20; color: #F59E0B; }
.badge-published { background: #00E0B820; color: var(--accent); }
.badge-failed { background: #EF444420; color: var(--red); }
.badge-manual_required { background: #FF8A3D20; color: var(--orange); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-secondary {
  background: var(--gray-dark);
  color: var(--white);
}

.btn-secondary:hover { background: #4B5563; }

.btn-sm { padding: 5px 10px; font-size: 11px; }

.btn-danger { background: #EF444430; color: var(--red); }
.btn-danger:hover { background: #EF444450; }

.btn-orange { background: var(--orange); color: var(--bg-dark); }

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--gray-dark);
  border-radius: 8px;
  color: var(--white);
  font-size: 14px;
  font-family: inherit;
}

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

textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: none; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* 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: 200;
  display: none;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--graphite);
  border: 1px solid var(--gray-dark);
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.modal-header h3 { font-size: 20px; font-weight: 700; }

.modal-close {
  background: none; border: none;
  color: var(--gray); cursor: pointer;
  font-size: 24px;
}

.modal-close:hover { color: var(--white); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-dark);
}

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

.calendar-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray);
  padding: 8px;
}

.calendar-day {
  background: var(--graphite);
  border: 1px solid var(--gray-dark);
  border-radius: 8px;
  min-height: 100px;
  padding: 8px;
}

.calendar-day.today { border-color: var(--accent); }

.calendar-day .day-number {
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 6px;
}

.calendar-item {
  padding: 4px 6px;
  margin-bottom: 4px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.calendar-item.linkedin { background: #0077B530; color: #0A66C2; }
.calendar-item.instagram { background: #E4405F30; color: #E4405F; }
.calendar-item.tiktok { background: #00F2EA30; color: #00F2EA; }

/* Platform Status */
.platform-card {
  background: var(--graphite);
  border: 1px solid var(--gray-dark);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.platform-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}

.platform-info { flex: 1; }
.platform-info h4 { font-size: 16px; margin-bottom: 4px; }
.platform-info p { font-size: 13px; color: var(--gray); }

.status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.active { background: var(--green); }
.status-dot.inactive { background: var(--red); }

/* Filters */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--gray-dark);
  background: transparent;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover { border-color: var(--accent); color: var(--white); }
.filter-btn.active { background: var(--accent); color: var(--bg-dark); border-color: var(--accent); }

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--gray);
}

.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--gray-dark);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

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

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  background: var(--graphite);
  border: 1px solid var(--gray-dark);
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }

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

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
}

.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--white); }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-brand h1 { font-size: 14px; }
  .sidebar-brand span { display: none; }
  .nav-item span { display: none; }
  .main { margin-left: 60px; padding: 16px; }
  .content-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* Section hide/show */
.page-section { display: none; }
.page-section.active { display: block; }

/* Content card thumbnail */
.card-thumb {
  margin: -16px -16px 12px;
  height: 200px;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
  background: var(--bg);
}
.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

/* Templates grid */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.template-card {
  background: var(--graphite);
  border: 2px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
}

.template-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.template-card .preview-area {
  aspect-ratio: 1;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.template-card .preview-area img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.template-card .preview-area .loading {
  color: var(--gray);
  font-size: 13px;
}

.template-card .info {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.template-card .info h4 {
  color: var(--white);
  font-size: 15px;
  font-weight: 700;
}

.template-card .info p {
  color: var(--gray);
  font-size: 12px;
  line-height: 1.4;
}

.template-card .tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.template-card .tag {
  background: rgba(0,224,184,0.1);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Bulk Actions Bar */
.bulk-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--graphite);
  border: 1px solid var(--accent);
  padding: 12px 20px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.bulk-bar #bulk-count {
  font-weight: 600;
  color: var(--accent);
}

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

.btn-danger {
  background: var(--red, #EF4444);
  color: white;
}

.btn-danger:hover { opacity: 0.85; }

.content-card.bulk-mode { cursor: pointer; position: relative; }

.content-card.bulk-mode::before {
  content: '';
  position: absolute;
  top: 12px; right: 12px;
  width: 22px; height: 22px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: transparent;
}

.content-card.bulk-mode.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.content-card.bulk-mode.selected::before {
  background: var(--accent);
  content: '✓';
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

/* Analytics specific */
.analytics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.analytics-table {
  width: 100%;
  background: var(--graphite);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}

.analytics-table thead {
  background: rgba(0, 224, 184, 0.05);
}

.analytics-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.analytics-table td {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  color: var(--white);
}

.analytics-table tbody tr:hover { background: rgba(255,255,255,0.02); }

.pillar-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pillar-bar .fill {
  height: 8px;
  background: var(--accent);
  border-radius: 4px;
  min-width: 4px;
}

/* Timeline */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  padding: 12px 16px;
  background: var(--graphite);
  border-radius: 8px;
  align-items: center;
}

.timeline-icon {
  width: 36px;
  height: 36px;
  background: rgba(0, 224, 184, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 18px;
}

.timeline-icon.fail { background: rgba(239, 68, 68, 0.1); color: var(--red, #EF4444); }
.timeline-icon.lead { background: rgba(255, 138, 61, 0.1); color: var(--orange, #FF8A3D); }

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-action { font-weight: 600; color: var(--white); }
.timeline-desc { font-size: 13px; color: var(--gray); }
.timeline-time { font-size: 12px; color: var(--gray); white-space: nowrap; }

/* WhatsApp messages */
.wa-message {
  padding: 12px 16px;
  background: var(--graphite);
  border-radius: 12px;
  margin-bottom: 8px;
  border-left: 3px solid var(--gray);
}

.wa-message.out { border-left-color: var(--accent); }
.wa-message.in { border-left-color: var(--orange, #FF8A3D); }

.wa-message-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 4px;
}

.wa-message-body {
  color: var(--white);
  white-space: pre-wrap;
  font-size: 14px;
}

/* Lead row */
.lead-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 16px;
  padding: 12px 16px;
  background: var(--graphite);
  border-radius: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.lead-row .lead-tag {
  background: rgba(0, 224, 184, 0.1);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.form-input {
  background: var(--bg);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 30px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: rgba(255,255,255,0.15);
  transition: 0.3s;
  border-radius: 30px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 4px;
  background-color: var(--white);
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(26px); }

/* Provider card */
.provider-card {
  background: var(--graphite);
  border: 2px solid rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.provider-card:hover { border-color: rgba(0,224,184,0.3); }
.provider-card.selected { border-color: var(--accent); }
.provider-card.disabled { opacity: 0.5; cursor: not-allowed; }

.provider-card .provider-info h4 {
  color: var(--white);
  margin-bottom: 4px;
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 8px;
}

.provider-card .provider-model {
  font-family: monospace;
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 4px;
}

.provider-card .provider-cost {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 4px;
}

.provider-card .provider-msg {
  font-size: 13px;
  color: var(--gray);
}

.provider-card .badge-free {
  background: rgba(0, 224, 184, 0.15);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.provider-card .badge-paid {
  background: rgba(255, 138, 61, 0.15);
  color: var(--orange, #FF8A3D);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.provider-card .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--red, #EF4444);
}

.provider-card .status-dot.on { background: var(--accent); }

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