/* AI Persian Chatbot - Frontend Styles */

/* Product Cards in Chat */
.apc-products-message {
    background: #f8f9fa !important;
}

.apc-products-title {
    font-weight: bold;
    margin-bottom: 10px;
    color: #2271b1;
    font-size: 14px;
}

.apc-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.apc-product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    transition: box-shadow 0.2s;
    font-size: 12px;
}

.apc-product-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.apc-product-image {
    margin-bottom: 8px;
}

.apc-product-image img {
    max-width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.apc-product-title {
    font-size: 12px;
    font-weight: bold;
    margin: 6px 0;
    line-height: 1.3;
    color: #333;
}

.apc-product-description {
    font-size: 11px;
    color: #666;
    margin: 4px 0;
    line-height: 1.3;
}

.apc-product-actions {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.apc-sale-badge {
    background: #ff4444;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.apc-product-price {
    color: #2271b1;
    font-weight: bold;
    margin: 4px 0;
    font-size: 11px;
}

.apc-product-link {
    display: inline-block;
    background: #2271b1;
    color: white !important;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 10px;
    margin-top: 6px;
    transition: background 0.2s;
}

.apc-product-link:hover {
    background: #1e5a8a;
    color: white !important;
}

/* RTL Support for Products */
.apc-chat-widget[data-language="fa"] .apc-products-explanation {
    text-align: right;
    direction: rtl;
}

.apc-chat-widget[data-language="fa"] .apc-products-title {
    text-align: right;
}

.apc-chat-widget[data-language="fa"] .apc-product-card {
    text-align: right;
}

.apc-chat-widget[data-language="fa"] .apc-product-title {
    text-align: right;
}

/* RTL support for horizontal products */
.apc-chat-widget[data-language="fa"] .apc-products-horizontal {
    direction: ltr; /* Keep horizontal scrolling direction consistent */
}

.apc-chat-widget[data-language="fa"] .apc-products-horizontal .apc-product-card {
    text-align: right;
}

/* Error message styling */
.apc-error-message {
    background: #fdf0f0 !important;
    border-left: 3px solid #dc3232;
}

.apc-error-message .apc-message-content {
    color: #dc3232;
}

.apc-chat-widget {
    position: fixed;
    z-index: 9999;
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif;
    direction: ltr; /* Default to LTR, will be overridden for Persian */
}

/* RTL Support for Persian */
.apc-chat-widget[data-language="fa"] {
    direction: rtl;
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif;
}

.apc-chat-widget[data-language="fa"] .apc-message {
    text-align: right;
}

.apc-chat-widget[data-language="fa"] .apc-user-message {
    margin-left: 50px;
    margin-right: 0;
}

.apc-chat-widget[data-language="fa"] .apc-bot-message {
    margin-right: 50px;
    margin-left: 0;
}

.apc-chat-widget[data-language="fa"] .apc-input-container {
    flex-direction: row-reverse;
}

.apc-chat-widget[data-language="fa"] .apc-send-button {
    border-radius: 8px 0 0 8px;
}

/* Widget positioning */
.apc-chat-widget.apc-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.apc-chat-widget.apc-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.apc-chat-widget.apc-position-top-right {
    top: 20px;
    right: 20px;
}

.apc-chat-widget.apc-position-top-left {
    top: 20px;
    left: 20px;
}

/* Chat window positioning */
.apc-position-bottom-right .apc-chat-window {
    bottom: 80px;
    right: 0;
    transform-origin: bottom right;
}

.apc-position-bottom-left .apc-chat-window {
    bottom: 80px;
    left: 0;
    transform-origin: bottom left;
}

.apc-position-top-right .apc-chat-window {
    top: 80px;
    right: 0;
    transform-origin: top right;
}

.apc-position-top-left .apc-chat-window {
    top: 80px;
    left: 0;
    transform-origin: top left;
}

/* Chat toggle button */
.apc-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    position: relative;
}

.apc-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

.apc-chat-toggle svg {
    width: 28px;
    height: 28px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
}

.apc-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: apc-pulse 2s infinite;
}

@keyframes apc-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Chat window */
.apc-chat-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - 100px);
}

@media (max-width: 480px) {
    .apc-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
    }
}

/* Chat header */
.apc-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.apc-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.apc-chat-title-text {
    font-weight: 600;
    font-size: 16px;
}

.apc-language-switcher {
    margin-left: 10px;
}

.apc-lang-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.apc-lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.apc-chat-controls {
    display: flex;
    gap: 5px;
}

.apc-control-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.apc-control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages area */
.apc-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    max-height: 300px;
}

.apc-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.apc-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.apc-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.apc-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Message styles */
.apc-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    animation: apc-fadeInUp 0.3s ease;
}

@keyframes apc-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.apc-user-message {
    align-items: flex-end;
}

.apc-bot-message {
    align-items: flex-start;
}

.apc-message-content {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.6;
    word-wrap: break-word;
}

.apc-message-content p {
    margin: 0 0 12px 0;
    line-height: 1.6;
    text-align: justify;
}

.apc-message-content p:last-child {
    margin-bottom: 0;
}

/* Better formatting for lists in messages */
.apc-message-content br + br {
    line-height: 0.5;
}

/* RTL text alignment for Persian */
.apc-chat-widget[data-language="fa"] .apc-message-content p,
.apc-chatbot-embed[data-language="fa"] .apc-message-content p {
    text-align: right;
    direction: rtl;
}

.apc-user-message .apc-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.apc-bot-message .apc-message-content {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.apc-error-message .apc-message-content {
    background: #fff5f5;
    border-color: #fed7d7;
    color: #c53030;
}

.apc-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
    padding: 0 5px;
}

/* Products display */
.apc-products-message {
    align-items: stretch;
    margin-top: 10px;
}

.apc-products-explanation {
    font-size: 14px;
    color: #4a5568;
    margin-bottom: 8px;
    padding: 0 5px;
    line-height: 1.4;
    font-style: italic;
}

.apc-products-title {
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 10px;
    padding: 0 5px;
}

.apc-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.apc-products-horizontal {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    padding: 5px;
    margin: 0 -5px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 #f7fafc;
}

.apc-products-horizontal::-webkit-scrollbar {
    height: 6px;
}

.apc-products-horizontal::-webkit-scrollbar-track {
    background: #f7fafc;
    border-radius: 3px;
}

.apc-products-horizontal::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.apc-products-horizontal::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.apc-products-horizontal .apc-product-card {
    flex: 0 0 auto;
    width: 160px;
    min-height: 220px;
    display: flex;
    flex-direction: column;
}

.apc-product-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    position: relative;
}

.apc-product-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.apc-product-image {
    position: relative;
    height: 80px;
    overflow: hidden;
}

.apc-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.apc-similarity-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: linear-gradient(135deg, #48bb78, #38a169);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.apc-sale-badge {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #e53e3e;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.apc-product-info {
    padding: 8px;
}

.apc-product-title {
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 4px 0;
    line-height: 1.3;
    color: #2d3748;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.apc-product-price {
    font-weight: 600;
    color: #667eea;
    font-size: 13px;
    margin-bottom: 6px;
}

.apc-product-desc {
    font-size: 11px;
    color: #718096;
    margin: 4px 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.apc-product-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.apc-view-product, .apc-add-to-cart {
    font-size: 11px;
    padding: 6px 8px;
    border-radius: 4px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.apc-view-product {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.apc-view-product:hover {
    background: #edf2f7;
    text-decoration: none;
}

.apc-add-to-cart {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.apc-add-to-cart:hover:not(:disabled) {
    background: #5a6fd8;
}

.apc-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.apc-added-to-cart {
    background: #48bb78 !important;
}

.apc-out-of-stock {
    font-size: 11px;
    color: #e53e3e;
    text-align: center;
    padding: 6px;
    font-weight: 600;
}

/* Typing indicator */
.apc-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    color: #718096;
    font-size: 13px;
}

.apc-typing-dots {
    display: flex;
    gap: 3px;
}

.apc-typing-dots span {
    width: 6px;
    height: 6px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: apc-typing 1.4s ease-in-out infinite both;
}

.apc-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.apc-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes apc-typing {
    0%, 80%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Input area */
.apc-chat-input-area {
    border-top: 1px solid #e9ecef;
    background: white;
    padding: 15px;
}

.apc-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

.apc-input-container:focus-within {
    border-color: #667eea;
}

.apc-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    font-family: inherit;
    min-height: 20px;
    max-height: 100px;
}

.apc-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #667eea;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.apc-send-btn:hover:not(:disabled) {
    background: #5a6fd8;
    transform: scale(1.05);
}

.apc-send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

.apc-char-counter {
    font-size: 11px;
    color: #a0aec0;
    text-align: right;
    margin-top: 4px;
    transition: color 0.2s ease;
}

.apc-char-counter.apc-warning {
    color: #ed8936;
}

/* Persian language support */
.apc-chat-widget[data-language="fa"] {
    direction: rtl;
}

.apc-chat-widget[data-language="fa"] .apc-chat-window {
    left: 0;
    right: auto;
}

.apc-chat-widget[data-language="fa"] .apc-user-message {
    align-items: flex-start;
}

.apc-chat-widget[data-language="fa"] .apc-bot-message {
    align-items: flex-end;
}

.apc-chat-widget[data-language="fa"] .apc-user-message .apc-message-content {
    border-bottom-right-radius: 18px;
    border-bottom-left-radius: 4px;
}

.apc-chat-widget[data-language="fa"] .apc-bot-message .apc-message-content {
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 4px;
}

/* RTL support for shortcode */
.apc-chatbot-embed[data-language="fa"] {
    direction: rtl;
}

.apc-chatbot-embed[data-language="fa"] .apc-message {
    text-align: right;
}

.apc-chatbot-embed[data-language="fa"] .apc-user-message {
    align-items: flex-start;
}

.apc-chatbot-embed[data-language="fa"] .apc-bot-message {
    align-items: flex-end;
}

/* Shortcode embed styles */
.apc-chatbot-embed {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif;
}

/* Ensure font is applied to all elements in shortcode */
.apc-chatbot-embed,
.apc-chatbot-embed * {
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif !important;
}

/* RTL support for Persian in shortcode */
.apc-chatbot-embed[data-language="fa"],
.apc-chatbot-embed[data-language="fa"] * {
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif !important;
    direction: rtl;
}

/* Typing indicator for shortcode */
.apc-chatbot-embed .apc-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    color: #718096;
    font-size: 13px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.apc-embed-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    min-height: 200px;
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif !important;
}

/* Ensure proper message formatting in shortcode */
.apc-embed-messages .apc-message-content {
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif !important;
}

.apc-embed-messages .apc-message-content p {
    margin: 0 0 12px 0;
    line-height: 1.6;
    font-family: 'Vazir', 'Tahoma', 'Arial Unicode MS', Arial, sans-serif !important;
}

/* RTL support for shortcode messages */
.apc-chatbot-embed[data-language="fa"] .apc-embed-messages .apc-message-content p {
    text-align: right;
    direction: rtl;
}

.apc-embed-products {
    padding: 15px;
    border-top: 1px solid #e9ecef;
    background: white;
}

.apc-embed-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.apc-embed-input {
    border-top: 1px solid #e9ecef;
    padding: 15px;
    background: white;
}

/* User Questions Styles */
.apc-question-form {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    margin: 10px 0;
    max-width: 100%;
}

.apc-question-input-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.apc-question-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.apc-question-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.apc-question-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.apc-question-submit-btn,
.apc-question-skip-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apc-question-submit-btn {
    background: #667eea;
    color: white;
}

.apc-question-submit-btn:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.apc-question-submit-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.apc-question-skip-btn {
    background: #e2e8f0;
    color: #4a5568;
}

.apc-question-skip-btn:hover {
    background: #cbd5e0;
    transform: translateY(-1px);
}

.apc-question-skip-btn:disabled {
    background: #f7fafc;
    color: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

/* RTL support for questions */
.apc-chat-widget[data-language="fa"] .apc-question-buttons {
    justify-content: flex-start;
}

.apc-chatbot-embed[data-language="fa"] .apc-question-buttons {
    justify-content: flex-start;
}

.apc-chatbot-embed[data-language="fa"] .apc-question-input {
    text-align: right;
    direction: rtl;
}

.apc-chat-widget[data-language="fa"] .apc-question-input {
    text-align: right;
    direction: rtl;
}

/* Responsive design for questions */
@media (max-width: 480px) {
    .apc-question-buttons {
        flex-direction: column;
    }
    
    .apc-question-submit-btn,
    .apc-question-skip-btn {
        width: 100%;
        justify-content: center;
    }
}

.apc-embed-form {
    display: flex;
    gap: 10px;
}

.apc-embed-input-field {
    flex: 1;
    padding: 10px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    outline: none;
    font-size: 14px;
}

.apc-embed-input-field:focus {
    border-color: #667eea;
}

.apc-embed-send {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
}

.apc-embed-send:hover {
    background: #5a6fd8;
}

/* Success notification */
.apc-cart-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #48bb78;
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    font-weight: 600;
    z-index: 10000;
    animation: apc-slideInRight 0.3s ease;
}

@keyframes apc-slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .apc-chat-window {
        width: 320px;
    }
    
    .apc-products-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .apc-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .apc-products-grid {
        grid-template-columns: 1fr;
    }
    
    .apc-product-card {
        display: flex;
        flex-direction: row;
        height: auto;
    }
    
    .apc-product-image {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
    }
    
    .apc-product-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    
    .apc-product-actions {
        flex-direction: row;
        justify-content: space-between;
    }
    
    .apc-product-actions > * {
        flex: 1;
        margin: 0 2px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .apc-chat-window {
        background: #2d3748;
        color: white;
    }
    
    .apc-chat-messages {
        background: #1a202c;
    }
    
    .apc-bot-message .apc-message-content {
        background: #4a5568;
        color: white;
        border-color: #718096;
    }
    
    .apc-product-card {
        background: #4a5568;
        border-color: #718096;
    }
    
    .apc-product-title {
        color: white;
    }
    
    .apc-input-container {
        background: #4a5568;
        border-color: #718096;
    }
    
    .apc-chat-input {
        color: white;
    }
    
    .apc-chat-input::placeholder {
        color: #a0aec0;
    }
}

/* Accessibility improvements */
.apc-chat-toggle:focus,
.apc-control-btn:focus,
.apc-lang-btn:focus,
.apc-send-btn:focus,
.apc-add-to-cart:focus,
.apc-view-product:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .apc-chat-toggle {
        background: #000;
        border: 2px solid #fff;
    }
    
    .apc-user-message .apc-message-content {
        background: #000;
        border: 1px solid #fff;
    }
    
    .apc-bot-message .apc-message-content {
        background: #fff;
        border: 2px solid #000;
        color: #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .apc-chat-widget * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Customer Profile Form Styles */
.apc-profile-form {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.apc-profile-form::-webkit-scrollbar {
    width: 6px;
}

.apc-profile-form::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.apc-profile-form::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.apc-profile-form::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.apc-profile-header {
    text-align: center;
    margin-bottom: 20px;
}

.apc-profile-header h3 {
    color: #333;
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
}

.apc-profile-header p {
    color: #666;
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
}

.apc-profile-form-element {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.apc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.apc-form-group {
    display: flex;
    flex-direction: column;
}

.apc-form-group label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    margin-bottom: 5px;
    line-height: 1.3;
}

.apc-form-group input,
.apc-form-group select,
.apc-form-group textarea {
    padding: 10px 12px;
    border: 1.5px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: white;
}

.apc-form-group input:focus,
.apc-form-group select:focus,
.apc-form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

.apc-form-group textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.4;
}

.apc-form-group input::placeholder,
.apc-form-group textarea::placeholder {
    color: #999;
    font-size: 13px;
}

.apc-profile-submit {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    align-self: center;
    min-width: 150px;
}

.apc-profile-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.apc-profile-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* RTL support for profile form */
.apc-chat-widget[data-language="fa"] .apc-profile-header,
.apc-chat-widget[data-language="fa"] .apc-form-group {
    text-align: right;
}

.apc-chat-widget[data-language="fa"] .apc-form-group label {
    text-align: right;
}

.apc-chat-widget[data-language="fa"] .apc-form-group input,
.apc-chat-widget[data-language="fa"] .apc-form-group select,
.apc-chat-widget[data-language="fa"] .apc-form-group textarea {
    text-align: right;
    direction: rtl;
}

.apc-chat-widget[data-language="fa"] .apc-profile-submit {
    align-self: center;
}

/* Mobile responsive adjustments for profile form */
@media (max-width: 480px) {
    .apc-profile-form {
        padding: 15px;
    }
    
    .apc-form-row {
        grid-template-columns: 1fr;
    }
    
    .apc-profile-header h3 {
        font-size: 16px;
    }
    
    .apc-profile-header p {
        font-size: 13px;
    }
    
    .apc-form-group label {
        font-size: 12px;
    }
    
    .apc-form-group input,
    .apc-form-group select,
    .apc-form-group textarea {
        font-size: 13px;
        padding: 9px 10px;
    }
    
    .apc-profile-submit {
        font-size: 15px;
        padding: 11px 20px;
        width: 100%;
    }
}

/* Dynamic Questions Form Styles */
.apc-dynamic-form {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
    border: 1px solid #e0e0e0;
}

.apc-dynamic-form h4 {
    color: #2271b1;
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.apc-dynamic-form p {
    color: #666;
    margin: 0 0 20px 0;
    font-size: 14px;
    line-height: 1.5;
}

.apc-form-group {
    margin-bottom: 15px;
}

.apc-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
    font-size: 13px;
}

.apc-form-group input,
.apc-form-group select,
.apc-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.apc-form-group input:focus,
.apc-form-group select:focus,
.apc-form-group textarea:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

.apc-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.apc-submit-btn {
    background: #2271b1;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 10px;
}

.apc-submit-btn:hover {
    background: #1e5a8a;
}

.apc-submit-btn:active {
    transform: translateY(1px);
}

/* RTL support for dynamic form */
.apc-chat-widget[data-language="fa"] .apc-dynamic-form,
.apc-chatbot-embed[data-language="fa"] .apc-dynamic-form {
    direction: rtl;
    text-align: right;
}

.apc-chat-widget[data-language="fa"] .apc-form-group label,
.apc-chatbot-embed[data-language="fa"] .apc-form-group label {
    text-align: right;
}

/* Mobile responsive for dynamic form */
@media (max-width: 480px) {
    .apc-dynamic-form {
        padding: 15px;
    }
    
    .apc-dynamic-form h4 {
        font-size: 15px;
    }
    
    .apc-dynamic-form p {
        font-size: 13px;
    }
    
    .apc-form-group input,
    .apc-form-group select,
    .apc-form-group textarea {
        font-size: 13px;
        padding: 9px 10px;
    }
    
    .apc-submit-btn {
        width: 100%;
        font-size: 15px;
        padding: 12px;
    }
}