/* ==========================================
   PHONE FRAME
   ========================================== */
.phone-frame {
  width: 280px;
  height: 560px;
  background: #000;
  border-radius: 36px;
  padding: 8px;
  position: relative;
  box-shadow: var(--shadow-xl), inset 0 0 0 2px rgba(255,255,255,0.1);
}

.phone-screen {
  width: 100%;
  height: 100%;
  border-radius: 28px;
  overflow: hidden;
  background: var(--wa-bg);
  display: flex;
  flex-direction: column;
}

.phone-notch {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 28px;
  background: #000;
  border-radius: 0 0 16px 16px;
  z-index: 2;
}

/* WhatsApp Header */
.wa-header {
  background: var(--wa-header);
  padding: 36px 12px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  flex-shrink: 0;
}

.wa-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.wa-contact-info {
  flex: 1;
}

.wa-contact-name {
  font-size: 13px;
  font-weight: 600;
}

.wa-contact-status {
  font-size: 10px;
  opacity: 0.8;
}

.wa-header-icons {
  display: flex;
  gap: 14px;
  font-size: 14px;
  opacity: 0.9;
}

/* WhatsApp Chat Area */
.wa-chat {
  flex: 1;
  padding: 8px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wa-date-label {
  align-self: center;
  background: rgba(0,0,0,0.06);
  color: var(--wa-time);
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 6px;
  margin: 4px 0;
}

/* Chat Bubbles */
.wa-bubble {
  max-width: 85%;
  padding: 6px 8px 4px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  position: relative;
  word-wrap: break-word;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.3s ease;
}

.wa-bubble.visible {
  opacity: 1;
  transform: translateY(0);
}

.wa-bubble-incoming {
  background: var(--wa-incoming);
  align-self: flex-start;
  border-top-left-radius: 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}

.wa-bubble-outgoing {
  background: var(--wa-outgoing);
  align-self: flex-end;
  border-top-right-radius: 2px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
}

.wa-bubble-text {
  margin-bottom: 2px;
  color: #303030;
}

.wa-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 9px;
  color: var(--wa-time);
}

.wa-check {
  color: var(--wa-check);
  font-size: 10px;
}

/* Typing Indicator */
.wa-typing {
  background: var(--wa-incoming);
  align-self: flex-start;
  padding: 10px 14px;
  border-radius: 8px;
  border-top-left-radius: 2px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.wa-typing.visible {
  opacity: 1;
}

.wa-typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.wa-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.wa-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* WhatsApp Input Bar */
.wa-input-bar {
  background: var(--bg-off-white);
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wa-input-field {
  flex: 1;
  background: #fff;
  border-radius: 20px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.wa-send-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--wa-header);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}


/* ==========================================
   BROWSER FRAME
   ========================================== */
.browser-frame {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.browser-toolbar {
  background: var(--bg-off-white);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
}

.browser-dots {
  display: flex;
  gap: 6px;
}

.browser-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.browser-dots span:nth-child(1) { background: #ff5f57; }
.browser-dots span:nth-child(2) { background: #ffbd2e; }
.browser-dots span:nth-child(3) { background: #28c840; }

.browser-url {
  flex: 1;
  background: #fff;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

.browser-content {
  padding: var(--space-lg);
  min-height: 280px;
}


/* ==========================================
   DASHBOARD COMPONENTS (inside browser frames)
   ========================================== */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: var(--space-lg);
}

.dash-stat-card {
  background: var(--bg-off-white);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}

.dash-stat-value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--primary);
}

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

/* Bar Chart */
.dash-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  padding: 8px 0;
}

.dash-bar {
  flex: 1;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  min-height: 8px;
  opacity: 0.8;
  transition: height 0.6s ease;
}

.dash-bar:nth-child(even) {
  background: var(--accent);
}

/* Conversation List */
.dash-conv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-off-white);
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.dash-conv-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

.dash-conv-info {
  flex: 1;
  min-width: 0;
}

.dash-conv-name {
  font-weight: 600;
  color: var(--text-dark);
  font-size: 11px;
}

.dash-conv-preview {
  color: var(--text-muted);
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dash-conv-time {
  font-size: 9px;
  color: var(--text-light);
  flex-shrink: 0;
}

.dash-conv-badge {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* Calendar Grid */
.dash-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  font-size: 10px;
  text-align: center;
}

.dash-calendar .day-header {
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0;
  font-size: 9px;
}

.dash-calendar .day {
  padding: 4px;
  border-radius: 4px;
  color: var(--text-body);
}

.dash-calendar .day.has-event {
  background: rgba(139, 195, 74, 0.2);
  color: var(--accent-dark);
  font-weight: 700;
}

.dash-calendar .day.today {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

/* Settings Panel */
.dash-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg-off-white);
  border-radius: var(--radius-sm);
  font-size: 11px;
}

.dash-setting-label {
  font-weight: 600;
  color: var(--text-dark);
}

.dash-toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--accent);
  position: relative;
}

.dash-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
}

.dash-toggle.off {
  background: var(--border);
}

.dash-toggle.off::after {
  right: auto;
  left: 3px;
}

.dash-input-mock {
  padding: 4px 8px;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-muted);
  min-width: 100px;
  text-align: right;
}

/* Integration Cards (small) */
.dash-integrations {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dash-integration-card {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-off-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.dash-integration-icon {
  font-size: 20px;
  margin-bottom: 4px;
}

.dash-integration-icon svg {
  width: 20px;
  height: 20px;
}

.dash-integration-name {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-dark);
}

/* Workflow Nodes */
.dash-workflow {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 10px;
}

.dash-node {
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  min-width: 70px;
}

.dash-node-trigger {
  background: #e8eaf6;
  color: #283593;
  border: 1px solid #c5cae9;
}

.dash-node-action {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.dash-node-output {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffe0b2;
}

.dash-arrow {
  font-size: 14px;
  color: var(--text-muted);
}

/* Rules Editor */
.dash-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dash-rule {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg-off-white);
  border-radius: var(--radius-sm);
  font-size: 10px;
  border-left: 3px solid var(--accent);
}

.dash-rule-keyword {
  font-weight: 700;
  color: var(--primary);
}

.dash-rule-arrow {
  color: var(--text-light);
}

.dash-rule-action {
  color: var(--accent-dark);
  font-weight: 600;
}

/* CRM Table */
.dash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.dash-table th {
  background: var(--primary);
  color: #fff;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
  font-size: 9px;
}

.dash-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-body);
}

.dash-table tr:nth-child(even) {
  background: var(--bg-off-white);
}

/* Multi-language mockup */
.wa-bubble-lang {
  font-size: 8px;
  color: var(--text-light);
  margin-bottom: 2px;
}

/* Phone floating animation */
.phone-float {
  animation: phone-float 4s ease-in-out infinite;
}

@keyframes phone-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ===================== */
/* N8N-STYLE WORKFLOW    */
/* ===================== */
.wf-window {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: #f9f9f9;
}

/* Title bar */
.wf-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
}
.wf-dots { display: flex; gap: 5px; }
.wf-dots span { width: 10px; height: 10px; border-radius: 50%; background: #ddd; }
.wf-title { flex: 1; font-size: 12px; font-weight: 600; color: var(--text-dark); }
.wf-status {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 9px;
  background: rgba(139,195,74,.15); color: var(--accent-dark);
}

/* Canvas area — dot grid, horizontal scroll */
.wf-canvas {
  position: relative;
  padding: 24px 28px;
  background-image: radial-gradient(#d6d6d6 1px, transparent 1px);
  background-size: 18px 18px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

/* SVG lines layer */
.wf-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Node card ---------- */
.wf-nd {
  position: absolute;
  width: 110px;
  text-align: center;
  z-index: 1;
  cursor: default;
}

.wf-card {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border-radius: 14px;
  background: #fff;
  border: 1.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: box-shadow .25s, border-color .25s, transform .25s;
}

.wf-nd:hover .wf-card {
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  border-color: #94a3b8;
  transform: translateY(-2px);
}

.wf-port {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  border: 1.5px solid #fff;
  z-index: 2;
}
.wf-port-l { left: calc(50% - 30px); top: 22px; }
.wf-port-r { right: calc(50% - 30px); top: 22px; }

.wf-label {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
  line-height: 1.2;
}

/* Branch label tags */
.wf-tag {
  position: absolute;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 2px 7px;
  border-radius: 6px;
  z-index: 3;
  pointer-events: none;
}

/* ---------- Node positions (S-shape with branch) ---------- */
/*
  Row 1 (left → right):
  [WhatsApp] → [AI Agent] → [Customer DB] → [Existing/New?] ─→ [Load History]
                                                              ╲
                                                               → [Collect & Store]
  Both branches merge ↓
  Row 2 (right → left):
  [Book Apt] ← [Calendar] ← [Booking?] ← [Smart Reply]

  Row 3 (left → right):
  [Google Meet] → [Notify Cust] → [Notify Client] → [Save DB] → [AI Training]
*/

/* Row 1: left → right (centered: 35px margins each side) */
.wf-n1  { left: 35px;  top: 16px; }
.wf-n2  { left: 215px; top: 16px; }
.wf-n3  { left: 395px; top: 16px; }
.wf-n4  { left: 575px; top: 16px; }
.wf-n5a { left: 755px; top: 16px; }

/* Branch: new customer path */
.wf-n5b { left: 755px; top: 115px; }

/* Row 2: right → left */
.wf-n6  { left: 575px; top: 220px; }
.wf-n7  { left: 395px; top: 220px; }
.wf-n8  { left: 215px; top: 220px; }
.wf-n9  { left: 35px;  top: 220px; }

/* Row 3: left → right */
.wf-n10 { left: 35px;  top: 345px; }
.wf-n11 { left: 215px; top: 345px; }
.wf-n12 { left: 395px; top: 345px; }
.wf-n13 { left: 575px; top: 345px; }
.wf-n14 { left: 755px; top: 345px; }

/* Canvas sizing — tightly fit the 15-node layout */
.wf-canvas {
  min-height: 440px;
  width: 900px;
  max-width: 100%;
  margin: 0 auto;
  overflow-x: auto;
}

/* Bottom bar */
.wf-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 14px; background: #fff;
  border-top: 1px solid var(--border-light);
  font-size: 10px; color: var(--text-muted);
}
.wf-bar-tag {
  padding: 2px 8px; border-radius: 9px;
  background: rgba(33,50,94,.08); color: var(--primary);
  font-weight: 600; font-size: 9px; text-transform: uppercase; letter-spacing: .5px;
}

/* ---------- Animations ---------- */
.n8n-anim {
  opacity: 0;
  transform: translateX(-12px) scale(.96);
  transition: opacity .35s ease, transform .35s ease;
}
.n8n-anim.n8n-visible {
  opacity: 1;
  transform: translateX(0) scale(1);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .wf-canvas {
    min-height: auto !important;
    min-width: 0 !important;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .wf-nd {
    position: static !important;
    width: 100% !important;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
  }
  .wf-card {
    margin: 0;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
  }
  .wf-label { margin-top: 0; }
  .wf-port { display: none; }
  .wf-lines { display: none; }
  .wf-tag { display: none; }
}
