/* ============================================================
   AdsPilot Pro — Base & Reset Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Links */
a { color: var(--brand-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: #7ab3ff; }

/* Headings */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

/* Images */
img { max-width: 100%; height: auto; display: block; }

/* Inputs base */
input, textarea, select {
  font-family: var(--font-sans);
  font-size: 14px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select option { background: var(--bg-elevated); color: var(--text-primary); }

/* Buttons base */
button {
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  outline: none;
  transition: all var(--transition-fast);
}

/* Code */
code, pre {
  font-family: var(--font-mono);
  font-size: 13px;
}

/* Selection */
::selection { background: rgba(79,142,247,0.3); color: var(--text-primary); }

/* ============================================================
   Layout Components
   ============================================================ */

/* App Shell */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: var(--z-sidebar);
  transition: width var(--transition-base);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 64px;
}

.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--brand-gradient);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  font-size: 16px; font-weight: 700;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.sidebar-logo .logo-badge {
  font-size: 9px; font-weight: 600;
  background: var(--brand-gradient);
  color: #fff;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  -webkit-text-fill-color: #fff;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) 0;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-sm);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--space-md);
  color: var(--text-secondary);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  border-radius: 0;
  transition: all var(--transition-fast);
  position: relative;
  white-space: nowrap;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-left-color: var(--border-default);
}

.nav-item.active {
  background: rgba(79,142,247,0.1);
  color: var(--brand-primary);
  border-left-color: var(--brand-primary);
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.nav-item .nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 600;
  background: var(--brand-primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.nav-item .nav-badge.danger { background: var(--danger); }
.nav-item .nav-badge.success { background: var(--success); }

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.user-card:hover { background: var(--bg-elevated); }

.user-avatar {
  width: 34px; height: 34px;
  background: var(--brand-gradient);
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.user-info { overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

.main-content.expanded { margin-left: var(--sidebar-collapsed); }

/* Top Header */
.top-header {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center;
  padding: 0 var(--space-xl);
  gap: var(--space-md);
  position: sticky; top: 0;
  z-index: var(--z-header);
}

.header-title { font-size: 18px; font-weight: 700; flex: 1; }
.header-subtitle { font-size: 12px; color: var(--text-muted); font-weight: 400; margin-left: 8px; }

.header-actions { display: flex; align-items: center; gap: var(--space-sm); }

.header-btn {
  width: 36px; height: 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}
.header-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-default); }

.header-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.page-content {
  flex: 1;
  padding: var(--space-xl);
  max-width: 1400px;
  width: 100%;
}

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

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: border-color var(--transition-fast);
}
.card:hover { border-color: var(--border-default); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-md);
}

.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Stat Cards */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
}
.stat-card:hover {
  border-color: var(--border-default);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--brand-gradient);
}

.stat-card.tiktok::before { background: var(--tiktok-color); }
.stat-card.facebook::before { background: var(--facebook-color); }
.stat-card.success::before { background: var(--success); }
.stat-card.warning::before { background: var(--warning); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: var(--space-md);
}

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-change {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600;
  margin-top: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.stat-change.up { color: var(--success); background: var(--success-bg); }
.stat-change.down { color: var(--danger); background: var(--danger-bg); }

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

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--brand-gradient);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(79,142,247,0.3);
}
.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79,142,247,0.4);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239,68,68,0.25);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(34,197,94,0.25);
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-tiktok {
  background: var(--tiktok-bg);
  color: var(--tiktok-color);
  border-color: rgba(255,45,85,0.25);
}
.btn-tiktok:hover { background: var(--tiktok-color); color: #fff; }

.btn-facebook {
  background: var(--facebook-bg);
  color: var(--facebook-color);
  border-color: rgba(24,119,242,0.25);
}
.btn-facebook:hover { background: var(--facebook-color); color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 9px; }
.btn-icon.btn-sm { padding: 6px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ============================================================
   Badges & Tags
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.badge-primary { background: rgba(79,142,247,0.15); color: var(--brand-primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger);  }
.badge-info    { background: var(--info-bg);    color: var(--info);    }
.badge-muted   { background: var(--bg-hover);   color: var(--text-muted); }
.badge-tiktok  { background: var(--tiktok-bg);  color: var(--tiktok-color); }
.badge-facebook{ background: var(--facebook-bg);color: var(--facebook-color); }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody tr:hover td { background: var(--bg-elevated); color: var(--text-primary); }
tbody tr:last-child td { border-bottom: none; }

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

.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-md); }

.input-group { position: relative; }
.input-group input { padding-right: 44px; }
.input-group .input-suffix {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 16px; cursor: pointer;
}
.input-group .input-suffix:hover { color: var(--text-primary); }

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

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-lg);
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition-base);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
}
.modal-overlay.active .modal { transform: scale(1) translateY(0); }

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.modal-close:hover { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.3); }

.modal-body { padding: var(--space-lg); }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
}

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

.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 300px; max-width: 420px;
  pointer-events: all;
  transform: translateX(120%);
  transition: transform var(--transition-base);
}
.toast.show { transform: translateX(0); }
.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(--brand-primary); }

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast-content { flex: 1; }
.toast-title { font-size: 13.5px; font-weight: 600; }
.toast-message { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

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

.tabs {
  display: flex; gap: 2px;
  background: var(--bg-elevated);
  padding: 4px;
  border-radius: var(--radius-md);
  width: fit-content;
}

.tab-btn {
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   Progress & Charts Placeholders
   ============================================================ */

.progress-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--brand-gradient);
  border-radius: var(--radius-full);
  transition: width 0.8s ease;
}
.progress-fill.tiktok { background: var(--tiktok-color); }
.progress-fill.facebook { background: var(--facebook-color); }
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }

/* ============================================================
   Platform Tags
   ============================================================ */

.platform-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px; font-weight: 600;
}
.platform-tag.tiktok { background: var(--tiktok-bg); color: var(--tiktok-color); }
.platform-tag.facebook { background: var(--facebook-bg); color: var(--facebook-color); }

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

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
}
.empty-icon { font-size: 48px; margin-bottom: var(--space-md); opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.empty-desc { font-size: 13px; color: var(--text-muted); max-width: 320px; }

/* ============================================================
   Checkbox & Toggle
   ============================================================ */

.checkbox-wrap {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
}
.checkbox-wrap input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--brand-primary);
  cursor: pointer;
}

.toggle {
  position: relative;
  width: 40px; height: 22px;
  display: inline-block;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--bg-hover);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}
.toggle input:checked + .toggle-slider { background: var(--brand-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

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

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-lg); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-lg); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--space-lg); }

/* ============================================================
   Utility Classes
   ============================================================ */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary-color { color: var(--brand-primary); }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.border { border: 1px solid var(--border-subtle); }
.divider { height: 1px; background: var(--border-subtle); margin: var(--space-md) 0; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Responsive */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .page-content { padding: var(--space-md); }
}
