/**
 * Legal Chat AI - Widget Styles
 *
 * Professional, accessible, and responsive chat widget design
 * optimized for law firm websites.
 *
 * Features:
 * - CSS Variables for easy customization
 * - Mobile-first responsive design
 * - WCAG 2.1 AA accessibility compliance
 * - Smooth animations
 * - Print-friendly styles
 *
 * @package Legal_Chat_AI
 * @since   1.0.0
 */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
    /* Primary colors (can be overridden via PHP) */
    --legal-chat-primary: #0073aa;
    --legal-chat-primary-hover: #005a87;
    --legal-chat-secondary: #f0f0f1;
    --legal-chat-text: #ffffff;

    /* Dimensions */
    --legal-chat-max-height: 600px;
    --legal-chat-max-width: 400px;

    /* Extended color palette */
    --legal-chat-bg: #ffffff;
    --legal-chat-border: #e0e0e0;
    --legal-chat-text-dark: #1a1a1a;
    --legal-chat-text-muted: #6b7280;
    --legal-chat-assistant-bubble: #f3f4f6;
    --legal-chat-error-bg: #fee;
    --legal-chat-error-text: #c00;
    --legal-chat-success-bg: #d4edda;
    --legal-chat-success-text: #155724;

    /* Shadows */
    --legal-chat-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --legal-chat-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --legal-chat-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);

    /* Transitions */
    --legal-chat-transition: 0.3s ease;

    /* Z-index */
    --legal-chat-z-index: 999999;

    /* Border radius */
    --legal-chat-radius: 12px;
    --legal-chat-radius-sm: 8px;

    /* Spacing */
    --legal-chat-spacing: 16px;
}

/* ============================================
   BASE STYLES
   ============================================ */

.legal-chat-widget-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--legal-chat-text-dark);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ============================================
   TRIGGER BUTTON (Floating)
   ============================================ */

.legal-chat-trigger {
    position: fixed;
    bottom: 20px;
    z-index: var(--legal-chat-z-index);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-width: 48px;
    height: 48px;
    padding: 0 14px;
    background: var(--legal-chat-primary);
    color: var(--legal-chat-text);
    border: none;
    border-radius: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all var(--legal-chat-transition);
    font-size: 14px;
    font-weight: 500;
}

.legal-chat-position-bottom-right .legal-chat-trigger {
    right: 20px;
}

.legal-chat-position-bottom-left .legal-chat-trigger {
    left: 20px;
}

.legal-chat-trigger:hover,
.legal-chat-trigger:focus {
    background: var(--legal-chat-primary-hover);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    transform: scale(1.03);
}

.legal-chat-trigger:focus {
    outline: none;
}

.legal-chat-trigger:active {
    transform: scale(0.95);
}

.legal-chat-trigger svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
}

.legal-chat-trigger-text {
    display: none;
}

/* Show label on mobile when setting enabled */
@media (max-width: 767px) {
    body.legal-chat-mobile-show-label .legal-chat-trigger-text {
        display: inline;
    }
}

@media (min-width: 768px) {
    .legal-chat-trigger-text {
        display: inline;
    }
}

/* ============================================
   CHAT WIDGET
   ============================================ */

.legal-chat-widget {
    position: fixed;
    bottom: 90px;
    z-index: var(--legal-chat-z-index);
    display: none;
    flex-direction: column;
    width: 90vw;
    max-width: var(--legal-chat-max-width);
    height: 70vh;
    max-height: var(--legal-chat-max-height);
    background: var(--legal-chat-bg);
    border-radius: var(--legal-chat-radius);
    box-shadow: var(--legal-chat-shadow-lg);
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

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

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

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

/* Embedded widget */
.legal-chat-widget-embedded {
    position: relative;
    bottom: auto;
    right: auto;
    left: auto;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

/* ============================================
   HEADER
   ============================================ */

.legal-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--legal-chat-spacing);
    background: var(--legal-chat-primary);
    color: #ffffff !important; /* Ensure white text on blue background */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.legal-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.legal-chat-avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legal-chat-title-wrapper {
    flex: 1;
    min-width: 0;
}

.legal-chat-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    color: #ffffff !important; /* Ensure white text on blue background */
    text-overflow: ellipsis;
}

.legal-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
    color: #ffffff !important; /* Ensure white text on blue background */
}

.legal-chat-status-indicator {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.legal-chat-header-actions {
    display: flex;
    gap: 8px;
}

.legal-chat-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    color: var(--legal-chat-text);
    border: none;
    border-radius: var(--legal-chat-radius-sm);
    cursor: pointer;
    transition: background var(--legal-chat-transition);
}

.legal-chat-action-btn:hover,
.legal-chat-action-btn:focus {
    background: rgba(255, 255, 255, 0.2);
}

.legal-chat-action-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.legal-chat-messages {
    flex: 1;
    padding: var(--legal-chat-spacing);
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    background: var(--legal-chat-bg);
}

.legal-chat-messages:focus {
    outline: 2px solid var(--legal-chat-primary);
    outline-offset: -2px;
}

/* Custom scrollbar */
.legal-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.legal-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.legal-chat-messages::-webkit-scrollbar-thumb {
    background: var(--legal-chat-border);
    border-radius: 3px;
}

.legal-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--legal-chat-text-muted);
}

/* ============================================
   INDIVIDUAL MESSAGES
   ============================================ */

.legal-chat-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    margin-bottom: 16px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.legal-chat-message--user {
    align-self: flex-end;
    margin-left: auto;
}

.legal-chat-message--assistant {
    align-self: flex-start;
}

.legal-chat-message-content {
    padding: 12px 16px;
    border-radius: var(--legal-chat-radius);
    line-height: 1.6;
}

.legal-chat-message--user .legal-chat-message-content {
    background: var(--legal-chat-primary);
    color: var(--legal-chat-text);
    border-bottom-right-radius: 4px;
}

.legal-chat-message--assistant .legal-chat-message-content {
    background: var(--legal-chat-assistant-bubble);
    color: var(--legal-chat-text-dark);
    border-bottom-left-radius: 4px;
}

/* Markdown formatting in assistant messages */
.legal-chat-message--assistant .legal-chat-message-content p {
    margin: 0 0 8px 0;
}

.legal-chat-message--assistant .legal-chat-message-content p:last-child {
    margin-bottom: 0;
}

/* Style the disclaimer text (wrapped in <em> by markdown) */
.legal-chat-message--assistant .legal-chat-message-content em {
    font-style: italic;
    color: #6b7280;
    font-size: 0.9em;
}

.legal-chat-message--assistant .legal-chat-message-content ul,
.legal-chat-message--assistant .legal-chat-message-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.legal-chat-message--assistant .legal-chat-message-content li {
    margin: 4px 0;
}

.legal-chat-message--assistant .legal-chat-message-content code {
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
    font-size: 0.9em;
    font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
}

.legal-chat-message--assistant .legal-chat-message-content pre {
    margin: 8px 0;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--legal-chat-radius-sm);
    overflow-x: auto;
}

.legal-chat-message--assistant .legal-chat-message-content pre code {
    padding: 0;
    background: transparent;
}

.legal-chat-message--assistant .legal-chat-message-content a {
    color: var(--legal-chat-primary);
    text-decoration: underline;
}

.legal-chat-message--assistant .legal-chat-message-content a:hover {
    color: var(--legal-chat-primary-hover);
}

.legal-chat-message--assistant .legal-chat-message-content strong {
    font-weight: 600;
}

/* Message timestamp */
.legal-chat-message-time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--legal-chat-text-muted);
    opacity: 0.8;
}

.legal-chat-message--user .legal-chat-message-time {
    text-align: right;
}

/* ============================================
   SOURCE CITATIONS
   ============================================ */

.legal-chat-sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.legal-chat-message--user .legal-chat-sources {
    border-top-color: rgba(255, 255, 255, 0.3);
}

.legal-chat-sources-heading {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--legal-chat-text-muted);
}

.legal-chat-message--user .legal-chat-sources-heading {
    color: rgba(255, 255, 255, 0.9);
}

.legal-chat-sources-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.legal-chat-sources-list li {
    margin: 6px 0;
    font-size: 12px;
}

.legal-chat-sources-list a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: inherit;
    text-decoration: underline;
    transition: opacity var(--legal-chat-transition);
}

.legal-chat-sources-list a:hover,
.legal-chat-sources-list a:focus {
    opacity: 0.7;
}

.legal-chat-sources-list a svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.legal-chat-source-score {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.7;
}

.legal-chat-citation-number {
    display: inline;
    margin-right: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--legal-chat-primary);
    vertical-align: top;
    line-height: 1.2;
}

.legal-chat-source-cited {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 600;
    color: white;
    background: var(--legal-chat-primary);
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Inline citations in message content */
.legal-chat-inline-citation {
    display: inline;
    font-size: 0.75em !important;
    font-weight: 400 !important;
    color: #94a3b8 !important;
    opacity: 0.8 !important;
    margin: 0 2px;
    padding: 0;
    vertical-align: baseline !important;
    line-height: inherit !important;
    cursor: help;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.legal-chat-inline-citation:hover {
    opacity: 1 !important;
    color: var(--legal-chat-primary) !important;
}

/* Hidden sources container */
.legal-chat-hidden-sources {
    margin: 0;
    padding: 0;
}

/* Show more sources button */
.legal-chat-show-more-sources {
    display: inline-block;
    margin: 8px 0 0 0;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--legal-chat-primary);
    background: transparent;
    border: 1px solid var(--legal-chat-primary);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--legal-chat-transition);
    font-family: inherit;
}

.legal-chat-show-more-sources:hover {
    background: var(--legal-chat-primary);
    color: white;
}

.legal-chat-show-more-sources:focus {
    outline: 2px solid var(--legal-chat-primary);
    outline-offset: 2px;
}

.legal-chat-message--user .legal-chat-show-more-sources {
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.5);
}

.legal-chat-message--user .legal-chat-show-more-sources:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.9);
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.legal-chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    padding: 12px 16px;
    background: var(--legal-chat-assistant-bubble);
    border-radius: var(--legal-chat-radius);
    border-bottom-left-radius: 4px;
}

.legal-chat-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--legal-chat-text-muted);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.legal-chat-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.legal-chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.legal-chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ============================================
   ERROR MESSAGES
   ============================================ */

.legal-chat-error {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--legal-chat-error-bg);
    color: var(--legal-chat-error-text);
    border-radius: var(--legal-chat-radius);
    border-left: 4px solid var(--legal-chat-error-text);
    font-size: 13px;
    line-height: 1.5;
}

.legal-chat-error svg {
    flex-shrink: 0;
}

/* Context optimization notification */
.legal-chat-context-notification {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    background: #e8f4fd;
    color: #0066cc;
    border-radius: var(--legal-chat-radius);
    border-left: 4px solid #0066cc;
    font-size: 12px;
    line-height: 1.5;
    opacity: 1;
}

.legal-chat-context-notification svg {
    flex-shrink: 0;
    color: #0066cc;
}

/* ============================================
   INPUT AREA
   ============================================ */

.legal-chat-input-area {
    border-top: 1px solid var(--legal-chat-border);
    background: var(--legal-chat-bg);
}

.legal-chat-disclaimer {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px var(--legal-chat-spacing);
    background: #fffbf0;
    border-bottom: 1px solid var(--legal-chat-border);
    font-size: 11px;
    line-height: 1.4;
    color: var(--legal-chat-text-muted);
}

.legal-chat-disclaimer svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: #f59e0b;
}

.legal-chat-input-wrapper {
    padding: 12px var(--legal-chat-spacing);
}

.legal-chat-input {
    width: 100%;
    min-height: 44px;
    max-height: 150px;
    padding: 12px;
    border: 1px solid var(--legal-chat-border);
    border-radius: var(--legal-chat-radius-sm);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--legal-chat-text-dark);
    resize: none;
    transition: border-color var(--legal-chat-transition);
}

.legal-chat-input:focus {
    outline: none;
    border-color: var(--legal-chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.legal-chat-input::placeholder {
    color: #4a5568;
    opacity: 1;
}

.legal-chat-input:disabled {
    background: var(--legal-chat-secondary);
    cursor: not-allowed;
    opacity: 0.6;
}

.legal-chat-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.legal-chat-char-count {
    font-size: 11px;
    color: var(--legal-chat-text-muted);
}

.legal-chat-char-count-warning {
    color: #dc2626;
    font-weight: 600;
}

/* Quick Action Icons */
.legal-chat-quick-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legal-chat-quick-action {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: var(--legal-chat-radius-sm);
    cursor: pointer;
    transition: all var(--legal-chat-transition);
}

.legal-chat-quick-action:hover {
    background: rgba(0, 115, 170, 0.1);
    color: var(--legal-chat-primary);
    border-color: var(--legal-chat-primary);
}

.legal-chat-quick-action:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.legal-chat-quick-action svg {
    width: 16px;
    height: 16px;
}

.legal-chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--legal-chat-primary);
    color: var(--legal-chat-text);
    border: none;
    border-radius: var(--legal-chat-radius-sm);
    cursor: pointer;
    transition: all var(--legal-chat-transition);
}

.legal-chat-send-btn:hover:not(:disabled) {
    background: var(--legal-chat-primary-hover);
    transform: scale(1.05);
}

.legal-chat-send-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2);
}

.legal-chat-send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.legal-chat-send-btn:disabled {
    background: var(--legal-chat-text-muted);
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Mobile devices */
@media (max-width: 767px) {
    .legal-chat-trigger {
        right: 15px;
        bottom: 15px;
        min-width: 44px;
        height: 32px;
        padding: 6px 10px;
        gap: 4px;
        font-size: 12px;
        line-height: 1;
    }

    .legal-chat-trigger svg {
        width: 14px;
        height: 14px;
    }

    .legal-chat-position-bottom-left .legal-chat-trigger {
        left: 15px;
    }

    .legal-chat-widget {
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .legal-chat-header {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-bottom: 12px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .legal-chat-messages {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .legal-chat-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .legal-chat-message {
        max-width: 90%;
    }
}

/* Tablet and up */
@media (min-width: 768px) {
    .legal-chat-widget {
        width: 400px;
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 20px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

/* Focus visible for keyboard navigation */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .legal-chat-trigger,
    .legal-chat-send-btn {
        border: 2px solid currentColor;
    }

    .legal-chat-input:focus {
        outline: 2px solid currentColor;
        outline-offset: 2px;
    }
}

/* Dark mode support - DISABLED to maintain consistent light theme */
/*
@media (prefers-color-scheme: dark) {
    :root {
        --legal-chat-bg: #1f2937;
        --legal-chat-border: #374151;
        --legal-chat-text-dark: #f3f4f6;
        --legal-chat-text-muted: #9ca3af;
        --legal-chat-assistant-bubble: #374151;
    }

    .legal-chat-disclaimer {
        background: #374151;
    }

    .legal-chat-input {
        background: #374151;
        color: #f3f4f6;
    }
}
*/

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .legal-chat-widget-container {
        display: none !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.legal-chat-hidden {
    display: none !important;
}

.legal-chat-fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.legal-chat-slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* ============================================
   Consent Disclaimer Styles
   ============================================ */

.legal-chat-consent {
    margin: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, var(--legal-chat-gradient-start, #667eea) 0%, var(--legal-chat-gradient-end, #764ba2) 100%);
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease-out;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
}

.legal-chat-consent-content {
    color: white;
}

.legal-chat-consent h4 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
}

.legal-chat-consent p {
    margin: 0 0 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
}

.legal-chat-consent-notice {
    font-size: 0.85rem !important;
    color: rgba(255, 255, 255, 0.8) !important;
    font-style: italic;
}

.legal-chat-consent-button {
    margin-top: 1rem;
    padding: 0.75rem 2rem;
    background: white;
    color: var(--legal-chat-primary, #667eea);
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.legal-chat-consent-button:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.legal-chat-consent-button:active {
    transform: translateY(0);
}

/* Style for disclaimer content within consent popup */
.legal-chat-consent .legal-chat-disclaimer {
    display: block;
    width: 100%;
    max-width: 100%;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.legal-chat-consent .legal-chat-disclaimer h4 {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.legal-chat-consent .legal-chat-disclaimer p {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.legal-chat-consent .legal-chat-disclaimer ul {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0.5rem 0;
    padding-left: 1.5rem;
    list-style-type: disc;
    list-style-position: outside;
    box-sizing: border-box;
}

.legal-chat-consent .legal-chat-disclaimer li {
    display: list-item;
    margin: 0.4rem 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.95);
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.legal-chat-consent .legal-chat-disclaimer strong {
    font-weight: 600;
    color: white;
}

/* Follow-up Messages */
.legal-chat-message-followup {
    opacity: 0.95;
}

.legal-chat-message-followup .legal-chat-message-content {
    background-color: rgba(var(--legal-chat-primary-rgb), 0.05);
    border-left: 3px solid var(--legal-chat-primary);
    padding: 0.75rem;
    border-radius: 8px;
}

.legal-chat-followup-text {
    margin: 0 0 0.75rem 0;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--legal-chat-text-secondary, #4a5568);
}

/* Contact Actions in Follow-up */
.legal-chat-contact-actions {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.75rem;
}

.legal-chat-contact-button,
.legal-chat-schedule-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.625rem;
    background-color: var(--legal-chat-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
}

.legal-chat-schedule-button {
    background: linear-gradient(135deg, var(--legal-chat-primary) 0%, var(--legal-chat-primary-hover) 100%);
    font-weight: 700;
}

.legal-chat-contact-button:hover,
.legal-chat-schedule-button:hover {
    background-color: var(--legal-chat-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.legal-chat-schedule-button:hover {
    background: linear-gradient(135deg, var(--legal-chat-primary-hover) 0%, var(--legal-chat-primary) 100%);
}

.legal-chat-contact-button:active,
.legal-chat-schedule-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legal-chat-phone-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: var(--legal-chat-primary);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid var(--legal-chat-primary);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.legal-chat-phone-link:hover {
    background-color: rgba(var(--legal-chat-primary-rgb), 0.05);
    text-decoration: none;
}

.legal-chat-phone-link::before {
    content: "📞";
    margin-right: 0.375rem;
}

.legal-chat-action-separator {
    color: var(--legal-chat-text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-style: italic;
    padding: 0 0.125rem;
    flex-shrink: 0;
}

/* Mobile Responsiveness for Contact Actions */
@media (max-width: 480px) {
    .legal-chat-contact-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .legal-chat-contact-button,
    .legal-chat-schedule-button,
    .legal-chat-phone-link {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}

/* ============================================
   MODAL DIALOG STYLES
   ============================================ */

.legal-chat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    animation: legal-chat-fade-in 0.2s ease;
}

.legal-chat-modal {
    background: var(--legal-chat-bg);
    border-radius: 8px;
    box-shadow: var(--legal-chat-shadow-lg);
    max-width: 440px;
    width: 90%;
    padding: 1.5rem;
    animation: legal-chat-slide-up 0.3s ease;
}

.legal-chat-modal h3 {
    margin: 0 0 1rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--legal-chat-text-dark);
}

.legal-chat-modal-message {
    margin: 0 0 1.5rem 0;
    color: var(--legal-chat-text-muted);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.legal-chat-modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.legal-chat-modal-button {
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: inherit;
}

.legal-chat-modal-button:focus {
    outline: 2px solid var(--legal-chat-primary);
    outline-offset: 2px;
}

.legal-chat-modal-button-primary {
    background-color: var(--legal-chat-primary);
    color: var(--legal-chat-text);
}

.legal-chat-modal-button-primary:hover {
    background-color: var(--legal-chat-primary-hover);
}

.legal-chat-modal-button-secondary {
    background-color: transparent;
    color: var(--legal-chat-text-dark);
    border: 1px solid var(--legal-chat-border);
}

.legal-chat-modal-button-secondary:hover {
    background-color: var(--legal-chat-secondary);
}

@keyframes legal-chat-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes legal-chat-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .legal-chat-modal {
        width: 95%;
        padding: 1.25rem;
    }

    .legal-chat-modal-buttons {
        flex-direction: column-reverse;
    }

    .legal-chat-modal-button {
        width: 100%;
    }
}

/* ============================================
   UX ENHANCEMENTS - CUSTOM SCROLLBAR
   ============================================ */

/* Enhanced custom scrollbar when enabled via settings */
.legal-chat-messages.legal-chat-custom-scrollbar {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 115, 170, 0.4) rgba(0, 0, 0, 0.05);
}

.legal-chat-messages.legal-chat-custom-scrollbar::-webkit-scrollbar {
    width: 10px;
}

.legal-chat-messages.legal-chat-custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 5px;
    margin: 4px 0;
}

.legal-chat-messages.legal-chat-custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 115, 170, 0.4);
    border-radius: 5px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 40px;
}

.legal-chat-messages.legal-chat-custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 115, 170, 0.6);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.legal-chat-messages.legal-chat-custom-scrollbar::-webkit-scrollbar-thumb:active {
    background: var(--legal-chat-primary);
}

/* ============================================
   UX ENHANCEMENTS - MORE BUTTON
   ============================================ */

/* Wrapper for messages area with more button */
.legal-chat-messages-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.legal-chat-messages-wrapper .legal-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.legal-chat-more-button {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(0, 115, 170, 0.95);
    color: #ffffff;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    z-index: 10;
    animation: moreButtonBounce 2s ease-in-out infinite;
}

.legal-chat-more-button:hover {
    background: rgba(0, 115, 170, 1);
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.legal-chat-more-button:active {
    transform: translateX(-50%) scale(0.95);
}

.legal-chat-more-button.visible {
    display: flex;
}

.legal-chat-more-button svg {
    width: 14px;
    height: 14px;
    animation: moreButtonArrow 1.5s ease-in-out infinite;
}

@keyframes moreButtonBounce {
    0%, 100% {
        bottom: 8px;
    }
    50% {
        bottom: 12px;
    }
}

@keyframes moreButtonArrow {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(2px);
    }
}

/* ============================================
   UX ENHANCEMENTS - GRADIENT FADE
   ============================================ */

.legal-chat-messages.has-gradient-fade {
    position: relative;
}

.legal-chat-messages.has-gradient-fade::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(
        to bottom,
        transparent 0%,
        rgba(255, 255, 255, 0.7) 50%,
        rgba(255, 255, 255, 0.95) 100%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
}

.legal-chat-messages.has-gradient-fade.show-gradient::after {
    opacity: 1;
}

/* Dark mode gradient */
@media (prefers-color-scheme: dark) {
    .legal-chat-messages.has-gradient-fade::after {
        background: linear-gradient(
            to bottom,
            transparent 0%,
            rgba(31, 41, 55, 0.7) 50%,
            rgba(31, 41, 55, 0.95) 100%
        );
    }
}
