/**
 * Public-facing styles for AI Assistant
 */

:root {
    --ai-primary-color: #2271b1;
    --ai-text-color: #1d2327;
    --ai-bg-color: #ffffff;
    --ai-border-color: #dcdcde;
    --ai-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --ai-border-radius: 8px;
    --ai-chat-width: 350px;
    --ai-chat-height: 500px;
}

/* High contrast mode */
.ai-assistant-chat-widget.ai-high-contrast {
    --ai-primary-color: #000000;
    --ai-text-color: #000000;
    --ai-bg-color: #ffffff;
    --ai-border-color: #000000;
}

/* Main widget container */
.ai-assistant-chat-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    z-index: 9999;
}

.ai-assistant-chat-widget * {
    box-sizing: border-box;
}

/* Embedded positioning */
.ai-assistant-chat-widget.ai-position-embedded {
    position: relative;
    margin: 20px 0;
    max-width: var(--ai-chat-width);
}

/* Fixed positioning */
.ai-assistant-chat-widget:not(.ai-position-embedded) {
    position: fixed;
    z-index: 9999;
}

.ai-assistant-chat-widget.ai-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.ai-assistant-chat-widget.ai-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.ai-assistant-chat-widget.ai-position-top-right {
    top: 20px;
    right: 20px;
}

.ai-assistant-chat-widget.ai-position-top-left {
    top: 20px;
    left: 20px;
}

/* Floating trigger button */
.ai-chat-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--ai-primary-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ai-shadow);
    transition: all 0.3s ease;
    color: white;
}

.ai-chat-trigger:hover {
    transform: scale(1.05);
}

.ai-chat-trigger .ai-close-icon {
    display: none;
}

.ai-assistant-chat-widget:not(.ai-minimized) .ai-chat-trigger .ai-chat-icon {
    display: none;
}

.ai-assistant-chat-widget:not(.ai-minimized) .ai-chat-trigger .ai-close-icon {
    display: block;
}

/* Chat window */
.ai-chat-window {
    width: var(--ai-chat-width);
    height: var(--ai-chat-height);
    background-color: var(--ai-bg-color);
    border: 1px solid var(--ai-border-color);
    border-radius: var(--ai-border-radius);
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.ai-assistant-chat-widget.ai-minimized .ai-chat-window {
    display: none;
}

/* Header */
.ai-chat-header {
    background-color: var(--ai-primary-color);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-assistant-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-assistant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-assistant-name {
    font-weight: 600;
}

.ai-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4ade80;
}

.ai-chat-minimize {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.ai-chat-minimize:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Consent wrapper */
.ai-consent-wrapper {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid var(--ai-border-color);
}

.ai-consent-message p {
    margin: 0 0 16px;
    color: var(--ai-text-color);
}

.ai-consent-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.ai-consent-accept,
.ai-consent-decline {
    padding: 8px 16px;
    border: 1px solid var(--ai-border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.ai-consent-accept {
    background-color: var(--ai-primary-color);
    color: white;
    border-color: var(--ai-primary-color);
}

.ai-consent-accept:hover {
    background-color: #135e96;
}

.ai-consent-decline {
    background-color: white;
    color: var(--ai-text-color);
}

.ai-consent-decline:hover {
    background-color: #f6f7f7;
}

/* Messages area */
.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: #f8f9fa;
}

.ai-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.ai-message-user {
    align-items: flex-end;
}

.ai-message-assistant {
    align-items: flex-start;
}

.ai-message-content {
    max-width: 80%;
    padding: 12px;
    border-radius: var(--ai-border-radius);
    word-wrap: break-word;
}

.ai-message-user .ai-message-content {
    background-color: var(--ai-primary-color);
    color: white;
}

.ai-message-assistant .ai-message-content {
    background-color: white;
    color: var(--ai-text-color);
    border: 1px solid var(--ai-border-color);
}

/* Typing indicator */
.ai-typing-indicator {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #6b7280;
    font-size: 12px;
}

.ai-typing-indicator::before {
    content: "AI is typing";
    margin-right: 8px;
}

.ai-typing-indicator span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #9ca3af;
    animation: typing-pulse 1.4s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-pulse {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    40% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Privacy notice */
.ai-privacy-notice {
    padding: 8px 16px;
    background-color: #f0f0f1;
    border-top: 1px solid var(--ai-border-color);
    text-align: center;
}

.ai-privacy-notice small {
    color: #646970;
    font-size: 12px;
}

/* Input area */
.ai-chat-input-wrapper {
    padding: 16px;
    border-top: 1px solid var(--ai-border-color);
    background-color: var(--ai-bg-color);
}

.ai-input-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid var(--ai-border-color);
    border-radius: var(--ai-border-radius);
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 36px;
    max-height: 100px;
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--ai-primary-color);
}

.ai-send-button {
    background-color: var(--ai-primary-color);
    color: white;
    border: none;
    border-radius: var(--ai-border-radius);
    padding: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    min-width: 36px;
    height: 36px;
}

.ai-send-button:hover:not(:disabled) {
    background-color: #135e96;
}

.ai-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-char-counter {
    font-size: 12px;
    color: #646970;
    text-align: right;
    margin-top: 4px;
}

.ai-char-counter.ai-over-limit {
    color: #d63638;
}

/* Accessibility toolbar */
.ai-accessibility-toolbar {
    padding: 8px;
    border-top: 1px solid var(--ai-border-color);
    display: flex;
    gap: 8px;
    justify-content: center;
    background-color: #f6f7f7;
}

.ai-accessibility-toolbar button {
    background: none;
    border: 1px solid var(--ai-border-color);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    color: var(--ai-text-color);
    transition: all 0.2s;
}

.ai-accessibility-toolbar button:hover {
    background-color: var(--ai-bg-color);
    border-color: var(--ai-primary-color);
}

/* Error messages */
.ai-error-message {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px;
    margin: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
}

/* Font size adjustments */
.ai-assistant-chat-widget.ai-font-small {
    font-size: 12px;
}

.ai-assistant-chat-widget.ai-font-large {
    font-size: 16px;
}

.ai-assistant-chat-widget.ai-font-xl {
    font-size: 18px;
}

/* Theme variations */
.ai-theme-minimal {
    --ai-border-radius: 2px;
    --ai-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-theme-material {
    --ai-border-radius: 4px;
    --ai-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.ai-theme-classic {
    --ai-border-radius: 12px;
}

/* Animations */
.ai-assistant-chat-widget:not(.ai-no-animations) .ai-chat-window {
    animation: slideInUp 0.3s ease-out;
}

.ai-assistant-chat-widget.ai-minimized:not(.ai-no-animations) .ai-chat-window {
    animation: slideOutDown 0.3s ease-in;
}

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

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

/* Mobile responsive */
@media (max-width: 768px) {
    .ai-assistant-chat-widget:not(.ai-position-embedded) {
        bottom: 10px;
        right: 10px;
        left: 10px;
        position: fixed;
    }
    
    .ai-chat-window {
        width: 100%;
        height: 60vh;
        max-height: 500px;
    }
    
    .ai-chat-trigger {
        position: fixed;
        bottom: 20px;
        right: 20px;
    }
}

/* Screen reader only content */
.ai-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for keyboard navigation */
.ai-assistant-chat-widget button:focus,
.ai-assistant-chat-widget textarea:focus,
.ai-assistant-chat-widget input:focus {
    outline: 2px solid var(--ai-primary-color);
    outline-offset: 2px;
}

/* Loading state */
.ai-assistant-chat-widget.ai-loading .ai-send-button {
    animation: spin 1s linear infinite;
}

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

/* Honeypot field - hidden from users */
.ai-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

/* Typing effect cursor */
.ai-cursor-typing::after {
    content: '|';
    color: var(--ai-primary-color);
    animation: cursor-blink 1s infinite;
    font-weight: 100;
    margin-left: 1px;
}

@keyframes cursor-blink {
    0%, 50% { 
        opacity: 1; 
    }
    51%, 100% { 
        opacity: 0; 
    }
}

/* Typing effect styling */
.ai-typing-effect {
    position: relative;
}

/* Smooth text reveal during typing */
.ai-message-content {
    transition: none;
}

.ai-typing-effect {
    transition: none;
}

/* ============================================
   Pending Queries / Service Unavailable Form
   ============================================ */

.ai-service-unavailable {
    background: #fff;
    border: 1px solid #dcdcde;
    border-left: 4px solid #d63638;
    border-radius: 4px;
    margin: 16px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-unavailable-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f1;
}

.ai-unavailable-header .dashicons {
    color: #d63638;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.ai-unavailable-header strong {
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
}

.ai-unavailable-message {
    margin-bottom: 16px;
}

.ai-unavailable-message p {
    margin: 0;
    color: #50575e;
    font-size: 14px;
    line-height: 1.5;
}

/* Action Buttons */
.ai-unavailable-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.ai-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    border: 1px solid;
}

.ai-email-button {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.ai-email-button:hover {
    background: #135e96;
    border-color: #135e96;
}

.ai-email-button .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.ai-retry-button {
    background: #fff;
    color: #2271b1;
    border-color: #2271b1;
}

.ai-retry-button:hover {
    background: #f6f7f7;
    border-color: #135e96;
    color: #135e96;
}

.ai-retry-button .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Email Form Container */
.ai-email-form-container {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #dcdcde;
}

/* Form Styles */
.ai-pending-query-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-form-row label {
    font-size: 13px;
    font-weight: 500;
    color: #1d2327;
}

.ai-form-row .required {
    color: #d63638;
}

.ai-form-row .optional {
    font-weight: 400;
    color: #646970;
}

.ai-form-row input[type="email"],
.ai-form-row input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.4;
    color: #2c3338;
    background: #fff;
    transition: border-color 0.2s ease;
}

.ai-form-row input[type="email"]:focus,
.ai-form-row input[type="text"]:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.ai-form-row input[type="email"]::placeholder,
.ai-form-row input[type="text"]::placeholder {
    color: #a7aaad;
}

.ai-submit-pending {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #2271b1;
    color: #fff;
    border: 1px solid #2271b1;
    border-radius: 4px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.ai-submit-pending:hover {
    background: #135e96;
    border-color: #135e96;
}

.ai-submit-pending:active {
    background: #0a4b78;
    border-color: #0a4b78;
}

.ai-submit-pending .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Form Actions */
.ai-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.ai-cancel-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #50575e;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
}

.ai-cancel-button:hover {
    background: #f6f7f7;
    border-color: #646970;
    color: #1d2327;
}

.ai-submit-pending {
    flex: 2;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-service-unavailable {
        margin: 12px;
        padding: 12px;
    }

    .ai-action-button {
        padding: 10px 12px;
        font-size: 13px;
    }

    .ai-submit-pending,
    .ai-cancel-button {
        padding: 8px 12px;
        font-size: 13px;
    }

    .ai-form-actions {
        flex-direction: column;
    }

    .ai-submit-pending,
    .ai-cancel-button {
        flex: 1;
    }
}

/* Accessibility improvements */
.ai-form-row input[type="email"]:invalid:not(:placeholder-shown),
.ai-form-row input[type="text"]:invalid:not(:placeholder-shown) {
    border-color: #d63638;
}

.ai-form-row input[type="email"]:invalid:not(:placeholder-shown):focus,
.ai-form-row input[type="text"]:invalid:not(:placeholder-shown):focus {
    box-shadow: 0 0 0 1px #d63638;
}

/* Success state after submission */
.ai-service-unavailable.ai-submitted {
    border-left-color: #00a32a;
}

.ai-service-unavailable.ai-submitted .ai-unavailable-header .dashicons {
    color: #00a32a;
}

/* Loading state for submit button */
.ai-submit-pending.ai-loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.ai-submit-pending.ai-loading .dashicons {
    animation: spin 1s linear infinite;
}

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

/* Pending Query Success Message */
.ai-pending-success {
    background: #fff;
    border: 1px solid #dcdcde;
    border-left: 4px solid #00a32a;
    border-radius: 4px;
    padding: 16px;
    margin: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.ai-success-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f1;
}

.ai-success-header .dashicons {
    color: #00a32a;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.ai-success-header strong {
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
}

.ai-pending-success p {
    margin: 8px 0;
    color: #50575e;
    font-size: 14px;
    line-height: 1.5;
}

.ai-pending-success .ai-reference {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f1;
    color: #646970;
    font-size: 13px;
    font-family: monospace;
}