/**
 * HADDAF Coach AI — Scoped Styles
 *
 * All selectors are scoped under .haddaf-coach-ai-wrap to avoid
 * conflicts with the Salient parent theme and WordPress core styles.
 */

/* ===== CSS CUSTOM PROPERTIES + WRAPPER BASE ===== */
.haddaf-coach-ai-wrap {
  --gold: #C9A84C;
  --gold-light: #E8C96A;
  --cream: #FAF8F4;
  --black: #1A1814;
  --black-soft: #201E19;
  --black-card: #252219;
  --gray: #7A7870;
  --gray-light: #4A4840;
  --border: rgba(201,168,76,0.15);
  --border-strong: rgba(201,168,76,0.3);

  /* Full-width dark background that breaks out of theme content container */
  background: var(--black);
  color: var(--cream);
  font-family: 'Cairo', sans-serif;
  direction: rtl;
  min-height: 70vh;
  position: relative;
  width: 100%;
  overflow-x: hidden;
}

/* LTR overrides for English version */
.haddaf-coach-ai-wrap.hcai-ltr {
  direction: ltr;
}

/* Scoped box-sizing reset (does NOT touch theme elements) */
.haddaf-coach-ai-wrap *,
.haddaf-coach-ai-wrap *::before,
.haddaf-coach-ai-wrap *::after {
  box-sizing: border-box;
}

/* ===== HIDE SALIENT PAGE TITLE BAR (if visible) ===== */
.page-template-page-coach-ai .page-header-bg-image,
.page-template-page-coach-ai .page-header-no-bg,
.page-template-page-coach-ai #page-header-bg,
.page-template-page-coach-ai .page-header-overlay,
.page-template-page-coach-ai #page-header-wrap {
  display: none !important;
}

.page-template-page-coach-ai #ajax-content-wrap {
  padding-top: 0 !important;
}

.page-template-page-coach-ai .container-wrap {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Force dark background (#1a1814) on the entire page body, wrappers, and footer */
body.page-template-page-coach-ai,
body.page-template-page-coach-ai-php,
body.page-template-page-coach-ai #ajax-content-wrap,
body.page-template-page-coach-ai-php #ajax-content-wrap,
body.page-template-page-coach-ai #footer-outer,
body.page-template-page-coach-ai-php #footer-outer,
body.page-template-page-coach-ai #footer-widgets,
body.page-template-page-coach-ai-php #footer-widgets,
body.page-template-page-coach-ai .container-wrap,
body.page-template-page-coach-ai-php .container-wrap {
  background-color: #1a1814 !important;
  background-image: none !important;
}


/* ===== HOME STATE (initial centered layout) ===== */
.haddaf-coach-ai-wrap #home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 3rem 1.5rem 2rem;
  transition: all 0.4s ease;
}

.haddaf-coach-ai-wrap #home.collapsed {
  min-height: auto;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--black-soft);
  flex-direction: row;
  justify-content: center;
  gap: 1rem;
}


/* ===== BRAND ===== */
.haddaf-coach-ai-wrap .brand {
  text-align: center;
  margin-bottom: 2.5rem;
  transition: all 0.4s ease;
}

.haddaf-coach-ai-wrap #home.collapsed .brand {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
}

.haddaf-coach-ai-wrap.hcai-ltr #home.collapsed .brand {
  text-align: left;
}

.haddaf-coach-ai-wrap .brand-label {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--gold);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.haddaf-coach-ai-wrap #home.collapsed .brand-label {
  margin-bottom: 0;
  font-size: 10px;
}

.haddaf-coach-ai-wrap .brand-title {
  font-size: 38px;
  font-weight: 900;
  color: var(--cream);
  line-height: 1.1;
  margin: 0;
  padding: 0;
  border: none;
  letter-spacing: 0;
}

.haddaf-coach-ai-wrap #home.collapsed .brand-title {
  font-size: 20px;
}

.haddaf-coach-ai-wrap .brand-sub {
  font-size: 15px;
  color: var(--gray);
  margin-top: 8px;
  font-weight: 400;
}

.haddaf-coach-ai-wrap #home.collapsed .brand-sub {
  display: none;
}


/* ===== SEARCH BOX ===== */
.haddaf-coach-ai-wrap .search-wrapper {
  width: 100%;
  max-width: 680px;
  transition: max-width 0.4s ease;
}

.haddaf-coach-ai-wrap #home.collapsed .search-wrapper {
  max-width: 600px;
}

.haddaf-coach-ai-wrap .search-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--black-card);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 14px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.haddaf-coach-ai-wrap .search-box:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,0.08);
}

.haddaf-coach-ai-wrap textarea#query {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--cream);
  font-family: 'Cairo', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  min-height: 24px;
  max-height: 160px;
  direction: rtl;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 0;
  margin: 0;
}

.haddaf-coach-ai-wrap.hcai-ltr textarea#query {
  direction: ltr;
}

.haddaf-coach-ai-wrap textarea#query::placeholder {
  color: var(--gray);
}

.haddaf-coach-ai-wrap textarea#query::-webkit-scrollbar {
  display: none;
}

.haddaf-coach-ai-wrap .send-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  background: var(--gold);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
  padding: 0;
}

.haddaf-coach-ai-wrap .send-btn:hover {
  background: var(--gold-light);
}

.haddaf-coach-ai-wrap .send-btn:active {
  transform: scale(0.95);
}

.haddaf-coach-ai-wrap .send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.haddaf-coach-ai-wrap .send-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--black);
  transform: rotate(180deg);
}

.haddaf-coach-ai-wrap.hcai-ltr .send-btn svg {
  transform: rotate(0deg);
}


/* ===== SUGGESTIONS ===== */
.haddaf-coach-ai-wrap .suggestions {
  margin-top: 2rem;
  width: 100%;
  max-width: 680px;
}

.haddaf-coach-ai-wrap #home.collapsed .suggestions {
  display: none;
}

.haddaf-coach-ai-wrap .suggestions-label {
  font-size: 11px;
  color: var(--gray);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 12px;
  text-align: center;
}

.haddaf-coach-ai-wrap .suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.haddaf-coach-ai-wrap .suggestion-chip {
  background: var(--black-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  color: var(--gray);
  cursor: pointer;
  text-align: right;
  transition: all 0.2s;
  line-height: 1.5;
}

.haddaf-coach-ai-wrap.hcai-ltr .suggestion-chip {
  text-align: left;
}

.haddaf-coach-ai-wrap .suggestion-chip:hover {
  border-color: var(--border-strong);
  color: var(--cream);
  background: rgba(201,168,76,0.05);
}

.haddaf-coach-ai-wrap .suggestion-chip .chip-icon {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}


/* ===== RESULTS AREA ===== */
.haddaf-coach-ai-wrap #results {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}


/* ===== USER MESSAGE ===== */
.haddaf-coach-ai-wrap .message {
  margin-bottom: 2rem;
  animation: hcaiFadeIn 0.3s ease;
}

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

.haddaf-coach-ai-wrap .user-message {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.25rem;
}

.haddaf-coach-ai-wrap .user-bubble {
  background: rgba(201,168,76,0.1);
  border: 1px solid var(--border-strong);
  border-radius: 16px 4px 16px 16px;
  padding: 12px 18px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--cream);
  max-width: 80%;
}

.haddaf-coach-ai-wrap.hcai-ltr .user-bubble {
  border-radius: 4px 16px 16px 16px;
}


/* ===== AI MESSAGE ===== */
.haddaf-coach-ai-wrap .ai-message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.haddaf-coach-ai-wrap .ai-avatar {
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: rgba(201,168,76,0.12);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0;
}

.haddaf-coach-ai-wrap .ai-bubble {
  flex: 1;
  background: var(--black-card);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  padding: 18px 20px;
  font-size: 14px;
  line-height: 2;
  color: var(--cream);
  direction: rtl;
  text-align: right;
}

/* Markdown styling */
.haddaf-coach-ai-wrap .ai-bubble strong {
  color: var(--gold-light);
  font-weight: 700;
}

.haddaf-coach-ai-wrap .ai-bubble em {
  color: var(--gold);
  font-style: italic;
}

.haddaf-coach-ai-wrap.hcai-ltr .ai-bubble {
  direction: ltr;
  text-align: left;
  border-radius: 16px 4px 16px 16px;
}

.haddaf-coach-ai-wrap .ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: flex-end;
}

.haddaf-coach-ai-wrap .ai-action-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 12px;
  font-family: 'Cairo', sans-serif;
  font-size: 12px;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.2s;
}

.haddaf-coach-ai-wrap .ai-action-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}


/* ===== TYPING INDICATOR ===== */
.haddaf-coach-ai-wrap .typing-indicator {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.haddaf-coach-ai-wrap .typing-dots {
  display: flex;
  gap: 5px;
  padding: 18px 20px;
  background: var(--black-card);
  border: 1px solid var(--border);
  border-radius: 4px 16px 16px 16px;
  align-items: center;
}

.haddaf-coach-ai-wrap .dot {
  width: 7px;
  height: 7px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0.3;
  animation: hcaiBounce 1.2s infinite;
}

.haddaf-coach-ai-wrap .dot:nth-child(2) { animation-delay: 0.2s; }
.haddaf-coach-ai-wrap .dot:nth-child(3) { animation-delay: 0.4s; }

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


/* ===== THREAD DIVIDER ===== */
.haddaf-coach-ai-wrap .thread-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}


/* ===== ACCESS DENIED PAGE ===== */
.haddaf-coach-ai-wrap .hcai-access-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 4rem 2rem;
  text-align: center;
}

.haddaf-coach-ai-wrap .hcai-denied-icon {
  font-size: 64px;
  margin-bottom: 1.5rem;
  opacity: 0.8;
}

.haddaf-coach-ai-wrap .hcai-denied-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  margin: 0 0 1rem 0;
  padding: 0;
  border: none;
  letter-spacing: 0;
}

.haddaf-coach-ai-wrap .hcai-denied-text {
  font-size: 16px;
  color: var(--gray);
  line-height: 2;
  max-width: 520px;
  margin: 0 0 2rem 0;
}

.haddaf-coach-ai-wrap .hcai-subscribe-btn {
  display: inline-block;
  background: var(--gold);
  color: var(--black);
  font-family: 'Cairo', sans-serif;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 40px;
  border-radius: 12px;
  text-decoration: none;
  transition: background 0.2s, transform 0.1s;
}

.haddaf-coach-ai-wrap .hcai-subscribe-btn:hover {
  background: var(--gold-light);
  color: var(--black);
  text-decoration: none;
}

.haddaf-coach-ai-wrap .hcai-subscribe-btn:active {
  transform: scale(0.97);
}


/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .haddaf-coach-ai-wrap .brand-title {
    font-size: 28px;
  }
  .haddaf-coach-ai-wrap .brand-sub {
    font-size: 13px;
  }
  .haddaf-coach-ai-wrap .suggestions-grid {
    grid-template-columns: 1fr 1fr;
  }
  .haddaf-coach-ai-wrap .ai-bubble {
    font-size: 13px;
  }
  .haddaf-coach-ai-wrap #results {
    padding: 1.5rem 1rem 4rem;
  }
  .haddaf-coach-ai-wrap .hcai-denied-title {
    font-size: 22px;
  }
  .haddaf-coach-ai-wrap .hcai-denied-text {
    font-size: 14px;
  }
  .haddaf-coach-ai-wrap .hcai-sub-bar {
    flex-direction: column;
    gap: 8px;
    padding: 10px 16px;
  }
  .haddaf-coach-ai-wrap .hcai-denied-price {
    font-size: 26px;
  }
}


/* ===== SUBSCRIPTION STATUS BAR ===== */
.haddaf-coach-ai-wrap .hcai-sub-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 24px;
  background: rgba(34, 197, 94, 0.06);
  border-bottom: 1px solid rgba(34, 197, 94, 0.15);
  font-family: 'Cairo', sans-serif;
  font-size: 13px;
  direction: rtl;
}

.haddaf-coach-ai-wrap.hcai-ltr .hcai-sub-bar {
  direction: ltr;
}

.haddaf-coach-ai-wrap .hcai-sub-bar-text {
  color: #86efac;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

.haddaf-coach-ai-wrap .hcai-sub-bar-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
  animation: hcaiSubDot 2s ease infinite;
}

@keyframes hcaiSubDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.haddaf-coach-ai-wrap .hcai-sub-bar-renew {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  font-size: 12px;
  padding: 5px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  transition: all 0.2s;
  white-space: nowrap;
}

.haddaf-coach-ai-wrap .hcai-sub-bar-renew:hover {
  background: rgba(201, 168, 76, 0.1);
  color: var(--gold-light);
  text-decoration: none;
}

/* Warning state (≤7 days remaining) */
.haddaf-coach-ai-wrap .hcai-sub-bar--warning {
  background: rgba(234, 179, 8, 0.06);
  border-bottom-color: rgba(234, 179, 8, 0.15);
}

.haddaf-coach-ai-wrap .hcai-sub-bar--warning .hcai-sub-bar-text {
  color: #fde047;
}

.haddaf-coach-ai-wrap .hcai-sub-bar--warning .hcai-sub-bar-icon {
  background: #eab308;
}

/* Urgent state (≤3 days remaining) */
.haddaf-coach-ai-wrap .hcai-sub-bar--urgent {
  background: rgba(239, 68, 68, 0.06);
  border-bottom-color: rgba(239, 68, 68, 0.15);
}

.haddaf-coach-ai-wrap .hcai-sub-bar--urgent .hcai-sub-bar-text {
  color: #fca5a5;
}

.haddaf-coach-ai-wrap .hcai-sub-bar--urgent .hcai-sub-bar-icon {
  background: #ef4444;
  animation: hcaiUrgentDot 1s ease infinite;
}

@keyframes hcaiUrgentDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}


/* ===== PRICING DISPLAY (access denied) ===== */
.haddaf-coach-ai-wrap .hcai-denied-pricing {
  margin-bottom: 2rem;
  text-align: center;
}

.haddaf-coach-ai-wrap .hcai-denied-price {
  font-size: 34px;
  font-weight: 900;
  color: var(--gold);
  line-height: 1.2;
}

.haddaf-coach-ai-wrap .hcai-denied-price .woocommerce-Price-amount {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

.haddaf-coach-ai-wrap .hcai-denied-price-label {
  font-size: 16px;
  color: var(--gray);
  font-weight: 400;
}


/* ===== EXPIRED SUBSCRIPTION CARD (inline in chat) ===== */
.haddaf-coach-ai-wrap .hcai-expired-card {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 4px 16px 16px 16px;
  padding: 20px 24px;
  text-align: center;
  direction: rtl;
}

.haddaf-coach-ai-wrap.hcai-ltr .hcai-expired-card {
  direction: ltr;
}

.haddaf-coach-ai-wrap .hcai-expired-card-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.haddaf-coach-ai-wrap .hcai-expired-card-title {
  font-weight: 700;
  color: #fca5a5;
  margin-bottom: 8px;
  font-size: 15px;
}

.haddaf-coach-ai-wrap .hcai-expired-card-text {
  color: var(--gray);
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.8;
}

.haddaf-coach-ai-wrap .hcai-expired-card-btn {
  display: inline-block;
  background: var(--gold);
  color: var(--black);
  padding: 10px 28px;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  transition: background 0.2s, transform 0.1s;
}

.haddaf-coach-ai-wrap .hcai-expired-card-btn:hover {
  background: var(--gold-light);
  color: var(--black);
  text-decoration: none;
}

.haddaf-coach-ai-wrap .hcai-expired-card-btn:active {
  transform: scale(0.97);
}
