:root {
  --bg-dark: #090d16;
  --bg-card: #131b2e;
  --bg-card-hover: #1c2742;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-active: rgba(59, 130, 246, 0.4);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --sidebar-width: 280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: #0d1322;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 20px;
  position: fixed;
  height: 100vh;
  top: 0;
  left: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), var(--accent-purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.brand-text h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.badge-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.view-mode-selector {
  margin-bottom: 20px;
}

.view-mode-selector label, .client-filter-box label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  display: block;
  margin-bottom: 8px;
}

.segmented-control {
  display: flex;
  background: #172033;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.segment-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.segment-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.client-filter-box {
  margin-bottom: 24px;
}

.client-filter-box select {
  width: 100%;
  padding: 10px;
  background: #172033;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: rgba(59, 130, 246, 0.15);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

.counter-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}

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

.server-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #131b2e;
  padding: 10px;
  border-radius: 8px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-green);
}

.status-title {
  font-size: 12px;
  font-weight: 600;
}

.status-sub {
  font-size: 10px;
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 30px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.header-title h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 26px;
  font-weight: 700;
}

.header-title p {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  border: 2px solid var(--border-color);
}

/* Tabs System */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

/* AI Coach Card */
.ai-coach-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(139, 92, 246, 0.15));
  border: 1px solid rgba(139, 92, 246, 0.3);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
}

.coach-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-purple);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.coach-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
}

.coach-tag {
  font-size: 11px;
  font-weight: 800;
  color: #c084fc;
  letter-spacing: 0.5px;
}

.coach-date {
  font-size: 12px;
  color: var(--text-muted);
}

.ai-coach-card h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.ai-coach-card p {
  font-size: 14px;
  line-height: 1.6;
  color: #cbd5e1;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 20px;
  border-radius: 12px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-active);
}

.metric-header {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 10px;
}

.metric-value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'Outfit', sans-serif;
  margin-bottom: 8px;
}

.metric-foot {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.metric-foot.positive { color: var(--accent-green); }
.metric-foot.neutral { color: var(--accent-amber); }

/* Card Panels */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 30px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.panel-header h3 {
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Client Rows */
.client-rows {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.client-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #172033;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.client-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.client-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.client-icon.garbatina { background: #059669; }
.client-icon.spiedo { background: #ea580c; }
.client-icon.passfly { background: #7c3aed; }

.client-info h4 {
  font-size: 15px;
  font-weight: 600;
}

.client-info span {
  font-size: 12px;
  color: var(--text-muted);
}

.client-tags {
  display: flex;
  gap: 8px;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-badge.success { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.status-badge.info { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.status-badge.warning { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }
.status-badge.purple { background: rgba(139, 92, 246, 0.15); color: var(--accent-purple); }

/* Existing Posts Box */
.existing-posts-box {
  background: #172033;
  padding: 18px;
  border-radius: 10px;
  margin-bottom: 24px;
  border: 1px solid var(--border-color);
}

.existing-posts-box h4 {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.post-tag {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e2e8f0;
}

/* Drafts Grid */
.drafts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.draft-card {
  background: #172033;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.draft-media {
  position: relative;
  height: 160px;
}

.draft-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
}

.draft-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.draft-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.client-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.client-pill.garbatina { background: rgba(5, 150, 105, 0.2); color: #34d399; }
.client-pill.spiedo { background: rgba(234, 88, 12, 0.2); color: #fb923c; }
.client-pill.passfly { background: rgba(124, 58, 237, 0.2); color: #a78bfa; }

.date-pill {
  font-size: 11px;
  color: var(--text-muted);
}

.draft-body h4 {
  font-size: 15px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.draft-body p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;

  /* Line clamp 2 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.seo-info {
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.draft-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

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

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: #172033; color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: rgba(255, 255, 255, 0.05); }

.btn-success { background: var(--accent-green); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }

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

/* Tables */
.performance-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  background: #172033;
}

.badge-metric {
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}

.badge-metric.positive { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); }
.badge-metric.neutral { background: rgba(245, 158, 11, 0.15); color: var(--accent-amber); }

/* Ads Cards */
.ads-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.ads-card {
  background: #172033;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

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

.ads-card-title h4 {
  font-size: 16px;
  margin-bottom: 2px;
}

.ads-id {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 16px;
}

.ads-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.stat-item label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.stat-item span {
  font-size: 15px;
  font-weight: 700;
}

.ads-filter-info {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(59, 130, 246, 0.08);
  padding: 10px;
  border-radius: 6px;
}

/* Brand Editor */
.form-group {
  margin-bottom: 20px;
}

.form-group label, .form-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.form-group select, .form-field input, .form-field textarea {
  width: 100%;
  padding: 10px 14px;
  background: #172033;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

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

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

.form-actions {
  display: flex;
  justify-content: flex-end;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

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

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  width: 90%;
  max-width: 650px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
}

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

.modal-body {
  padding: 24px;
  max-height: 400px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
}

.modal-footer {
  padding: 16px 24px;
  background: #0d1322;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-color);
}
