/**
 * SwanChat - Frontend Styles
 * Version: 1.0.0
 * Modern, accessible, GDPR-compliant chat interface
 */

/* Root container */
#swan-chat-root {
    position: fixed;
    z-index: var(--swan-z, 999999);
    font-family: var(--swan-font, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
    font-size: var(--swan-font-size, 15px);
}

/* Launcher button */
.swan-launcher {
    width: var(--swan-launcher, 64px);
    height: var(--swan-launcher, 64px);
    background: linear-gradient(135deg, var(--swan-primary, #FF8C42), var(--swan-secondary, #FF6B00));
    border: none;
    border-radius: 50%;
    box-shadow: 0 8px 30px rgba(255, 107, 66, 0.45);
    cursor: pointer;
    color: white;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    outline: none;
}

.swan-launcher:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(255, 107, 66, 0.6);
}

.swan-launcher:focus {
    outline: 3px solid var(--swan-primary, #FF8C42);
    outline-offset: 3px;
}

.swan-launcher:active {
    transform: translateY(-2px);
}

/* Chat window */
.swan-chat-window {
    display: none;
    flex-direction: column;
    width: var(--swan-width, 400px);
    height: var(--swan-height, 640px);
    max-width: calc(100vw - 48px);
    max-height: 85vh;
    background: var(--swan-bg, #0f172a);
    border-radius: var(--swan-radius, 24px);
    overflow: hidden;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 140, 66, 0.15);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.swan-chat-window.swan-open {
    opacity: 1;
    transform: translateY(0);
}

/* Cookie notice */
.swan-cookie-notice {
    background: rgba(255, 140, 66, 0.1);
    padding: 10px 16px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 140, 66, 0.2);
}

.swan-cookie-text {
    flex: 1;
    line-height: 1.4;
}

.swan-cookie-text a {
    color: var(--swan-primary, #FF8C42);
    text-decoration: underline;
}

.swan-cookie-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.swan-cookie-close:hover {
    background: rgba(255, 140, 66, 0.2);
    color: var(--swan-primary, #FF8C42);
}

/* Consent overlay */
.swan-consent-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.swan-consent-content {
    background: var(--swan-header, #1e293b);
    padding: 32px;
    border-radius: 16px;
    max-width: 90%;
    text-align: center;
    border: 1px solid rgba(255, 140, 66, 0.2);
}

.swan-consent-content h3 {
    margin: 0 0 20px;
    color: white;
    font-size: 20px;
    font-weight: 600;
}

.swan-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    margin-bottom: 16px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.5;
}

.swan-consent-label input[type="checkbox"] {
    margin-top: 2px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.swan-consent-content a {
    color: var(--swan-primary, #FF8C42);
    text-decoration: none;
    font-size: 13px;
    display: inline-block;
    margin-bottom: 20px;
}

.swan-consent-content a:hover {
    text-decoration: underline;
}

.swan-consent-button {
    background: linear-gradient(135deg, var(--swan-primary, #FF8C42), var(--swan-secondary, #FF6B00));
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.swan-consent-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.swan-consent-button:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(255, 107, 66, 0.5);
}

/* Header */
.swan-header {
    background: linear-gradient(135deg, var(--swan-header, #1e293b), var(--swan-bg, #0f172a));
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 140, 66, 0.2);
    flex-shrink: 0;
}

.swan-header-title {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

.swan-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.swan-header-btn,
.swan-close-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    padding: 0;
}

.swan-header-btn:hover,
.swan-close-btn:hover {
    background: rgba(255, 107, 66, 0.15);
    color: var(--swan-primary, #FF8C42);
}

.swan-close-btn {
    font-size: 28px;
    line-height: 1;
}

/* Messages container */
.swan-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--swan-bg, #0f172a);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

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

.swan-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 140, 66, 0.3);
    border-radius: 3px;
}

.swan-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 140, 66, 0.5);
}

/* Message bubble */
.swan-msg {
    max-width: 82%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: slideIn 0.3s ease-out;
}

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

.swan-msg-user {
    align-self: flex-end;
    align-items: flex-end;
}

.swan-msg-bot {
    align-self: flex-start;
    align-items: flex-start;
}

.swan-msg-content {
    padding: 14px 20px;
    border-radius: 20px;
    line-height: 1.5;
    word-wrap: break-word;
    word-break: break-word;
}

.swan-msg-user .swan-msg-content {
    background: var(--swan-user-bubble, linear-gradient(135deg, #FF8C42, #FF6B00));
    color: white;
    border-bottom-right-radius: 6px;
}

.swan-msg-bot .swan-msg-content {
    background: var(--swan-bot-bubble, #1e293b);
    color: #e2e8f0;
    border: 1px solid #334155;
    border-bottom-left-radius: 6px;
}

.swan-msg-time {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    padding: 0 8px;
}

/* Typing indicator */
.swan-typing .swan-msg-content {
    padding: 16px 20px;
}

.swan-typing-dots {
    display: flex;
    gap: 6px;
    align-items: center;
}

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

.swan-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input area */
.swan-input-area {
    padding: 20px 24px;
    background: var(--swan-bg, #0f172a);
    border-top: 1px solid #334155;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.swan-input {
    flex: 1;
    padding: 14px 20px;
    background: var(--swan-header, #1e293b);
    border: 1px solid #334155;
    border-radius: 24px;
    color: white;
    font-size: var(--swan-font-size, 15px);
    font-family: inherit;
    outline: none;
    transition: all 0.3s;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
}

.swan-input:focus {
    border-color: var(--swan-primary, #FF8C42);
    box-shadow: 0 0 0 4px rgba(255, 140, 66, 0.15);
}

.swan-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.swan-send-btn {
    background: linear-gradient(135deg, var(--swan-primary, #FF8C42), var(--swan-secondary, #FF6B00));
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    flex-shrink: 0;
    padding: 0;
}

.swan-send-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(255, 107, 66, 0.5);
}

.swan-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.swan-send-btn:focus {
    outline: 3px solid var(--swan-primary, #FF8C42);
    outline-offset: 3px;
}

/* Input hint */
.swan-input-hint {
    padding: 8px 24px 12px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    background: var(--swan-bg, #0f172a);
    border-top: 1px solid rgba(255, 140, 66, 0.1);
}

/* Responsive design */
@media (max-width: 768px) {
    .swan-chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
    }
    
    .swan-msg {
        max-width: 85%;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .swan-chat-window {
        border: 2px solid var(--swan-primary, #FF8C42);
    }
    
    .swan-msg-content {
        border-width: 2px;
    }
    
    .swan-input:focus {
        outline: 3px solid var(--swan-primary, #FF8C42);
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .swan-launcher,
    .swan-chat-window,
    .swan-msg,
    .swan-send-btn,
    .swan-consent-button {
        animation: none;
        transition: none;
    }
}

/* Dark mode support (if system preference) */
@media (prefers-color-scheme: dark) {
    /* Already optimized for dark mode */
}

/* Print styles */
@media print {
    #swan-chat-root {
        display: none !important;
    }
}

/* Focus visible for keyboard navigation */
.swan-launcher:focus-visible,
.swan-send-btn:focus-visible,
.swan-close-btn:focus-visible,
.swan-header-btn:focus-visible,
.swan-consent-button:focus-visible {
    outline: 3px solid var(--swan-primary, #FF8C42);
    outline-offset: 3px;
}

/* Screen reader only content */
.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;
}
