/**
 * Voting Vault AI Chat Widget Styles
 * Blue Theme with high contrast for readability
 */

:root {
    --voting-primary: #2E86DE;
    --voting-primary-dark: #1E5FA8;
    --voting-primary-light: #5BA3E8;
    --voting-accent: #27AE60;
    --voting-accent-hover: #219A52;
    --voting-white: #FFFFFF;
    --voting-gray-light: #F8F9FA;
    --voting-gray: #E9ECEF;
    --voting-gray-dark: #6C757D;
    --voting-text: #212529;
    --voting-text-light: #495057;
    --voting-shadow: 0 4px 24px rgba(46, 134, 222, 0.25);
    --voting-radius: 16px;
}

/* ============================================
   CHAT TOGGLE BUTTON
   ============================================ */

.voting-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 22px 14px 14px;
    background: linear-gradient(135deg, var(--voting-primary) 0%, var(--voting-primary-dark) 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: var(--voting-shadow);
    transition: all 0.3s ease;
    font-family: inherit;
}

.voting-chat-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(46, 134, 222, 0.4);
}

.voting-chat-toggle:hover .chat-toggle-text {
    max-width: 200px;
    opacity: 1;
    margin-left: 8px;
}

.chat-toggle-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--voting-white);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 24px;
}

.chat-toggle-badge {
    position: absolute;
    top: 8px;
    right: 8px;
}

.pulse-dot {
    display: block;
    width: 12px;
    height: 12px;
    background: var(--voting-accent);
    border-radius: 50%;
    border: 2px solid var(--voting-white);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.chat-toggle-text {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    color: var(--voting-white);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
}

/* ============================================
   CHAT WINDOW
   ============================================ */

.voting-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9999;
    width: 400px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 150px);
    background: var(--voting-white);
    border-radius: var(--voting-radius);
    box-shadow: 0 10px 50px rgba(46, 134, 222, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, var(--voting-primary) 0%, var(--voting-primary-dark) 100%);
    color: var(--voting-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.chat-header-text h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.status-online {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--voting-accent);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.chat-action-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--voting-white);
    transition: background 0.2s;
}

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

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--voting-gray-light);
}

.chat-message {
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

.chat-message.user {
    align-self: flex-end;
}

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

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.chat-message.user .message-bubble {
    background: var(--voting-primary);
    color: var(--voting-white);
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .message-bubble {
    background: var(--voting-white);
    color: var(--voting-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message-bubble a {
    color: inherit;
    text-decoration: underline;
}

.chat-message.assistant .message-bubble a {
    color: var(--voting-primary);
}

.message-time {
    font-size: 11px;
    color: var(--voting-gray-dark);
    margin-top: 4px;
    padding: 0 4px;
}

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

/* Typing Indicator with Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px;
    background: var(--voting-white);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--voting-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Typewriter Effect for Messages */
.typewriter-text {
    overflow: hidden;
    display: inline;
}

.typewriter-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--voting-primary);
    margin-left: 2px;
    animation: blink 0.7s infinite;
    vertical-align: text-bottom;
}

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

/* Chat Input */
.chat-input-container {
    padding: 16px 20px;
    background: var(--voting-white);
    border-top: 1px solid var(--voting-gray);
    flex-shrink: 0;
}

.chat-form {
    margin: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--voting-gray-light);
    border-radius: 24px;
    padding: 8px 8px 8px 20px;
    border: 2px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--voting-primary);
    box-shadow: 0 0 0 3px rgba(46, 134, 222, 0.1);
}

.chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    color: var(--voting-text);
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: var(--voting-gray-dark);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--voting-accent);
    color: var(--voting-white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--voting-accent-hover);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: var(--voting-gray);
    cursor: not-allowed;
    transform: none;
}

.chat-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 11px;
    color: var(--voting-gray-dark);
}

.chat-footer a {
    color: var(--voting-primary);
    text-decoration: none;
}

.chat-footer a:hover {
    text-decoration: underline;
}

.chat-footer .separator {
    opacity: 0.5;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */

.voting-quick-actions {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9997;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.voting-quick-actions.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.quick-action-btn {
    background: var(--voting-white);
    border: 1px solid var(--voting-gray);
    padding: 12px 18px;
    border-radius: 24px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    color: var(--voting-text);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-action-btn:hover {
    background: var(--voting-primary);
    color: var(--voting-white);
    border-color: var(--voting-primary);
    transform: translateX(-8px);
    box-shadow: 0 4px 16px rgba(46, 134, 222, 0.3);
}

.quick-action-btn .icon {
    font-size: 16px;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .voting-chat-toggle {
        bottom: 16px;
        right: 16px;
        padding: 10px;
    }

    .chat-toggle-icon {
        width: 44px;
        height: 44px;
    }

    .chat-toggle-text {
        display: none;
    }

    .voting-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .voting-quick-actions {
        right: 16px;
        bottom: 80px;
    }

    .quick-action-btn {
        font-size: 12px;
        padding: 10px 14px;
    }
}

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

.voting-chat-toggle:focus,
.chat-action-btn:focus,
.chat-send-btn:focus,
.quick-action-btn:focus {
    outline: 2px solid var(--voting-primary);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .voting-chat-toggle,
    .voting-chat-window,
    .chat-message,
    .pulse-dot,
    .typing-indicator span,
    .typewriter-cursor {
        animation: none;
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .chat-message.assistant .message-bubble {
        border: 2px solid var(--voting-text);
    }
    
    .chat-message.user .message-bubble {
        border: 2px solid var(--voting-white);
    }
}

