/* * Smart FAQ Widget Styles
 * Refactored for RTL/LTR support using CSS Logical Properties
 */

:root {
    /* Color Palette */
    --sfaq-color-bg: #FFFFFF;
    --sfaq-color-text-dark: #333333;
    --sfaq-color-text-light: #666666;
    --sfaq-color-accent: #FF7F50;
    --sfaq-color-accent-hover: #e66a3c;
    --sfaq-color-border: #E5E7EB;
    --sfaq-color-glass: rgba(255, 255, 255, 0.85);
    
    /* UI Settings */
    --sfaq-radius: 1rem;
    --sfaq-shadow-soft: 0 4px 10px rgba(0, 0, 0, 0.05);
    --sfaq-shadow-lifted: 0 10px 40px -10px rgba(0, 0, 0, 0.1);
    
    /* Font: Will be inherited or set via PHP */
    --sfaq-font-main: inherit; 
    --sfaq-transition: all 0.3s ease;
}

/* --- Main Container --- */
.sfaq-wrapper {
    width: 100%;
    max-width: 672px; /* max-w-2xl */
    margin: 2rem auto;
    font-family: var(--sfaq-font-main);
    color: var(--sfaq-color-text-dark);
    position: relative;
    /* direction is handled by WordPress body class (rtl/ltr) */
    line-height: 1.6;
    box-sizing: border-box;
}

.sfaq-wrapper * {
    box-sizing: border-box;
}

/* Widget Header */
.sfaq-title-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.sfaq-main-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--sfaq-color-text-dark);
    margin-bottom: 0.5rem;
}

.sfaq-subtitle {
    font-size: 0.875rem;
    color: var(--sfaq-color-text-light);
    opacity: 0.8;
}

/* --- Search Box --- */
.sfaq-search-box {
    position: relative;
    width: 100%;
    background: #fff;
    border-radius: 9999px;
    box-shadow: var(--sfaq-shadow-soft);
    z-index: 20;
    transition: var(--sfaq-transition);
    border: 1px solid transparent;
}

.sfaq-search-box:hover,
.sfaq-search-box:focus-within {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: rgba(255, 127, 80, 0.3);
}

.sfaq-search-inner {
    display: flex;
    align-items: center;
    height: 4rem; /* 64px */
    /* LOGICAL PADDING: start is right in RTL, left in LTR */
    padding-inline-start: 1.25rem;
    padding-inline-end: 0.5rem;
}

.sfaq-search-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    /* LOGICAL MARGIN */
    margin-inline-end: 0.75rem;
    color: #9CA3AF;
}

.sfaq-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent;
    padding: 0 0.5rem;
    font-size: 1rem;
    font-family: var(--sfaq-font-main);
    color: var(--sfaq-color-text-dark);
    /* Ensure text input follows direction */
    text-align: start; 
}

.sfaq-input::placeholder {
    color: #9CA3AF;
}

/* Buttons inside Search */
.sfaq-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sfaq-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: var(--sfaq-transition);
}

.sfaq-btn-clear {
    background: #F3F4F6;
    color: #6B7280;
}

.sfaq-btn-clear:hover {
    background: #FEE2E2;
    color: #EF4444;
}

.sfaq-btn-arrow {
    background: var(--sfaq-color-accent);
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* LTR Fix for Arrow Icon */
html[dir="ltr"] .sfaq-btn-arrow span {
    transform: rotate(180deg);
}

.sfaq-btn-arrow:hover {
    background: var(--sfaq-color-accent-hover);
}

.hidden {
    display: none !important;
}

/* --- Results Panel (Glassmorphism) --- */
.sfaq-results-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    padding-top: 0.75rem;
    z-index: 10;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.98);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
}

.sfaq-results-container.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.sfaq-glass-panel {
    background: var(--sfaq-color-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--sfaq-radius);
    box-shadow: var(--sfaq-shadow-lifted);
    overflow: hidden;
    text-align: start; 
    position: relative; /* For Close Button */
}

/* --- NEW: Close Results Button --- */
.sfaq-result-close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem; /* In RTL this will be right, we might need logical property or manual flip */
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: all 0.2s;
}

.sfaq-result-close-btn:hover {
    background: #FEE2E2;
    color: #EF4444;
}

/* RTL support for Close Button */
html[dir="rtl"] .sfaq-result-close-btn {
    right: auto;
    left: 0.5rem;
}

/* List Header */
.sfaq-list-header {
    padding: 0.75rem 1.25rem;
    background: rgba(255, 255, 255, 0.4);
    border-bottom: 1px solid rgba(229, 231, 235, 0.5);
    font-size: 0.75rem;
    font-weight: bold;
    color: #9CA3AF;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* List Items */
.sfaq-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sfaq-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(243, 244, 246, 0.6);
    cursor: pointer;
    transition: background 0.2s;
    background: transparent;
}

.sfaq-item:hover {
    background: rgba(255, 255, 255, 0.8);
}

.sfaq-question-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sfaq-question-text {
    font-weight: 500;
    font-size: 0.95rem;
    text-align: start;
}

.sfaq-highlight {
    color: var(--sfaq-color-accent);
    font-weight: bold;
}

.sfaq-arrow-icon {
    color: #9CA3AF;
    transition: transform 0.3s ease;
}

/* Active Accordion */
.sfaq-item.active .sfaq-arrow-icon {
    transform: rotate(180deg);
    color: var(--sfaq-color-accent);
}

.sfaq-answer {
    max-height: 0;
    overflow: hidden;
    color: var(--sfaq-color-text-light);
    font-size: 0.875rem;
    line-height: 1.8;
    transition: max-height 0.4s ease-out, padding 0.3s ease;
    text-align: start;
}

.sfaq-item.active .sfaq-answer {
    max-height: 1000px;
    padding-top: 0.75rem;
}

/* Actions below answer */
.sfaq-answer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(229, 231, 235, 0.5);
}

.sfaq-link-btn {
    font-size: 0.75rem;
    color: var(--sfaq-color-accent);
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sfaq-link-btn:hover {
    text-decoration: underline;
}

.sfaq-like-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: #fff;
    border: 1px solid #F3F4F6;
    border-radius: 9999px;
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.2s;
}

.sfaq-like-btn:hover {
    background: #FFF7ED;
    color: var(--sfaq-color-accent);
    border-color: #FFEDD5;
}

.sfaq-like-btn.liked {
    background: #FFF7ED;
    color: var(--sfaq-color-accent);
    border-color: #FFEDD5;
}

/* --- Footer (Not Found / Ask) --- */
.sfaq-footer {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.4);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    text-align: center;
    font-size: 0.875rem;
    color: var(--sfaq-color-text-light);
}

.sfaq-ask-link {
    background: transparent;
    border: none;
    color: var(--sfaq-color-accent);
    font-weight: bold;
    cursor: pointer;
    font-family: var(--sfaq-font-main);
    font-size: inherit;
}

.sfaq-ask-link:hover {
    text-decoration: underline;
}

.sfaq-btn-primary {
    width: 100%;
    background: rgba(255, 127, 80, 0.1);
    color: var(--sfaq-color-accent);
    border: 1px solid rgba(255, 127, 80, 0.2);
    padding: 0.625rem;
    border-radius: 0.5rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
    font-family: var(--sfaq-font-main);
}

.sfaq-btn-primary:hover {
    background: var(--sfaq-color-accent);
    color: white;
}

/* --- Form View --- */
.sfaq-form-view {
    padding: 1.25rem;
    background: rgba(255, 255, 255, 0.95);
    text-align: start;
}

.sfaq-form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #F3F4F6;
}

.sfaq-form-title {
    font-weight: bold;
    color: var(--sfaq-color-text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sfaq-btn-close {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: var(--sfaq-color-text-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sfaq-btn-close:hover {
    color: #EF4444;
}

.sfaq-form-group {
    margin-bottom: 0.75rem;
}

.sfaq-label {
    display: block;
    font-size: 0.75rem;
    color: var(--sfaq-color-text-light);
    margin-bottom: 0.25rem;
    text-align: start;
}

.sfaq-textarea, .sfaq-text-input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #E5E7EB;
    background: #F9FAFB;
    font-family: var(--sfaq-font-main);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s;
    text-align: start;
}

.sfaq-textarea:focus, .sfaq-text-input:focus {
    background: #fff;
    border-color: var(--sfaq-color-accent);
    box-shadow: 0 0 0 1px var(--sfaq-color-accent);
}

.sfaq-textarea {
    min-height: 80px;
    resize: vertical;
}

.sfaq-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.sfaq-btn-submit {
    width: 100%;
    margin-top: 0.5rem;
    background: var(--sfaq-color-accent);
    color: white;
    border: none;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-weight: bold;
    font-family: var(--sfaq-font-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s;
    box-shadow: var(--sfaq-shadow-soft);
}

/* LTR Fix for Submit button icon */
html[dir="ltr"] .sfaq-btn-submit .material-symbols-outlined {
    transform: rotate(180deg) scaleY(-1); 
}

.sfaq-btn-submit:hover {
    background: var(--sfaq-color-accent-hover);
}

.sfaq-btn-submit:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
}

/* --- Success Message --- */
.sfaq-success-view {
    padding: 2rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
}

.sfaq-success-icon {
    width: 4rem;
    height: 4rem;
    background: #ECFDF5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem auto;
    animation: bounce 1s ease-in-out;
}

.sfaq-success-icon span {
    font-size: 2.25rem;
    color: #10B981;
}

.sfaq-success-title {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.75rem;
}

.sfaq-success-msg {
    font-size: 0.875rem;
    color: var(--sfaq-color-text-light);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(-5%); animation-timing-function: cubic-bezier(0.8, 0, 1, 1); }
    50% { transform: translateY(0); animation-timing-function: cubic-bezier(0, 0, 0.2, 1); }
}

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

.animate-spin {
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* Mobile */
@media (max-width: 640px) {
    .sfaq-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Categories (Tabs) */
.sfaq-categories {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 5px;
    white-space: nowrap;
    scrollbar-width: none; 
}
.sfaq-categories::-webkit-scrollbar { display: none; }

.sfaq-cat-btn {
    background: #fff;
    border: 1px solid var(--sfaq-color-border);
    color: var(--sfaq-color-text-light);
    padding: 0.4rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    font-family: var(--sfaq-font-main);
    transition: all 0.2s;
}

.sfaq-cat-btn:hover {
    background: #f9fafb;
    color: var(--sfaq-color-text-dark);
}

.sfaq-cat-btn.active {
    background: var(--sfaq-color-accent);
    color: white;
    border-color: var(--sfaq-color-accent);
    box-shadow: 0 4px 6px -1px rgba(255, 127, 80, 0.2);
}