/* ─────────────────────────────────────────────────────────
   CloudWapp Design System
   Dark-mode-first, glassmorphism, modern SaaS aesthetic
   ───────────────────────────────────────────────────────── */

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

/* ─── Tokens ─────────────────────────────────────────── */
:root {
  --bg-primary: #06060f;
  --bg-secondary: #0d0d1a;
  --bg-card: rgba(255,255,255,0.04);
  --bg-card-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --text-primary: #f0f0f5;
  --text-secondary: #8888aa;
  --text-muted: #555577;
  --accent: #6c63ff;
  --accent-light: #8b83ff;
  --cyan: #00d9ff;
  --green: #00e676;
  --orange: #ff9100;
  --red: #ff5252;
  --pink: #ff4081;
  --gradient-primary: linear-gradient(135deg, #6c63ff 0%, #00d9ff 100%);
  --gradient-hero: linear-gradient(135deg, #0a0a2e 0%, #1a0a3e 50%, #0a1a2e 100%);
  --gradient-card: linear-gradient(135deg, rgba(108,99,255,0.08) 0%, rgba(0,217,255,0.05) 100%);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 64px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px rgba(108,99,255,0.15);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ─── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--cyan); }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; }
code { font-family: var(--font-mono); font-size: 0.9em; }

/* ─── Layout ─────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.section { padding: 100px 0; }
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.gap-xl { gap: 40px; }
.text-center { text-align: center; }

/* ─── Typography ─────────────────────────────────────── */
h1, h2, h3, h4 { font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: clamp(2.5rem, 5vw, 4rem); }
h2 { font-size: clamp(2rem, 3.5vw, 2.8rem); }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
.subtitle { font-size: 1.15rem; color: var(--text-secondary); max-width: 600px; line-height: 1.8; }
.label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-light); }
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 28px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.95rem;
  transition: var(--transition);
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--gradient-primary); color: #fff;
  box-shadow: 0 4px 20px rgba(108,99,255,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(108,99,255,0.4); }
.btn-secondary {
  background: transparent; color: var(--text-primary);
  border-color: var(--border-hover);
}
.btn-secondary:hover { border-color: var(--accent); background: rgba(108,99,255,0.1); }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #ff3333; }
.btn-success { background: var(--green); color: #000; }

/* ─── Cards ──────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
  transition: var(--transition);
  backdrop-filter: blur(12px);
}
.card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
  transform: translateY(-4px);
}
.card-icon {
  width: 52px; height: 52px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--gradient-card);
  font-size: 1.5rem; margin-bottom: 16px;
}
.card-flat { background: var(--bg-secondary); border-color: var(--border); }
.card-flat:hover { transform: none; }

/* ─── Navigation ─────────────────────────────────────── */
.navbar {
  position: fixed; top: 0; width: 100%; z-index: 1000;
  padding: 16px 0;
  background: rgba(6,6,15,0.8);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  transition: var(--transition);
}
.navbar .container { display: flex; align-items: center; justify-content: space-between; }
.logo { font-size: 1.4rem; font-weight: 800; display: flex; align-items: center; gap: 10px; color: var(--text-primary); }
.logo span { background: var(--gradient-primary); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nav-links { display: flex; align-items: center; gap: 32px; list-style: none; }
.nav-links a { color: var(--text-secondary); font-weight: 500; font-size: 0.95rem; }
.nav-links a:hover { color: var(--text-primary); }

/* ─── Hero ───────────────────────────────────────────── */
.hero {
  min-height: 100vh; display: flex; align-items: center;
  background: var(--gradient-hero);
  position: relative; overflow: hidden;
  padding-top: 80px;
}
.hero::before {
  content: ''; position: absolute; top: -50%; right: -20%;
  width: 800px; height: 800px; border-radius: 50%;
  background: radial-gradient(circle, rgba(108,99,255,0.12) 0%, transparent 70%);
  animation: pulse 8s ease-in-out infinite;
}
.hero::after {
  content: ''; position: absolute; bottom: -30%; left: -10%;
  width: 600px; height: 600px; border-radius: 50%;
  background: radial-gradient(circle, rgba(0,217,255,0.08) 0%, transparent 70%);
  animation: pulse 10s ease-in-out infinite reverse;
}
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.5; } 50% { transform: scale(1.1); opacity: 1; } }
.hero-content { position: relative; z-index: 1; }

/* ─── Badge ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 100px;
  font-size: 0.8rem; font-weight: 600;
  border: 1px solid var(--border);
  background: rgba(108,99,255,0.08);
  color: var(--accent-light);
}
.badge-green { background: rgba(0,230,118,0.08); color: var(--green); border-color: rgba(0,230,118,0.2); }
.badge-cyan { background: rgba(0,217,255,0.08); color: var(--cyan); border-color: rgba(0,217,255,0.2); }
.badge-orange { background: rgba(255,145,0,0.08); color: var(--orange); border-color: rgba(255,145,0,0.2); }

/* ─── Code Block ─────────────────────────────────────── */
.code-wrapper {
  position: relative;
  margin-top: 0.5rem;
}
.code-block {
  background: #0d0d1f;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 20px 20px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.55;
  color: #c5c8d4;
  white-space: pre;
  tab-size: 2;
  margin: 0;
}
.code-block .comment { color: #6b7280; font-style: italic; }
.code-block .keyword { color: #c084fc; }
.code-block .string { color: #4ade80; }
.code-block .function { color: #22d3ee; }
.code-block .number { color: #fb923c; }
.code-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.code-copy:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text-primary);
}
.code-copy.copied {
  background: rgba(0,230,118,0.15);
  border-color: rgba(0,230,118,0.4);
  color: var(--green);
}

/* ─── Messages inbox (dashboard) ─────────────────────── */
.msg-toolbar { padding: 16px; }
.msg-toolbar-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.msg-field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.msg-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.msg-tabs { display: flex; gap: 4px; margin-top: 14px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.msg-tab {
  background: transparent; border: 0; color: var(--text-secondary); cursor: pointer;
  padding: 10px 18px; font-size: 0.9rem; font-family: inherit;
  border-bottom: 2px solid transparent; transition: var(--transition);
  display: inline-flex; gap: 8px; align-items: center;
}
.msg-tab:hover { color: var(--text-primary); }
.msg-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.msg-tab-count {
  background: var(--bg-secondary); border-radius: 999px;
  padding: 1px 8px; font-size: 0.72rem; color: var(--text-muted);
}
.msg-tab.active .msg-tab-count { background: rgba(0,217,255,0.15); color: var(--accent); }

.msg-list { display: flex; flex-direction: column; gap: 6px; }
.msg-empty {
  padding: 60px 20px; text-align: center; color: var(--text-muted);
  background: var(--bg-secondary); border-radius: var(--radius-md); border: 1px dashed var(--border);
}
.msg-row {
  display: grid; grid-template-columns: 32px 1fr; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-md);
  background: var(--bg-secondary); border: 1px solid var(--border);
  transition: var(--transition);
}
.msg-row:hover { background: var(--bg-card); }
.msg-row.inbound { border-left: 3px solid var(--green); }
.msg-row.outbound { border-left: 3px solid var(--accent); }
.msg-arrow { font-size: 1.4rem; line-height: 1; padding-top: 2px; opacity: 0.7; }
.msg-row.inbound .msg-arrow { color: var(--green); }
.msg-row.outbound .msg-arrow { color: var(--accent); }
.msg-main { min-width: 0; }
.msg-head {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 4px;
}
.msg-contact {
  font-family: var(--font-mono); font-size: 0.85rem;
  color: var(--text-primary); font-weight: 600;
}
.msg-type {
  font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.msg-time { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.msg-text {
  color: var(--text-secondary); font-size: 0.9rem; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
.msg-error { margin-top: 6px; font-size: 0.78rem; color: var(--red); }
.msg-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* ─── Table ──────────────────────────────────────────── */
.table-container { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 18px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-secondary); background: var(--bg-secondary); }
td { font-size: 0.9rem; }
tr:hover td { background: var(--bg-card); }

/* ─── Pricing ────────────────────────────────────────── */
.pricing-card { text-align: center; position: relative; overflow: hidden; }
.pricing-card.featured { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.pricing-card.featured::before {
  content: 'POPULAR'; position: absolute; top: 16px; right: -28px;
  background: var(--gradient-primary); color: #fff;
  padding: 4px 40px; font-size: 0.7rem; font-weight: 700;
  transform: rotate(45deg); letter-spacing: 0.08em;
}
.price { font-size: 3rem; font-weight: 800; margin: 16px 0 8px; }
.price small { font-size: 1rem; color: var(--text-secondary); font-weight: 400; }
.pricing-features { list-style: none; text-align: left; margin: 24px 0; }
.pricing-features li { padding: 8px 0; color: var(--text-secondary); display: flex; align-items: center; gap: 10px; }
.pricing-features li::before { content: '✓'; color: var(--green); font-weight: 700; }

/* ─── Steps ──────────────────────────────────────────── */
.step { position: relative; padding-left: 80px; }
.step-number {
  position: absolute; left: 0; top: 0;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--gradient-card);
  border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800; color: var(--accent-light);
}

/* ─── Footer ─────────────────────────────────────────── */
.footer { border-top: 1px solid var(--border); padding: 60px 0 30px; }
.footer-bottom { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.85rem; }

/* ─── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; color: var(--text-secondary); }
.form-input {
  width: 100%; padding: 12px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: var(--transition);
}
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108,99,255,0.15); }
.form-input::placeholder { color: var(--text-muted); }

/* ─── Dashboard Layout ───────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; padding-top: 65px; }
.sidebar {
  width: 260px; min-height: calc(100vh - 65px);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 24px 0; position: fixed; top: 65px; left: 0;
  overflow-y: auto;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 24px; color: var(--text-secondary);
  font-weight: 500; font-size: 0.9rem;
  transition: var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav li a:hover, .sidebar-nav li a.active {
  color: var(--text-primary);
  background: var(--bg-card);
  border-left-color: var(--accent);
}
.main-content { flex: 1; margin-left: 260px; padding: 32px; }
.page-header { margin-bottom: 32px; }
.page-header h1 { font-size: 1.8rem; }

/* ─── Stats ──────────────────────────────────────────── */
.stat-card { padding: 24px; }
.stat-value { font-size: 2.2rem; font-weight: 800; margin: 8px 0 4px; }
.stat-label { font-size: 0.85rem; color: var(--text-secondary); }

/* ─── Status Indicators ─────────────────────────────── */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 500; }
.status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.status-connected::before { background: var(--green); box-shadow: 0 0 8px var(--green); }
.status-disconnected::before { background: var(--text-muted); }
.status-connecting::before { background: var(--orange); animation: blink 1s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ─── Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 2000;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 32px;
  width: 90%; max-width: 500px; max-height: 90vh; overflow-y: auto;
}
.modal h2 { font-size: 1.4rem; margin-bottom: 20px; }

/* ─── Toast ──────────────────────────────────────────── */
.toast-container { position: fixed; top: 80px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500;
  animation: slideIn 0.3s ease;
  min-width: 300px;
}
.toast-success { background: rgba(0,230,118,0.15); border: 1px solid rgba(0,230,118,0.3); color: var(--green); }
.toast-error { background: rgba(255,82,82,0.15); border: 1px solid rgba(255,82,82,0.3); color: var(--red); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Tabs ───────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 12px 20px; font-weight: 500; font-size: 0.9rem;
  color: var(--text-secondary); background: transparent;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Auth Screen ────────────────────────────────────── */
.auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--gradient-hero);
}
.auth-card { width: 100%; max-width: 420px; }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .section { padding: 60px 0; }
  .hero { padding-top: 100px; min-height: auto; }
  .grid-3 { grid-template-columns: 1fr; }
  .step { padding-left: 60px; }
  .step-number { width: 44px; height: 44px; font-size: 1rem; }
}

/* ─── Utilities ──────────────────────────────────────── */
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
