/* ==========================================================================
   FreeScout WooCommerce My Account – frontend styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   My Account navigation – custom endpoint items
   Some WooCommerce themes apply icon-font ::before glyphs to all nav links,
   which renders as a solid block for unrecognised endpoint slugs.
   We take over the <a> layout with flexbox so we have full control over
   icon position and vertical alignment, regardless of whether the theme
   uses floats, inline-block, or its own flex layout on these elements.
   -------------------------------------------------------------------------- */
.woocommerce-MyAccount-navigation-link--support-tickets > a,
.woocommerce-MyAccount-navigation-link--knowledge-base > a {
  color: inherit;
  font-size: inherit;
  font-family: inherit;
  display: flex !important;
  align-items: center !important;
}

/* Suppress any ::after glyph the theme may inject. */
.woocommerce-MyAccount-navigation-link--support-tickets > a::after,
.woocommerce-MyAccount-navigation-link--knowledge-base > a::after {
  content: '' !important;
  display: none !important;
}

/* Shared icon setup – ::before becomes a flex item.
   order:1 + margin-left:auto pushes the icon to the far right so it
   sits in the same position as the theme's own icon-font glyphs. */
.woocommerce-MyAccount-navigation-link--support-tickets > a::before,
.woocommerce-MyAccount-navigation-link--knowledge-base > a::before {
  content: '' !important;
  display: block !important;
  width: 1.1em !important;
  height: 1.1em !important;
  order: 1 !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  flex-shrink: 0 !important;
  font-family: inherit !important;
  background-color: currentColor !important;
  -webkit-mask-repeat: no-repeat !important;
          mask-repeat: no-repeat !important;
  -webkit-mask-position: center !important;
          mask-position: center !important;
  -webkit-mask-size: 100% 100% !important;
          mask-size: 100% 100% !important;
}

/* Support Tickets – Feather "message-square" icon */
.woocommerce-MyAccount-navigation-link--support-tickets > a::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E") !important;
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E") !important;
}

/* Knowledge Base – Feather "book-open" icon (matches KB template icons) */
.woocommerce-MyAccount-navigation-link--knowledge-base > a::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E") !important;
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E") !important;
}

/* --------------------------------------------------------------------------
   Buttons
   Plugin buttons carry the theme's .button class for base reset/focus
   styles, then .fswa-btn overrides colour and size so they always render
   legibly regardless of which accent colour the active theme uses.
   -------------------------------------------------------------------------- */
/* Ensure button text is always readable (theme colour is inherited) */
.fswa-btn,
.fswa-btn:hover,
.fswa-btn:focus {
  color: #fff !important;
}

/* Compact variant used in table action cells and KB back-links */
.fswa-btn--sm {
  padding: 5px 12px !important;
  font-size: 0.8em !important;
}

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */
.fswa-tickets,
.fswa-ticket-detail,
.fswa-new-ticket {
  max-width: 900px;
}

/* --------------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------------- */
.fswa-tickets__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.fswa-tickets__title,
.fswa-ticket-detail__subject,
.fswa-new-ticket__title {
  margin: 0;
}

/* --------------------------------------------------------------------------
   Breadcrumb
   -------------------------------------------------------------------------- */
.fswa-breadcrumb {
  margin-bottom: 16px;
  font-size: 0.9em;
}

.fswa-breadcrumb a {
  text-decoration: none;
  color: inherit;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.fswa-breadcrumb a:hover {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Status badge
   -------------------------------------------------------------------------- */
.fswa-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.fswa-status--active    { background: #d1fae5; color: #065f46; }
.fswa-status--pending   { background: #fef3c7; color: #92400e; }
.fswa-status--closed    { background: #f3f4f6; color: #6b7280; }
.fswa-status--spam      { background: #fee2e2; color: #991b1b; }

/* --------------------------------------------------------------------------
   Tickets table
   -------------------------------------------------------------------------- */
.fswa-tickets__table {
  width: 100%;
  border-collapse: collapse;
}

.fswa-tickets__table th,
.fswa-tickets__table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

.fswa-tickets__table thead th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.fswa-ticket-row:hover td {
  background: #f9fafb;
}

.fswa-col-id      { width: 60px; }
.fswa-col-status  { width: 110px; }
.fswa-col-updated { width: 180px; white-space: nowrap; }
.fswa-col-action  { width: 80px; text-align: center; }

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.fswa-pagination {
  margin-top: 24px;
  text-align: center;
}

.fswa-pagination .page-numbers {
  display: inline-block;
  padding: 5px 10px;
  margin: 0 2px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}

.fswa-pagination .page-numbers.current,
.fswa-pagination .page-numbers:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* --------------------------------------------------------------------------
   Ticket detail header
   -------------------------------------------------------------------------- */
.fswa-ticket-detail__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.fswa-ticket-detail__id {
  color: #9ca3af;
  font-size: 0.9em;
}

/* --------------------------------------------------------------------------
   Thread / messages
   -------------------------------------------------------------------------- */
.fswa-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.fswa-message {
  padding: 16px 20px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  max-width: 85%;
}

.fswa-message--customer {
  align-self: flex-end;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.fswa-message--agent {
  align-self: flex-start;
  background: #ffffff;
}

.fswa-message__meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.82em;
}

.fswa-message__author {
  font-weight: 600;
}

.fswa-message__date {
  color: #9ca3af;
}

.fswa-message__body {
  line-height: 1.6;
  word-wrap: break-word;
}

.fswa-message__body p:last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Reply / new-ticket forms
   -------------------------------------------------------------------------- */
.fswa-reply-form,
.fswa-new-ticket .fswa-form {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 24px;
}

.fswa-reply-form__title {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1em;
}

.fswa-form-field {
  margin-bottom: 18px;
}

.fswa-form-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.9em;
}

.fswa-form-field input[type="text"],
.fswa-form-field select,
.fswa-form-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.95em;
  font-family: inherit;
  background: #ffffff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fswa-form-field input[type="text"]:focus,
.fswa-form-field select:focus,
.fswa-form-field textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.fswa-form-field textarea {
  resize: vertical;
  min-height: 120px;
}

/* --------------------------------------------------------------------------
   Notices
   -------------------------------------------------------------------------- */
.fswa-notice {
  padding: 10px 14px;
  border-radius: 5px;
  margin-bottom: 16px;
  font-size: 0.92em;
}

.fswa-notice--success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.fswa-notice--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.fswa-notice--info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.fswa-notice--warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* --------------------------------------------------------------------------
   Submit button state
   -------------------------------------------------------------------------- */
.fswa-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.fswa-btn-new-ticket {
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   File upload input
   -------------------------------------------------------------------------- */
.fswa-file-input {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px dashed #d1d5db;
  border-radius: 5px;
  background: #ffffff;
  font-size: 0.9em;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.fswa-file-input:hover,
.fswa-file-input:focus {
  border-color: #dc2626;
  background: #fff5f5;
  outline: none;
}

.fswa-form-field__help {
  margin: 6px 0 0;
  font-size: 0.82em;
  color: #6b7280;
}

/* --------------------------------------------------------------------------
   Turnstile captcha widget
   -------------------------------------------------------------------------- */
.fswa-captcha-field {
  margin-bottom: 20px;
}

/* --------------------------------------------------------------------------
   Empty state
   -------------------------------------------------------------------------- */
.fswa-tickets__empty {
  color: #6b7280;
  font-style: italic;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media ( max-width: 600px ) {
  .fswa-message {
    max-width: 100%;
  }

  .fswa-col-updated,
  .fswa-col-id {
    display: none;
  }
}

/* ==========================================================================
   Knowledge Base
   ========================================================================== */

/* --------------------------------------------------------------------------
   KB shared
   -------------------------------------------------------------------------- */
.fswa-kb {
  max-width: 900px;
}

.fswa-kb__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.fswa-kb__title {
  margin: 0;
}

.fswa-kb__desc {
  color: #6b7280;
  margin-top: -12px;
  margin-bottom: 20px;
}

.fswa-kb__empty {
  color: #6b7280;
  font-style: italic;
}

.fswa-kb__result-count {
  color: #6b7280;
  font-size: 0.9em;
  margin-bottom: 16px;
}

/* --------------------------------------------------------------------------
   KB search bar
   -------------------------------------------------------------------------- */
.fswa-kb-search {
  position: relative;
  margin-bottom: 28px;
}

.fswa-kb-search__form {
  position: relative;
}

.fswa-kb-search__input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.fswa-kb-search__input-wrap:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.fswa-kb-search__input {
  flex: 1;
  border: none;
  outline: none;
  padding: 11px 14px;
  font-size: 1em;
  font-family: inherit;
  background: transparent;
}

.fswa-kb-search__btn {
  border: none;
  background: #dc2626;
  padding: 0 16px;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  align-self: stretch;
  transition: background 0.15s;
}

.fswa-kb-search__btn:hover {
  background: #b91c1c;
  color: #fff;
}

/* Autocomplete suggestions dropdown */
.fswa-kb-search__suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
}

.fswa-kb-search__suggestions[hidden] {
  display: none;
}

.fswa-kb-search__suggestion {
  padding: 0;
}

.fswa-kb-search__suggestion a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  text-decoration: none;
  color: inherit;
  font-size: 0.92em;
  transition: background 0.1s;
}

.fswa-kb-search__suggestion a:hover,
.fswa-kb-search__suggestion a:focus,
.fswa-kb-search__suggestion--active a {
  background: #eff6ff;
  color: #1d4ed8;
}

.fswa-kb-search__suggestion-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

/* --------------------------------------------------------------------------
   Category card grid
   -------------------------------------------------------------------------- */
.fswa-kb-categories {
  display: grid;
  grid-template-columns: repeat( auto-fill, minmax( 260px, 1fr ) );
  gap: 16px;
}

.fswa-kb-category-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.fswa-kb-category-card:hover {
  border-color: #2563eb;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.fswa-kb-category-card__icon {
  flex-shrink: 0;
  color: #dc2626;
  margin-top: 2px;
}

.fswa-kb-category-card__body {
  flex: 1;
  min-width: 0;
}

.fswa-kb-category-card__name {
  margin: 0 0 4px;
  font-size: 1em;
  font-weight: 600;
}

.fswa-kb-category-card__desc {
  margin: 0 0 6px;
  font-size: 0.85em;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fswa-kb-category-card__count {
  font-size: 0.78em;
  color: #9ca3af;
}

.fswa-kb-category-card__arrow {
  color: #9ca3af;
  font-size: 1.4em;
  line-height: 1;
  align-self: center;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Article list (used in category & search views)
   -------------------------------------------------------------------------- */
.fswa-kb-article-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fswa-kb-article-list__item {
  border-bottom: 1px solid #f3f4f6;
}

.fswa-kb-article-list__item:last-child {
  border-bottom: none;
}

.fswa-kb-article-list__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  text-decoration: none;
  color: inherit;
  font-weight: 500;
  transition: color 0.15s;
}

.fswa-kb-article-list__link:hover {
  color: #2563eb;
}

.fswa-kb-article-list__icon {
  flex-shrink: 0;
  color: #9ca3af;
}

.fswa-kb-article-list__views {
  display: block;
  font-size: 0.78em;
  color: #9ca3af;
  padding-left: 24px;
  margin-top: -4px;
  margin-bottom: 4px;
}

.fswa-kb-article-list__item--search .fswa-kb-article-list__link {
  margin-bottom: 2px;
}

.fswa-kb-article-list__excerpt {
  margin: 0 0 10px 24px;
  font-size: 0.85em;
  color: #6b7280;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Article body
   -------------------------------------------------------------------------- */
.fswa-kb-article__header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

.fswa-kb-article__title {
  margin: 0 0 6px;
}

.fswa-kb-article__meta {
  margin: 0;
  font-size: 0.82em;
  color: #9ca3af;
}

.fswa-kb-article__body {
  line-height: 1.75;
  color: #374151;
  margin-bottom: 32px;
}

.fswa-kb-article__body h1,
.fswa-kb-article__body h2,
.fswa-kb-article__body h3 {
  margin-top: 1.5em;
}

.fswa-kb-article__body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.fswa-kb-article__body pre,
.fswa-kb-article__body code {
  background: #f3f4f6;
  border-radius: 4px;
  font-size: 0.88em;
}

.fswa-kb-article__body pre {
  padding: 14px 16px;
  overflow-x: auto;
}

.fswa-kb-article__body code {
  padding: 1px 5px;
}

.fswa-kb-article__body blockquote {
  border-left: 4px solid #e5e7eb;
  margin-left: 0;
  padding-left: 16px;
  color: #6b7280;
}

.fswa-kb-article__footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.fswa-kb-article__contact-btn {
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   New-ticket form footer (submit + Turnstile)
   -------------------------------------------------------------------------- */
.fswa-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

/* On narrow screens stack them vertically, widget below the button */
@media ( max-width: 480px ) {
  .fswa-form-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --------------------------------------------------------------------------
   KB responsive
   -------------------------------------------------------------------------- */
@media ( max-width: 600px ) {
  .fswa-kb-categories {
    grid-template-columns: 1fr;
  }

  .fswa-kb-article__contact-btn {
    margin-left: 0;
    width: 100%;
    text-align: center;
  }
}
