/* ============================================
   APP — CHAT PORTAL STYLES
   ============================================ */

/* ---- Loading Overlay ---- */
.app-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  z-index: 9999;
  transition: opacity 0.3s var(--ease-out);
}

.app-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner-ring {
  width: 40px;
  height: 40px;
  border: 3px solid var(--white-10);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ============================================
   AUTH MODAL (overlay over chat UI)
   ============================================ */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 0.25s var(--ease-out);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-modal {
  width: 100%;
  max-width: 440px;
  padding: 48px 40px;
  box-shadow: var(--shadow-card);
  position: relative;
  animation: modalSlideIn 0.3s var(--ease-out);
}

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

.auth-modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--white-50);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.auth-modal-close:hover {
  background: var(--white-10);
  color: var(--white);
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 24px;
}

.login-logo span {
  color: var(--gold);
}

.login-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--white);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--white-50);
  line-height: 1.5;
}

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

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--white-70);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--white-05);
  border: 1px solid var(--white-10);
  border-radius: var(--radius-sm);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.form-input::placeholder {
  color: var(--white-20);
}

.form-error {
  font-size: 0.8rem;
  color: #ff6b6b;
  margin-top: 6px;
  display: none;
}

.form-error.visible {
  display: block;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  border: none;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--gold);
  color: var(--navy);
}

.btn-primary:hover {
  background: var(--gold-light);
  box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--white-10);
  color: var(--white-70);
}

.btn-secondary:hover {
  background: var(--white-20);
  color: var(--white);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.btn.loading .btn-text {
  visibility: hidden;
}

.btn.loading .btn-spinner {
  position: absolute;
  display: block;
}

.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--navy);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Login sent state */
.login-sent {
  text-align: center;
}

.sent-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  color: var(--gold);
}

.sent-icon svg {
  width: 100%;
  height: 100%;
}

.login-sent h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--white);
  margin-bottom: 8px;
}

.login-sent p {
  font-size: 0.9rem;
  color: var(--white-50);
  line-height: 1.5;
  margin-bottom: 20px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--white-10);
}

.login-footer p {
  font-size: 0.8rem;
  color: var(--white-50);
}

.login-footer a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 500;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* ---- Not Enrolled / Onboarding States ---- */
.login-not-enrolled,
.login-onboarding {
  text-align: center;
}

.not-enrolled-icon {
  margin: 0 auto 16px;
  opacity: 0.9;
}

.login-not-enrolled h2,
.login-onboarding h2 {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--white);
  margin-bottom: 8px;
}

.not-enrolled-desc {
  font-size: 0.88rem;
  color: var(--white-50);
  line-height: 1.6;
  margin-bottom: 24px;
}

.not-enrolled-perks {
  text-align: left;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--white-05);
  border-radius: var(--radius-sm);
  border: 1px solid var(--white-05);
}

.perk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 0.85rem;
  color: var(--white-70);
}

.perk-item svg {
  flex-shrink: 0;
}




/* ---- Checkout Confirmation Step ---- */
.checkout-confirm {
  animation: confirmSlideIn 0.25s var(--ease-out);
}

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

.confirm-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--white-50);
  font-family: var(--font-body);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 12px;
  transition: color 0.2s;
}

.confirm-back:hover {
  color: var(--white);
}

.confirm-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 16px;
  text-align: center;
}

.confirm-plan-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gold);
  background: rgba(200, 160, 74, 0.08);
  margin-bottom: 16px;
  text-align: center;
}

.confirm-plan-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.confirm-plan-feat {
  font-size: 0.75rem;
  color: var(--gold);
}

.confirm-billing-toggle {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.confirm-billing-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--white-10);
  background: var(--white-05);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  position: relative;
}

.confirm-billing-opt:hover {
  border-color: var(--white-30);
  background: var(--white-10);
}

.confirm-billing-opt.active {
  border-color: var(--gold);
  background: rgba(200, 160, 74, 0.1);
}

.confirm-billing-opt.active::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: var(--gold);
  box-shadow: inset 0 0 0 3px var(--navy);
}

.confirm-billing-opt:not(.active)::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--white-20);
  background: none;
}

.confirm-billing-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--white);
}

.confirm-billing-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--white-70);
}

.confirm-billing-opt.active .confirm-billing-price {
  color: var(--white);
}

.confirm-billing-opt .billing-save {
  margin-left: auto;
  margin-right: 32px;
}

/* ---- Billing Toggle ---- */
.billing-toggle {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--white-05);
  border-radius: 8px;
  margin-bottom: 12px;
}

.billing-opt {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--white-50);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.billing-opt:hover {
  color: var(--white-70);
}

.billing-opt.active {
  background: var(--white-10);
  color: var(--white);
}

.billing-save {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(74, 222, 128, 0.15);
  color: #4ade80;
}

/* ---- Inline Plan Cards (Auth Modal) ---- */
.inline-plans {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.inline-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--white-10);
  background: var(--white-05);
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
  text-align: center;
}

.inline-plan:hover {
  border-color: var(--gold);
  background: rgba(200, 160, 74, 0.08);
  transform: translateY(-1px);
}

.inline-plan:active {
  transform: translateY(0);
}

.inline-plan.featured {
  border-color: var(--gold);
  background: rgba(200, 160, 74, 0.1);
}

.inline-plan.featured:hover {
  background: rgba(200, 160, 74, 0.18);
  box-shadow: 0 0 20px rgba(200, 160, 74, 0.15);
}

.inline-plan.loading {
  opacity: 0.5;
  pointer-events: none;
}

.inline-plan-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--gold);
  color: var(--navy);
  white-space: nowrap;
}

.inline-plan-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--white-70);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.inline-plan:hover .inline-plan-name,
.inline-plan.featured .inline-plan-name {
  color: var(--white);
}

.inline-plan-price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

.inline-plan-price small {
  font-size: 0.6rem;
  font-weight: 400;
  color: var(--white-50);
}

.inline-plan-feat {
  font-size: 0.68rem;
  color: var(--white-50);
}

.inline-plan.featured .inline-plan-feat {
  color: var(--gold);
}

.inline-plans-note {
  font-size: 0.72rem;
  color: var(--white-30);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.4;
}

@media (max-width: 400px) {
  .inline-plans {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .inline-plan {
    padding: 12px 6px 10px;
  }
  .inline-plan-price {
    font-size: 1rem;
  }
}

/* ============================================
   CHAT LAYOUT
   ============================================ */
.app-chat {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  background: var(--navy);
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--navy-dark);
  border-right: 1px solid var(--white-05);
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.sidebar-logo {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  text-decoration: none;
}

.sidebar-logo span {
  color: var(--gold);
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--white-50);
  cursor: pointer;
  padding: 4px;
}

/* ---- Sidebar Tabs ---- */
.sidebar-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 12px 4px;
}

.sidebar-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--white-50);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.sidebar-tab:hover {
  color: var(--white-70);
  background: var(--white-05);
}

.sidebar-tab.active {
  color: var(--gold);
  background: var(--white-10);
}

.sidebar-tab svg {
  opacity: 0.7;
}

.sidebar-tab.active svg {
  opacity: 1;
}

/* ---- Sidebar Tab Content ---- */
.sidebar-tab-content {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.sidebar-tab-content.active {
  display: flex;
}

.btn-new-chat {
  margin: 8px 12px 12px;
  font-size: 0.85rem;
  padding: 10px 16px;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.conversation-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--white-70);
  transition: background 0.15s;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item:hover {
  background: var(--white-05);
  color: var(--white);
}

.conversation-item.active {
  background: var(--white-10);
  color: var(--white);
}

.conversation-item .conv-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-right: 10px;
  color: var(--white-50);
}

.conversation-item .conv-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Workflow Add Form ---- */
.wf-add-form {
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wf-add-input,
.wf-add-select,
.wf-add-desc {
  padding: 8px 10px;
  font-size: 0.82rem;
  background: var(--white-05);
  border: 1px solid var(--white-10);
  border-radius: 6px;
  color: var(--white);
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.2s;
}

.wf-add-input:focus,
.wf-add-select:focus,
.wf-add-desc:focus {
  border-color: var(--gold);
}

.wf-add-select {
  appearance: none;
  cursor: pointer;
}

.wf-add-select option {
  background: var(--navy-dark);
  color: var(--white);
}

.wf-add-desc {
  resize: none;
}

.wf-add-actions {
  display: flex;
  gap: 6px;
}

.wf-add-actions .btn {
  flex: 1;
}

/* ---- Workflow List ---- */
.workflow-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px;
}

.workflow-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}

.workflow-item:hover {
  background: var(--white-05);
}

.workflow-item.active {
  background: var(--white-10);
}

.wf-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.wf-item-title {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--white-90);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.wf-item-score-text {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gold);
  margin-left: 8px;
  flex-shrink: 0;
}

.wf-item-bar {
  height: 4px;
  background: var(--white-10);
  border-radius: 2px;
  overflow: hidden;
}

.wf-item-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s var(--ease-out);
  min-width: 0;
}

/* Score color coding */
.wf-item-bar-fill.score-high { background: #4ade80; }
.wf-item-bar-fill.score-mid { background: var(--gold); }
.wf-item-bar-fill.score-low { background: #f97316; }
.wf-item-bar-fill.score-zero { background: var(--white-20); }

.wf-item-category {
  font-size: 0.7rem;
  color: var(--white-50);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.wf-empty {
  padding: 24px 12px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--white-20);
  line-height: 1.5;
}

/* ---- Sidebar Footer ---- */
.sidebar-footer {
  padding: 8px 12px 16px;
  border-top: 1px solid var(--white-05);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--white-50);
  font-size: 0.85rem;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.sidebar-footer-btn:hover {
  background: var(--white-05);
  color: var(--white);
}

/* ---- Sidebar Overlay (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

/* ---- Chat Main ---- */
.chat-main {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- Chat Header ---- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--white-05);
  background: var(--navy);
  flex-shrink: 0;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--white-70);
  cursor: pointer;
  padding: 4px;
}

.chat-title {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--white);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--white-50);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--white-10);
  color: var(--white);
}

/* ---- Chat View Container ---- */
.chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ---- Chat Messages ---- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
}

.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  color: var(--white-50);
}

.welcome-icon {
  margin-bottom: 16px;
  opacity: 0.6;
}

.chat-welcome h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--white-70);
  margin-bottom: 8px;
}

.chat-welcome p {
  font-size: 0.9rem;
  color: var(--white-50);
}

/* Message bubbles */
.message {
  display: flex;
  margin-bottom: 20px;
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message.user .message-bubble {
  background: var(--gold);
  color: var(--navy);
  border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
  background: var(--white-10);
  color: var(--white-90);
  border-bottom-left-radius: 4px;
}

/* Markdown in messages */
.message-bubble p {
  margin: 0 0 8px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.message-bubble strong {
  font-weight: 700;
}

.message-bubble em {
  font-style: italic;
}

.message-bubble code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.85em;
  padding: 2px 6px;
  border-radius: 4px;
}

.message.user .message-bubble code {
  background: rgba(0,0,0,0.15);
}

.message.assistant .message-bubble code {
  background: var(--white-10);
  color: var(--gold);
}

.message-bubble pre {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.5;
}

.message-bubble pre code {
  background: none;
  padding: 0;
  color: var(--white-90);
}

.message-bubble ul,
.message-bubble ol {
  padding-left: 20px;
  margin: 8px 0;
}

.message-bubble li {
  margin-bottom: 4px;
}

/* Streaming cursor */
.streaming-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--gold);
  margin-left: 2px;
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  border-radius: 1px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---- Chat Input ---- */
.chat-input-wrapper {
  flex-shrink: 0;
  padding: 12px 20px 20px;
  background: var(--navy);
}

.chat-input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 780px;
  margin: 0 auto;
  background: var(--white-05);
  border: 1px solid var(--white-10);
  border-radius: 16px;
  padding: 8px 8px 8px 16px;
  transition: border-color 0.2s;
}

.chat-input-form:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  max-height: 150px;
  padding: 4px 0;
}

.chat-input::placeholder {
  color: var(--white-20);
}

.btn-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--gold);
  border: none;
  color: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.btn-send:hover:not(:disabled) {
  background: var(--gold-light);
  transform: scale(1.05);
}

.btn-send:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---- Attach Button ---- */
.btn-attach {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: none;
  border: none;
  color: var(--white-40);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.btn-attach:hover { color: var(--white); background: var(--white-05); }
.btn-attach.has-files { color: var(--gold); }

/* ---- File Preview Bar ---- */
.file-preview-bar {
  max-width: 780px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--white-05);
  border: 1px solid var(--white-10);
  border-radius: 12px;
}
.file-preview-list {
  display: flex;
  gap: 8px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.file-preview-list::-webkit-scrollbar { display: none; }

.file-preview-item {
  position: relative;
  flex-shrink: 0;
}
.file-preview-item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--white-10);
}
.file-preview-item .file-doc {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--white-05);
  border-radius: 8px;
  border: 1px solid var(--white-10);
  max-width: 160px;
}
.file-doc-icon { color: var(--gold); flex-shrink: 0; }
.file-doc-name {
  font-size: 0.75rem;
  color: var(--white-60);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-preview-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--navy);
  border: 1px solid var(--white-20);
  color: var(--white-60);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0;
  transition: background 0.15s;
}
.file-preview-remove:hover { background: rgba(239,68,68,0.3); color: #fff; }
.file-preview-clear {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--white-40);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.file-preview-clear:hover { color: var(--white); }

/* ---- Attachments in Messages ---- */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.msg-attachments img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
}
.msg-attachments img:hover { opacity: 0.85; }
.msg-attachment-doc {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--white-05);
  border-radius: 6px;
  font-size: 0.8rem;
  color: var(--white-60);
}

/* ============================================
   WORKFLOW DETAIL VIEW
   ============================================ */
.workflow-detail {
  flex: 1;
  overflow: hidden;
}

.wf-detail-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 32px 24px;
  max-width: 640px;
  margin: 0 auto;
}

/* Score Hero */
.wf-score-hero {
  text-align: center;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--white-05);
  margin-bottom: 28px;
}

.wf-score-ring {
  width: 140px;
  height: 140px;
  margin: 0 auto 20px;
  position: relative;
}

.wf-score-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.wf-ring-bg {
  fill: none;
  stroke: var(--white-10);
  stroke-width: 6;
}

.wf-ring-fill {
  fill: none;
  stroke: var(--gold);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 0.8s var(--ease-out), stroke 0.3s;
}

.wf-ring-fill.score-high { stroke: #4ade80; }
.wf-ring-fill.score-mid { stroke: var(--gold); }
.wf-ring-fill.score-low { stroke: #f97316; }

.wf-score-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
}

.wf-detail-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--white);
  margin-bottom: 8px;
}

.wf-category-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: rgba(200, 160, 74, 0.15);
  border: 1px solid rgba(200, 160, 74, 0.3);
}

.wf-detail-desc {
  font-size: 0.88rem;
  color: var(--white-50);
  line-height: 1.5;
  margin-top: 12px;
}

.wf-detail-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 24px;
}

.wf-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wf-stat-val {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
}

.wf-stat-label {
  font-size: 0.72rem;
  color: var(--white-50);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* Sections */
.wf-section {
  margin-bottom: 28px;
}

.wf-section-title {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.wf-section-desc {
  font-size: 0.85rem;
  color: var(--white-50);
  margin-bottom: 16px;
}

/* Outcome Buttons */
.wf-outcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.wf-outcome-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--white-10);
  background: var(--white-05);
  color: var(--white-70);
  cursor: pointer;
  transition: all 0.2s;
}

.wf-outcome-btn:hover {
  border-color: var(--white-20);
  background: var(--white-10);
  color: var(--white);
}

.wf-outcome-btn span {
  font-weight: 600;
  font-size: 0.85rem;
}

.wf-outcome-btn small {
  font-size: 0.7rem;
  color: var(--white-50);
}

.wf-outcome-btn.success:hover { border-color: #4ade80; color: #4ade80; }
.wf-outcome-btn.partial:hover { border-color: var(--gold); color: var(--gold); }
.wf-outcome-btn.corrected:hover { border-color: #f97316; color: #f97316; }
.wf-outcome-btn.failed:hover { border-color: #f87171; color: #f87171; }

.wf-outcome-btn.logging {
  opacity: 0.5;
  pointer-events: none;
}

/* Execution History */
.wf-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wf-history-empty {
  font-size: 0.85rem;
  color: var(--white-20);
  text-align: center;
  padding: 24px 0;
}

.wf-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--white-05);
  border: 1px solid var(--white-05);
}

.wf-history-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wf-history-icon.success { background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.wf-history-icon.partial { background: rgba(200, 160, 74, 0.15); color: var(--gold); }
.wf-history-icon.corrected { background: rgba(249, 115, 22, 0.15); color: #f97316; }
.wf-history-icon.failed { background: rgba(248, 113, 113, 0.15); color: #f87171; }

.wf-history-info {
  flex: 1;
  min-width: 0;
}

.wf-history-outcome {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--white-90);
  text-transform: capitalize;
}

.wf-history-date {
  font-size: 0.72rem;
  color: var(--white-50);
  margin-top: 2px;
}

.wf-history-notes {
  font-size: 0.78rem;
  color: var(--white-50);
  margin-top: 4px;
  font-style: italic;
}

.wf-history-feedback {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.wf-fb-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--white-10);
  background: none;
  color: var(--white-50);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all 0.15s;
}

.wf-fb-btn:hover {
  background: var(--white-10);
  color: var(--white);
}

.wf-fb-btn.active-up {
  background: rgba(74, 222, 128, 0.15);
  border-color: #4ade80;
  color: #4ade80;
}

.wf-fb-btn.active-down {
  background: rgba(248, 113, 113, 0.15);
  border-color: #f87171;
  color: #f87171;
}

/* Danger Zone */
.wf-danger-zone {
  padding-top: 20px;
  border-top: 1px solid var(--white-05);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wf-btn-delete {
  background: rgba(248, 113, 113, 0.1);
  color: #f87171;
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.wf-btn-delete:hover {
  background: rgba(248, 113, 113, 0.2);
  border-color: #f87171;
}

/* ============================================
   SETTINGS PANEL (Slide-over)
   ============================================ */
.settings-panel {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  height: 100vh;
  z-index: 200;
  transition: right 0.3s var(--ease-out);
}

.settings-panel.open {
  right: 0;
}

.settings-panel-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--navy-dark);
  border-left: 1px solid var(--white-10);
}

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

.settings-header h2 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--white);
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Settings sections */
.settings-section {
  margin-bottom: 28px;
}

.settings-section-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
}

.settings-stat {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--white-05);
}

.settings-stat-label {
  color: var(--white-50);
}

.settings-stat-value {
  color: var(--white);
  font-weight: 500;
}

.settings-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
}

.settings-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.settings-status .dot.green { background: #4ade80; }
.settings-status .dot.yellow { background: #fbbf24; }
.settings-status .dot.red { background: #f87171; }

/* Settings form */
.settings-form .form-group {
  margin-bottom: 16px;
}

.settings-form .form-label {
  font-size: 0.8rem;
  color: var(--white-50);
  margin-bottom: 4px;
}

.settings-form .form-input {
  padding: 10px 12px;
  font-size: 0.85rem;
}

.settings-form .btn {
  margin-top: 8px;
}

.settings-save-status {
  font-size: 0.8rem;
  margin-top: 8px;
  color: #4ade80;
  display: none;
}

.settings-save-status.visible {
  display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .app-chat {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    z-index: 100;
    width: 280px;
    transition: left 0.3s var(--ease-out);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-close {
    display: block;
  }

  .hamburger {
    display: block;
  }

  .login-card {
    padding: 32px 24px;
  }

  .message-bubble {
    max-width: 90%;
  }

  .settings-panel {
    width: 100%;
    right: -100%;
  }

  .wf-outcome-grid {
    grid-template-columns: 1fr;
  }

  .wf-detail-stats {
    gap: 20px;
  }
}

@media (max-width: 480px) {
  .chat-messages {
    padding: 12px;
  }

  .chat-input-wrapper {
    padding: 8px 12px 12px;
  }

  .wf-detail-scroll {
    padding: 20px 16px;
  }
}

/* Saved Profile State */
.login-saved { text-align: center; padding: 10px 0; }
.saved-avatar { width: 72px; height: 72px; border-radius: 50%; background: rgba(212,175,55,0.1); border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.saved-title { font-size: 1.3rem; margin: 0 0 4px; color: var(--white); }
.saved-email { font-size: 0.95rem; color: var(--white-60); margin: 0 0 24px; }
