/* ============================================================
   Zayado Extension — CSS Plugin WordPress
   ============================================================ */

:root {
  --zd-white:     #FFFFFF;
  --zd-beige:     #F5F5F0;
  --zd-blue-lt:   #E8F4F8;
  --zd-blue:      #1E3A8A;
  --zd-blue-mid:  #2563EB;
  --zd-blue-soft: #3B82F6;
  --zd-red:       #DC2626;
  --zd-gold:      #D4A574;
  --zd-border:    #E5E5E5;
  --zd-muted:     #6B7280;
  --zd-sidebar:   240px;
  --zd-radius:    12px;
  --zd-font:      'Sora', -apple-system, BlinkMacSystemFont, sans-serif;
  --zd-mono:      'JetBrains Mono', 'Fira Code', monospace;
}

/* ── Wrapper global ─────────────────────────────────────── */
#zayado-app { font-family: var(--zd-font); color: var(--zd-blue); line-height: 1.5; }
#zayado-app * { box-sizing: border-box; }

.zd-layout {
  display: flex;
  height: 80vh;
  min-height: 600px;
  border: 1.5px solid var(--zd-border);
  border-radius: var(--zd-radius);
  overflow: hidden;
  background: var(--zd-beige);
  box-shadow: 0 4px 24px rgba(30,58,138,0.08);
}

/* ── Sidebar ────────────────────────────────────────────── */
.zd-sidebar {
  width: var(--zd-sidebar);
  background: var(--zd-white);
  border-right: 1.5px solid var(--zd-border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  flex-shrink: 0;
  overflow-y: auto;
}

.zd-logo {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px 14px;
  border-bottom: 1px solid var(--zd-border);
  margin-bottom: 10px;
}

.zd-logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--zd-blue), var(--zd-blue-mid));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 17px;
  box-shadow: 0 2px 8px rgba(30,58,138,0.3);
}

.zd-logo-text { font-size: 14px; font-weight: 700; color: var(--zd-blue); }
.zd-logo-text span { color: var(--zd-red); }

.zd-nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--zd-muted);
  padding: 10px 10px 4px;
}

.zd-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--zd-muted);
  transition: all 0.15s;
  margin-bottom: 1px;
  position: relative;
}
.zd-nav-item:hover { background: var(--zd-beige); color: var(--zd-blue); }
.zd-nav-item.active { background: var(--zd-blue-lt); color: var(--zd-blue); font-weight: 600; }
.zd-nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--zd-blue);
  border-radius: 0 3px 3px 0;
}

.zd-sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--zd-border);
}

.zd-credits-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--zd-blue);
  padding: 6px 10px;
  background: var(--zd-blue-lt);
  border-radius: 8px;
  margin-bottom: 8px;
}
.zd-credits-dot { width: 7px; height: 7px; background: var(--zd-blue-soft); border-radius: 50%; flex-shrink: 0; }

.zd-plan-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--zd-blue), var(--zd-blue-mid));
  color: white;
  margin-bottom: 8px;
}

.zd-btn-upgrade {
  width: 100%;
  background: var(--zd-red);
  color: white;
  border: none;
  padding: 9px;
  border-radius: 9px;
  font-family: var(--zd-font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.zd-btn-upgrade:hover { opacity: 0.9; }

/* ── Main content ───────────────────────────────────────── */
.zd-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Mode bar ───────────────────────────────────────────── */
.zd-mode-bar {
  background: var(--zd-white);
  border-bottom: 1.5px solid var(--zd-border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.zd-mode-tabs { display: flex; gap: 4px; background: var(--zd-beige); padding: 4px; border-radius: 10px; }

.zd-mode-tab {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--zd-font);
  font-size: 12px;
  font-weight: 500;
  color: var(--zd-muted);
  background: transparent;
  white-space: nowrap;
  transition: all 0.2s;
}
.zd-mode-tab.active {
  background: var(--zd-white);
  color: var(--zd-blue);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(30,58,138,0.12);
}
.zd-mode-info { font-size: 12px; color: var(--zd-muted); }

/* ── Views ──────────────────────────────────────────────── */
.zd-view { display: none; flex: 1; flex-direction: column; overflow: hidden; }
.zd-view.active { display: flex; }

/* ── Chat ───────────────────────────────────────────────── */
.zd-chat-container { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

.zd-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.zd-messages::-webkit-scrollbar { width: 4px; }
.zd-messages::-webkit-scrollbar-thumb { background: var(--zd-border); border-radius: 4px; }

.zd-msg { display: flex; gap: 10px; align-items: flex-start; }
.zd-msg-user { flex-direction: row-reverse; }

.zd-msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.zd-msg-assistant .zd-msg-avatar { background: linear-gradient(135deg, var(--zd-blue), var(--zd-blue-mid)); color: white; }
.zd-msg-user .zd-msg-avatar { background: linear-gradient(135deg, var(--zd-red), #F87171); color: white; }

.zd-msg-body { max-width: 72%; }

.zd-msg-content {
  padding: 12px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.65;
}
.zd-msg-assistant .zd-msg-content {
  background: var(--zd-white);
  border: 1px solid var(--zd-border);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.zd-msg-user .zd-msg-content {
  background: var(--zd-blue);
  color: white;
  border-top-right-radius: 4px;
}

.zd-mode-tag {
  display: inline-block;
  font-size: 10px; font-weight: 600;
  padding: 2px 9px;
  border-radius: 20px;
  margin-bottom: 5px;
}
.tag-fast   { background: #FEF3C7; color: #92400E; }
.tag-pro    { background: var(--zd-blue-lt); color: var(--zd-blue); }
.tag-agent  { background: #FEE2E2; color: #991B1B; }
.tag-chatgpt{ background: #ECFDF5; color: #065F46; }
.tag-opus   { background: #F3E8FF; color: #6B21A8; }

.zd-msg-actions {
  display: flex; gap: 6px; margin-top: 6px;
}
.zd-msg-actions button {
  background: var(--zd-beige);
  border: 1px solid var(--zd-border);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--zd-muted);
}
.zd-msg-actions button:hover { background: var(--zd-blue-lt); color: var(--zd-blue); border-color: var(--zd-blue-soft); }

/* Cursor streaming */
@keyframes zdBlink { 0%,100%{opacity:1} 50%{opacity:0} }
.zd-cursor { display: inline-block; width: 2px; height: 14px; background: var(--zd-blue); animation: zdBlink 1s infinite; vertical-align: middle; margin-left: 2px; }

/* Code blocks */
.zd-code { background: #0F172A; color: #E2E8F0; padding: 12px; border-radius: 8px; font-family: var(--zd-mono); font-size: 12px; overflow-x: auto; margin: 8px 0; white-space: pre-wrap; }
.zd-inline-code { background: #F1F5F9; color: #DC2626; padding: 1px 6px; border-radius: 4px; font-family: var(--zd-mono); font-size: 12px; }

/* Typing indicator */
.zd-typing { display: flex; align-items: center; gap: 4px; padding: 10px 14px; background: var(--zd-white); border: 1px solid var(--zd-border); border-radius: 14px; border-top-left-radius: 4px; }
.zd-typing span { width: 6px; height: 6px; background: var(--zd-blue-soft); border-radius: 50%; animation: zdBounce 1.2s infinite; }
.zd-typing span:nth-child(2) { animation-delay: 0.2s; }
.zd-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes zdBounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }

/* Agent status */
.zd-agent-status { font-size: 13px; }
.zd-agent-progress { height: 4px; background: var(--zd-border); border-radius: 4px; margin: 8px 0; overflow: hidden; }
.zd-agent-progress-bar { height: 100%; background: linear-gradient(90deg, var(--zd-blue), var(--zd-blue-mid)); border-radius: 4px; transition: width 0.5s; }
.zd-agent-steps { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.zd-agent-step { display: flex; gap: 8px; font-size: 12px; }
.zd-step-icon { width: 18px; height: 18px; border-radius: 50%; background: var(--zd-blue); color: white; display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }
.zd-step-result { background: var(--zd-beige); border-radius: 6px; padding: 6px 8px; margin-top: 4px; font-size: 11px; color: var(--zd-muted); }
.zd-agent-summary { background: var(--zd-blue-lt); border-radius: 8px; padding: 12px; margin-top: 10px; font-size: 13px; }

/* ── Input zone ─────────────────────────────────────────── */
.zd-input-zone {
  background: var(--zd-white);
  border-top: 1.5px solid var(--zd-border);
  padding: 14px 16px;
  flex-shrink: 0;
}

.zd-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--zd-beige);
  border: 1.5px solid var(--zd-border);
  border-radius: 12px;
  padding: 10px 12px;
  transition: border-color 0.2s;
}
.zd-input-wrap:focus-within { border-color: var(--zd-blue-mid); box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }

#zd-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--zd-font);
  font-size: 13.5px;
  color: var(--zd-blue);
  resize: none;
  outline: none;
  min-height: 22px;
  max-height: 140px;
  line-height: 1.5;
}
#zd-input::placeholder { color: #9CA3AF; }

.zd-input-actions { display: flex; gap: 6px; }

.zd-btn-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--zd-blue);
  color: white;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  transition: all 0.2s;
  box-shadow: 0 2px 6px rgba(30,58,138,0.3);
}
.zd-btn-icon:hover { background: var(--zd-blue-mid); transform: scale(1.05); }

.zd-input-footer { display: flex; justify-content: space-between; margin-top: 7px; font-size: 11px; color: var(--zd-muted); }

/* ── Sections ───────────────────────────────────────────── */
.zd-view { padding: 0; }
.zd-view#view-projects,
.zd-view#view-history,
.zd-view#view-billing,
.zd-view#view-settings,
.zd-view#view-workflows { overflow-y: auto; padding: 20px; background: var(--zd-beige); }

.zd-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.zd-section-header h2 { font-size: 20px; font-weight: 700; color: var(--zd-blue); }

/* ── Projets ─────────────────────────────────────────────── */
.zd-projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }

.zd-project-card {
  background: var(--zd-white);
  border: 1px solid var(--zd-border);
  border-radius: 12px;
  padding: 14px 16px;
  transition: all 0.15s;
}
.zd-project-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.07); transform: translateY(-1px); }

.zd-project-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.zd-project-header h3 { font-size: 13px; font-weight: 700; margin: 0; }
.zd-project-actions { display: flex; gap: 4px; }

.zd-btn-icon-sm { background: none; border: 1px solid var(--zd-border); padding: 3px 6px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: all 0.15s; }
.zd-btn-icon-sm:hover { background: var(--zd-beige); }

.zd-project-meta { font-size: 11px; color: var(--zd-muted); margin-bottom: 10px; }

.zd-project-timer { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.zd-timer-display { font-family: var(--zd-mono); font-size: 18px; font-weight: 500; color: var(--zd-blue); }

.zd-timer-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all 0.2s;
}
.zd-timer-btn.start { background: #D1FAE5; color: #065F46; }
.zd-timer-btn.stop  { background: #FEE2E2; color: #991B1B; }
.zd-timer-btn.start:hover { background: #A7F3D0; }
.zd-timer-btn.stop:hover  { background: #FECACA; }

.zd-project-revenue { font-size: 12px; color: #10B981; font-weight: 600; }

/* ── Historique ─────────────────────────────────────────── */
.zd-search-input {
  width: 100%;
  max-width: 350px;
  border: 1.5px solid var(--zd-border);
  border-radius: 10px;
  padding: 9px 13px;
  font-family: var(--zd-font);
  font-size: 13px;
  color: var(--zd-blue);
  outline: none;
  margin-bottom: 14px;
  background: var(--zd-white);
}

.zd-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--zd-white);
  border: 1px solid var(--zd-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.zd-history-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); transform: translateY(-1px); }

.zd-history-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.zd-history-content { flex: 1; }
.zd-history-title { font-size: 13px; font-weight: 600; color: var(--zd-blue); }
.zd-history-meta { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.zd-tag { font-size: 10px; padding: 2px 8px; border-radius: 20px; background: var(--zd-beige); color: var(--zd-muted); font-weight: 600; }

/* ── Billing ─────────────────────────────────────────────── */
.zd-billing-info { display: flex; gap: 16px; margin-bottom: 24px; }
.zd-kpi { background: var(--zd-white); border: 1.5px solid var(--zd-border); border-radius: 12px; padding: 16px 20px; flex: 1; }
.zd-kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--zd-muted); font-weight: 600; }
.zd-kpi-value { font-size: 28px; font-weight: 700; color: var(--zd-blue); margin-top: 6px; }

.zd-plans-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.zd-plan-card { background: var(--zd-white); border: 1.5px solid var(--zd-border); border-radius: 14px; padding: 20px; position: relative; }
.zd-plan-card.popular { border-color: var(--zd-blue); background: var(--zd-blue-lt); }
.zd-plan-badge-popular { position: absolute; top: -10px; right: 12px; background: var(--zd-red); color: white; font-size: 10px; font-weight: 700; padding: 3px 10px; border-radius: 10px; }
.zd-plan-card h4 { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.zd-plan-price { font-size: 22px; font-weight: 700; color: var(--zd-blue); margin-bottom: 12px; }
.zd-plan-card ul { list-style: none; padding: 0; margin: 0 0 14px; font-size: 12px; display: flex; flex-direction: column; gap: 4px; }

.zd-packs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.zd-pack-card { background: var(--zd-white); border: 1.5px solid var(--zd-border); border-radius: 12px; padding: 16px; text-align: center; }
.zd-pack-card.popular { border-color: var(--zd-blue); }
.zd-pack-credits { font-size: 18px; font-weight: 700; color: var(--zd-blue); }
.zd-pack-price { font-size: 20px; font-weight: 700; margin: 4px 0 12px; }

/* ── Paramètres ─────────────────────────────────────────── */
.zd-settings-form { max-width: 560px; }
.zd-settings-form h3 { font-size: 15px; font-weight: 700; margin: 20px 0 8px; color: var(--zd-blue); }
.zd-form-row { display: flex; gap: 8px; align-items: center; }
.zd-form-group { margin-bottom: 14px; }
.zd-form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--zd-blue); margin-bottom: 5px; }
.zd-input {
  width: 100%;
  border: 1.5px solid var(--zd-border);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: var(--zd-font);
  font-size: 13px;
  color: var(--zd-blue);
  outline: none;
  transition: all 0.2s;
  background: var(--zd-beige);
}
.zd-input:focus { border-color: var(--zd-blue-mid); background: white; box-shadow: 0 0 0 3px rgba(37,99,235,0.08); }

/* ── Boutons ─────────────────────────────────────────────── */
.zd-btn-primary, .zd-btn-secondary {
  padding: 9px 18px;
  border-radius: 9px;
  font-family: var(--zd-font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  white-space: nowrap;
}
.zd-btn-primary { background: var(--zd-blue); color: white; }
.zd-btn-primary:hover { background: var(--zd-blue-mid); }
.zd-btn-secondary { background: var(--zd-beige); color: var(--zd-blue); border: 1.5px solid var(--zd-border); }
.zd-btn-secondary:hover { background: var(--zd-blue-lt); }

/* ── Form dans modal ─────────────────────────────────────── */
.zd-form { display: flex; flex-direction: column; gap: 10px; }
.zd-form label { font-size: 12px; font-weight: 600; color: var(--zd-blue); }
.zd-form input, .zd-form textarea {
  border: 1.5px solid var(--zd-border);
  border-radius: 9px;
  padding: 9px 12px;
  font-family: var(--zd-font);
  font-size: 13px;
  color: var(--zd-blue);
  outline: none;
  background: var(--zd-beige);
}
.zd-form input:focus, .zd-form textarea:focus { border-color: var(--zd-blue-mid); background: white; }

.zd-color-picker { display: flex; gap: 8px; }
.zd-color-swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; }
.zd-color-swatch.selected { border-color: var(--zd-blue); transform: scale(1.15); box-shadow: 0 0 0 2px white, 0 0 0 4px var(--zd-blue); }

/* ── Modal ──────────────────────────────────────────────── */
.zd-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.55);
  display: none; align-items: center; justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}
.zd-modal-overlay[style*="flex"] { display: flex !important; }

.zd-modal {
  background: var(--zd-white);
  border-radius: 16px;
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: zdModalIn 0.2s ease;
}
@keyframes zdModalIn { from{opacity:0;transform:scale(0.96)} to{opacity:1;transform:scale(1)} }

.zd-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.zd-modal-header h3 { font-size: 16px; font-weight: 700; margin: 0; color: var(--zd-blue); }
.zd-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--zd-muted); }

/* ── Toast ──────────────────────────────────────────────── */
.zd-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--zd-white);
  border: 1px solid var(--zd-border);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10000;
  animation: zdToastIn 0.3s ease;
  max-width: 280px;
  font-family: var(--zd-font);
}
@keyframes zdToastIn { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
.zd-toast b { font-weight: 700; color: var(--zd-blue); }

/* ── Utilitaires ─────────────────────────────────────────── */
.zd-loading { color: var(--zd-muted); font-size: 13px; padding: 20px; }
.zd-empty { color: var(--zd-muted); font-size: 14px; text-align: center; padding: 40px 0; }
.zd-error { color: var(--zd-red); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .zd-layout { flex-direction: column; height: auto; min-height: 90vh; }
  .zd-sidebar { width: 100%; border-right: none; border-bottom: 1.5px solid var(--zd-border); flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .zd-sidebar-footer { display: none; }
  .zd-mode-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .zd-plans-grid, .zd-packs-grid { grid-template-columns: 1fr; }
  .zd-billing-info { flex-direction: column; }
}
