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

/* ─── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: rgba(20, 20, 35, 0.7);
  --bg-card-hover: rgba(30, 30, 50, 0.8);
  --bg-input: rgba(15, 15, 25, 0.8);
  --border: rgba(255, 255, 255, 0.06);
  --border-focus: rgba(139, 92, 246, 0.5);
  --text-primary: #f0f0f5;
  --text-secondary: #8888a0;
  --text-muted: #55556a;
  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.3);
  --accent-2: #6366f1;
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  --error: #ef4444;
  --error-glow: rgba(239, 68, 68, 0.3);
  --warn: #f59e0b;
  --warn-glow: rgba(245, 158, 11, 0.3);
  --gradient-1: linear-gradient(135deg, #8b5cf6, #6366f1, #3b82f6);
  --gradient-2: linear-gradient(135deg, #6366f1, #8b5cf6);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ─── Animated Background ─────────────────────────────────── */
.bg-effects {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-effects .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
  animation: float 20s ease-in-out infinite;
}

.bg-effects .orb-1 {
  width: 600px; height: 600px;
  background: #8b5cf6;
  top: -200px; right: -100px;
}

.bg-effects .orb-2 {
  width: 400px; height: 400px;
  background: #3b82f6;
  bottom: -100px; left: -100px;
  animation-delay: -7s;
}

.bg-effects .orb-3 {
  width: 300px; height: 300px;
  background: #6366f1;
  top: 50%; left: 50%;
  animation-delay: -14s;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ─── Login Page ──────────────────────────────────────────── */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 1;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow), var(--shadow-glow);
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card .logo { text-align: center; margin-bottom: 36px; }

.login-card .logo-icon {
  width: 72px; height: 72px;
  background: var(--gradient-1);
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3);
  animation: pulse-glow 3s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 8px 24px rgba(139, 92, 246, 0.3); }
  50% { box-shadow: 0 8px 40px rgba(139, 92, 246, 0.5); }
}

.login-card .logo h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.5px;
  background: var(--gradient-1);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card .logo p {
  color: var(--text-secondary); font-size: 14px; margin-top: 6px;
}

/* ─── Form Elements ───────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

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

.form-input {
  width: 100%; padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

textarea.form-input { resize: vertical; min-height: 100px; line-height: 1.5; }

select.form-input {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238888a0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  border: none; outline: none;
  position: relative; overflow: hidden;
}

.btn-primary {
  background: var(--gradient-1); color: white;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669); color: white;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4); }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626); color: white;
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(239, 68, 68, 0.4); }

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

.btn-google {
  background: white; color: #1f1f1f;
  border: 1px solid #ddd; font-weight: 500;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.btn-google:hover { background: #f8f8f8; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(0,0,0,0.15); }
.btn-google img { width: 18px; height: 18px; }

.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ─── Dashboard Layout ────────────────────────────────────── */
.app-container { position: relative; z-index: 1; min-height: 100vh; }

.app-header {
  background: rgba(10, 10, 15, 0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0 32px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 14px; }

.header-logo {
  width: 38px; height: 38px;
  background: var(--gradient-1);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.header-title { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.status-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
}

.status-badge.online {
  background: rgba(16, 185, 129, 0.12); color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.offline {
  background: rgba(239, 68, 68, 0.12); color: var(--error);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-badge.online .status-dot { animation: blink 1.5s ease-in-out infinite; }

@keyframes blink {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px currentColor; }
  50% { opacity: 0.4; box-shadow: none; }
}

.btn-logout {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 14px; border-radius: var(--radius-xs);
  font-family: 'Inter', sans-serif; font-size: 13px;
  cursor: pointer; transition: var(--transition);
}
.btn-logout:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3); color: var(--error);
}

/* ─── Tab Navigation ──────────────────────────────────────── */
.tab-navigation {
  display: flex;
  gap: 4px;
  padding: 16px 32px 0;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.main-tab {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 28px;
  background: rgba(20, 20, 35, 0.4);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.main-tab:hover {
  color: var(--text-secondary);
  background: rgba(30, 30, 50, 0.5);
}

.main-tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: rgba(139, 92, 246, 0.3);
  border-bottom: 1px solid transparent;
  box-shadow: 0 -4px 16px rgba(139, 92, 246, 0.1);
}

.main-tab .tab-icon {
  font-size: 18px;
}

.tab-content {
  display: none;
}

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

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

/* ─── Main Content ────────────────────────────────────────── */
.main-content { padding: 32px; max-width: 1400px; margin: 0 auto; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ─── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }

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

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

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

.card-title {
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}

.card-title .icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.card-title .icon.purple { background: rgba(139, 92, 246, 0.15); }
.card-title .icon.blue { background: rgba(59, 130, 246, 0.15); }
.card-title .icon.green { background: rgba(16, 185, 129, 0.15); }
.card-title .icon.orange { background: rgba(245, 158, 11, 0.15); }

.card-body { padding: 24px; }

/* ─── Video Preview ───────────────────────────────────────── */
.video-preview {
  display: flex; gap: 16px; padding: 16px;
  background: rgba(15, 15, 25, 0.5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 16px;
  animation: fadeIn 0.3s ease;
}

.video-preview img {
  width: 140px; height: 80px;
  border-radius: var(--radius-xs);
  object-fit: cover;
}

.video-info h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; line-height: 1.3; }
.video-info p { font-size: 12px; color: var(--text-secondary); }

.video-stats { display: flex; gap: 12px; margin-top: 8px; }
.video-stats span {
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}

/* ─── Comments List ───────────────────────────────────────── */
.comments-list {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 12px; max-height: 200px; overflow-y: auto;
}

.comment-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: rgba(15, 15, 25, 0.5);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  font-size: 13px;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.comment-item .text { flex: 1; color: var(--text-secondary); }

.comment-item .remove-btn {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 16px; padding: 4px;
  transition: var(--transition); border-radius: 4px;
}
.comment-item .remove-btn:hover { color: var(--error); background: rgba(239, 68, 68, 0.1); }

.add-comment-row { display: flex; gap: 8px; margin-top: 12px; }
.add-comment-row .form-input { flex: 1; }

/* ─── Frequency Controls ──────────────────────────────────── */
.freq-row { display: flex; gap: 12px; align-items: end; margin-top: 12px; }
.freq-row .form-group { flex: 1; margin-bottom: 0; }

.freq-type-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(15, 15, 25, 0.6);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.freq-tab, .ai-provider-tab {
  flex: 1; padding: 8px 16px;
  border: none; background: transparent;
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 500;
  border-radius: var(--radius-xs);
  cursor: pointer; transition: var(--transition);
}

.freq-tab.active, .ai-provider-tab.active {
  background: var(--accent); color: white;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.freq-tab:hover:not(.active), .ai-provider-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.05);
}

/* ─── Bot Controls ────────────────────────────────────────── */
.bot-controls { display: flex; gap: 12px; margin-top: 20px; }

.stats-row {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 20px;
}

.stat-card {
  padding: 16px;
  background: rgba(15, 15, 25, 0.5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: center;
}

.stat-value {
  font-size: 28px; font-weight: 700;
  background: var(--gradient-1);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  font-size: 12px; color: var(--text-muted); margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* ─── OAuth2 Section ──────────────────────────────────────── */
.oauth-status {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 16px;
}

.oauth-status.connected {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2); color: var(--success);
}

.oauth-status.disconnected {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2); color: var(--warn);
}

/* ─── Warning box ─────────────────────────────────────────── */
.warning-box {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--warn);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 16px;
  display: flex; gap: 12px; align-items: flex-start;
  animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.warning-box.hidden { display: none; }

/* ─── AI Test Result ──────────────────────────────────────── */
.ai-test-result {
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-secondary);
  animation: fadeIn 0.3s ease;
}

.ai-test-result .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.ai-test-result .reply {
  color: var(--success);
  font-weight: 500;
}

/* ─── Logs ────────────────────────────────────────────────── */
.card.logs-card { /* no grid-column needed since logs is outside grid */ }

.logs-container {
  max-height: 320px; overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 12px; line-height: 1.8;
}

.log-entry {
  padding: 6px 12px; border-radius: var(--radius-xs);
  display: flex; gap: 12px;
  animation: logSlide 0.2s ease;
}

@keyframes logSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.log-entry:hover { background: rgba(255, 255, 255, 0.02); }

.log-entry .log-time { color: var(--text-muted); white-space: nowrap; min-width: 70px; }
.log-entry .log-msg { flex: 1; }
.log-entry.info .log-msg { color: var(--text-secondary); }
.log-entry.success .log-msg { color: var(--success); }
.log-entry.error .log-msg { color: var(--error); }
.log-entry.warn .log-msg { color: var(--warn); }

/* ─── Custom Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ─── Toast Notifications ─────────────────────────────────── */
.toast-container {
  position: fixed; top: 80px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  backdrop-filter: blur(20px);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastOut 0.3s ease 2.7s forwards;
  box-shadow: var(--shadow);
}

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

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

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* ─── Error & spinner ─────────────────────────────────────── */
.error-msg { color: var(--error); font-size: 13px; min-height: 20px; margin-bottom: 8px; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

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

.hidden { display: none !important; }

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
  .app-header { padding: 0 16px; }
  .tab-navigation { padding: 12px 16px 0; }
  .main-tab { padding: 10px 16px; font-size: 13px; }
}
