/* Duskstone Design System: Seamless Dark/Light Canvas with Emerald Accents */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Readex+Pro:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root, [data-theme="dark"] {
  --bg-canvas: #09090b;
  --bg-surface: #121215;
  --bg-surface-elevated: #18181d;
  --border-subtle: #27272a;
  --border-highlight: #3f3f46;
  
  --emerald-primary: #10b981;
  --emerald-hover: #059669;
  --emerald-glow: rgba(16, 185, 129, 0.25);
  --emerald-subtle: rgba(16, 185, 129, 0.1);
  --emerald-border: rgba(16, 185, 129, 0.35);

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --heading-color: #ffffff;

  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.12);
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);

  --wa-bubble-in: #202c33;
  --wa-bubble-out: #005c4b;
  --wa-bg: #0b141a;
}

[data-theme="light"] {
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-highlight: #cbd5e1;

  --emerald-primary: #0d9488;
  --emerald-hover: #0f766e;
  --emerald-glow: rgba(13, 148, 136, 0.15);
  --emerald-subtle: rgba(13, 148, 136, 0.08);
  --emerald-border: rgba(13, 148, 136, 0.3);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --heading-color: #0f172a;

  --accent-cyan: #0284c7;
  --accent-purple: #7c3aed;
  --danger: #dc2626;
  --danger-subtle: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --warning-subtle: rgba(217, 119, 6, 0.08);
  --card-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);

  --wa-bubble-in: #ffffff;
  --wa-bubble-out: #d9fdd3;
  --wa-bg: #efeae2;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Readex Pro', 'IBM Plex Sans Arabic', -apple-system, sans-serif;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.6;
  padding: 24px;
  min-height: 100vh;
}

.dashboard-container {
  max-width: 1280px;
  margin: 0 auto;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  padding: 18px 24px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--card-shadow);
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--heading-color);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--emerald-primary), #06b6d4);
  color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px var(--emerald-glow);
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--emerald-subtle);
  color: var(--emerald-primary);
  border: 1px solid var(--emerald-border);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--emerald-primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-ctrl {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}

.btn-ctrl:hover {
  border-color: var(--border-highlight);
  background: var(--bg-surface);
}

.current-plan-badge {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(6, 182, 212, 0.15));
  border: 1px solid var(--emerald-border);
  color: var(--emerald-primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

/* Metrics Strip */
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 20px;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--border-subtle);
  transition: background 0.3s ease;
}

.metric-card.highlight-emerald::after {
  background: var(--emerald-primary);
}

.metric-card.highlight-cyan::after {
  background: var(--accent-cyan);
}

.metric-card.highlight-purple::after {
  background: var(--accent-purple);
}

.metric-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--heading-color);
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.metric-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.metric-subtext.positive {
  color: var(--emerald-primary);
}

/* Navigation Tabs */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  position: relative;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--emerald-primary);
  background: var(--bg-surface);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--emerald-primary);
  border-radius: 3px 3px 0 0;
}

/* Tab Content */
.tab-content {
  display: none;
}

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

/* Workflows Grid */
.workflows-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 24px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--heading-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Switch Toggle (iOS / Modern style) */
.switch-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border-highlight);
  transition: .3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--emerald-primary);
  box-shadow: 0 0 12px var(--emerald-glow);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

.status-badge-active {
  background: var(--emerald-subtle);
  color: var(--emerald-primary);
  border: 1px solid var(--emerald-border);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge-disabled {
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

/* Setting Row & Controls */
.settings-group {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--text-primary);
}

.setting-label-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.select-ctrl, .input-ctrl {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.select-ctrl:focus, .input-ctrl:focus {
  border-color: var(--emerald-primary);
}

/* WhatsApp Message Preview Box */
.whatsapp-preview-box {
  background: var(--wa-bg);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.wa-bubble {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  position: relative;
}

.wa-bubble.outbound {
  align-self: flex-start;
  background: var(--wa-bubble-out);
  color: #f1f5f9;
  border-top-right-radius: 0;
}

[dir="ltr"] .wa-bubble.outbound {
  align-self: flex-end;
  border-top-right-radius: 10px;
  border-top-left-radius: 0;
}

.wa-bubble.inbound {
  align-self: flex-end;
  background: var(--wa-bubble-in);
  color: var(--text-primary);
  border-top-left-radius: 0;
}

[dir="ltr"] .wa-bubble.inbound {
  align-self: flex-start;
  border-top-left-radius: 10px;
  border-top-right-radius: 0;
}

.wa-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.wa-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: default;
}

[data-theme="light"] .wa-btn {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.1);
  color: #0f172a;
}

.wa-time {
  font-size: 10px;
  opacity: 0.7;
  text-align: left;
  margin-top: 4px;
}

[dir="ltr"] .wa-time {
  text-align: right;
}

/* AI Simulator Layout */
.simulator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .simulator-layout {
    grid-template-columns: 1fr;
  }
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.chip-btn:hover {
  background: var(--emerald-subtle);
  color: var(--emerald-primary);
  border-color: var(--emerald-border);
}

.chat-input-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.chat-input {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
}

.chat-input:focus {
  border-color: var(--emerald-primary);
}

.btn-send {
  background: var(--emerald-primary);
  color: white;
  border: none;
  padding: 0 20px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-send:hover {
  background: var(--emerald-hover);
}

.result-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-tag-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.tag-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Logs Table */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13.5px;
}

[dir="ltr"] .data-table {
  text-align: left;
}

.data-table th {
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  padding: 14px 18px;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Pricing Grid */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.pricing-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 32px 24px;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--card-shadow);
}

.pricing-card.featured {
  border-color: var(--emerald-primary);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.04) 0%, var(--bg-surface) 100%);
  box-shadow: 0 8px 30px var(--emerald-glow);
}

.featured-pill {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--emerald-primary);
  color: white;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.pricing-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--heading-color);
  margin-bottom: 8px;
}

.pricing-cost {
  font-size: 38px;
  font-weight: 800;
  color: var(--heading-color);
  margin: 16px 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.pricing-features {
  list-style: none;
  margin: 20px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pricing-features li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 14px;
  color: var(--text-secondary);
}

.pricing-features li span.check {
  color: var(--emerald-primary);
  font-weight: bold;
}

.btn-plan {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-highlight);
  color: var(--text-primary);
  padding: 12px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.btn-plan:hover {
  background: var(--emerald-subtle);
  border-color: var(--emerald-primary);
  color: var(--emerald-primary);
}

.btn-plan.featured-btn {
  background: var(--emerald-primary);
  color: white;
  border: none;
}

.btn-plan.featured-btn:hover {
  background: var(--emerald-hover);
}

/* Toast Alerts */
.toast-notice {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--emerald-border);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  font-size: 14px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s ease;
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* Courier badges */
.courier-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.courier-pill {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
