/**
 * Dansk Live Chat - Modern Styles
 * Version: 1.0.0
 * 
 * A modern, responsive live chat widget with brand colors
 */

:root {
    --dlc-primary: #efc75e;
    --dlc-primary-dark: #d4b347;
    --dlc-secondary: #000000;
    --dlc-text-dark: #1a1a1a;
    --dlc-text-light: #666666;
    --dlc-bg-light: #ffffff;
    --dlc-bg-gray: #f8f9fa;
    --dlc-border: #e0e0e0;
    --dlc-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --dlc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --dlc-radius: 16px;
    --dlc-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
.dlc-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Main Widget Container */
.dlc-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Float Button */
.dlc-float-button {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--dlc-primary) 0%, var(--dlc-primary-dark) 100%);
    border-radius: 50%;
    box-shadow: var(--dlc-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--dlc-transition);
    border: none;
    position: relative;
    overflow: hidden;
}

.dlc-float-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(239, 199, 94, 0.4);
}

.dlc-float-button:active {
    transform: scale(0.95);
}

.dlc-float-button svg {
    width: 32px;
    height: 32px;
    fill: var(--dlc-secondary);
}

.dlc-float-button.dlc-hidden {
    display: none;
}

/* Unread Badge */
.dlc-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Chat Window */
.dlc-chat-window {
    position: fixed;
    bottom: 10px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 20px);
    background: var(--dlc-bg-light);
    border-radius: var(--dlc-radius);
    box-shadow: var(--dlc-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
    transition: var(--dlc-transition);
}

.dlc-chat-window.dlc-active {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* Header */
.dlc-chat-header {
    background: linear-gradient(135deg, var(--dlc-secondary) 0%, #2a2a2a 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--dlc-radius) var(--dlc-radius) 0 0;
}

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

.dlc-chat-avatar {
    width: 40px;
    height: 40px;
    background: var(--dlc-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    color: var(--dlc-secondary);
}

.dlc-chat-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}


.dlc-chat-status {
    font-size: 12px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dlc-status-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: dlc-pulse 2s infinite;
}

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

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

.dlc-btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--dlc-transition);
    color: white;
}

.dlc-btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.dlc-btn-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* Messages Area */
.dlc-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--dlc-bg-gray);
    scroll-behavior: smooth;
}

.dlc-messages-container::-webkit-scrollbar {
    width: 6px;
}

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

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

.dlc-messages-container::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Message */
.dlc-message {
    margin-bottom: 16px;
    animation: dlc-slideUp 0.3s ease;
}

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

.dlc-message-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.dlc-message.dlc-message-visitor .dlc-message-wrapper {
    flex-direction: row-reverse;
}

.dlc-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--dlc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 14px;
    color: var(--dlc-secondary);
}

.dlc-message.dlc-message-visitor .dlc-message-avatar {
    background: #6b7280;
    color: white;
}

.dlc-message-content {
    max-width: 75%;
}

.dlc-message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--dlc-text-dark);
    box-shadow: var(--dlc-shadow-sm);
    word-wrap: break-word;
}

.dlc-message.dlc-message-visitor .dlc-message-bubble {
    background: linear-gradient(135deg, var(--dlc-primary) 0%, var(--dlc-primary-dark) 100%);
    color: var(--dlc-secondary);
    box-shadow: 0 2px 8px rgba(239, 199, 94, 0.3);
}

.dlc-message.dlc-message-system .dlc-message-bubble {
    background: #dbeafe;
    color: #1e40af;
    font-size: 13px;
    text-align: center;
    border: 1px solid #93c5fd;
    font-weight: 500;
}

.dlc-message.dlc-message-system .dlc-message-wrapper {
    justify-content: center;
}

.dlc-message.dlc-message-system .dlc-message-content {
    max-width: 90%;
}

.dlc-message.dlc-message-system .dlc-message-avatar {
    display: none;
}

.dlc-message-time {
    font-size: 11px;
    color: var(--dlc-text-light);
    margin-top: 4px;
    padding: 0 4px;
}

.dlc-message.dlc-message-visitor .dlc-message-time {
    text-align: right;
}

/* Typing Indicator */
.dlc-typing-indicator {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    box-shadow: var(--dlc-shadow-sm);
    max-width: 80px;
}

.dlc-typing-dots {
    display: flex;
    gap: 4px;
}

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

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

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

@keyframes dlc-bounce {
    0%, 80%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.dlc-input-container {
    padding: 10px 10px;
    background: white;
    border-top: 1px solid var(--dlc-border);
}

.dlc-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--dlc-bg-gray);
    border: 2px solid transparent;
    border-radius: 24px;
    padding: 8px 12px 8px 16px;
    transition: var(--dlc-transition);
}

.dlc-input-wrapper:focus-within {
    border-color: var(--dlc-primary);
    background: white;
}

.dlc-input-field {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 14px;
    line-height: 1.5;
    color: var(--dlc-text-dark);
    resize: none;
    max-height: 120px;
    font-family: inherit;
}

.dlc-input-field::placeholder {
    color: var(--dlc-text-light);
}

.dlc-btn-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--dlc-primary) 0%, var(--dlc-primary-dark) 100%);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--dlc-transition);
    flex-shrink: 0;
    color: #ffffff6e;
}

.dlc-btn-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(239, 199, 94, 0.4);
}

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

.dlc-btn-send svg {
    width: 20px;
    height: 20px;
    stroke: var(--dlc-secondary);
    fill: none;
}

/* Quick Actions */
.dlc-quick-actions {
    display: flex;
    gap: 8px;
    margin-top: 0px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.dlc-quick-action {
    background: white;
    border: 1px solid var(--dlc-border);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--dlc-text-dark);
    cursor: pointer;
    transition: var(--dlc-transition);
}

.dlc-quick-action:hover {
    background: var(--dlc-primary);
    color: var(--dlc-secondary);
    border-color: var(--dlc-primary);
}

/* Agent Handover Form */
.dlc-handover-form {
    padding: 20px;
    background: white;
}

.dlc-form-group {
    margin-bottom: 16px;
}

.dlc-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dlc-text-dark);
    margin-bottom: 6px;
}

.dlc-form-input,
.dlc-form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--dlc-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: var(--dlc-transition);
    outline: none;
}

.dlc-form-input:focus,
.dlc-form-textarea:focus {
    border-color: var(--dlc-primary);
}

.dlc-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.dlc-btn-primary {
    width: 100%;
    background: linear-gradient(135deg, var(--dlc-primary) 0%, var(--dlc-primary-dark) 100%);
    color: var(--dlc-secondary);
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dlc-transition);
}

.dlc-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 199, 94, 0.4);
}

.dlc-btn-secondary {
    width: 100%;
    background: white;
    color: var(--dlc-text-dark);
    border: 2px solid var(--dlc-border);
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--dlc-transition);
    margin-top: 8px;
}

.dlc-btn-secondary:hover {
    border-color: var(--dlc-primary);
    color: var(--dlc-primary);
}

/* Footer */
.dlc-chat-footer {
    padding: 12px 20px;
    text-align: center;
    background: var(--dlc-bg-gray);
    border-top: 1px solid var(--dlc-border);
    font-size: 11px;
    color: var(--dlc-text-light);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dlc-chat-availability {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(239, 199, 94, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(239, 199, 94, 0.2);
    font-size: 12px;
    color: var(--dlc-text-dark);
    font-weight: 500;
}

.dlc-availability-icon {
    width: 14px;
    height: 14px;
    stroke: var(--dlc-primary);
    flex-shrink: 0;
}

.dlc-availability-text {
    line-height: 1.4;
}

.dlc-chat-footer-text {
    font-size: 11px;
    color: var(--dlc-text-light);
    display: none;
}

@media (min-height: 200px) and (max-height: 600px) {
    .dlc-quick-actions {
        display: none!important;
    }
    .dlc-chat-header {
        padding: 6px;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .dlc-chat-window {
        width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for better mobile support */
        max-width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
        position: fixed;
    }
    
    /* Prevent body scroll when chat is open on mobile */
    body.dlc-chat-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100vh;
    }
    
    .dlc-chat-header {
        border-radius: 0;
        padding: 16px;
        /* Safe area for notches */
        padding-top: max(16px, env(safe-area-inset-top));
    }
    
    .dlc-chat-window.dlc-keyboard-open {
        /* When keyboard is open, adjust height */
        height: 100vh;
    }
    
    .dlc-messages-container {
        padding: 12px;
        /* Add extra padding at bottom to prevent content from being cut off */
        padding-bottom: 20px;
    }
    
    .dlc-input-container {
        padding: 10px;
        /* Safe area for home indicator */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        background: white;
        /* Ensure input stays visible */
        position: relative;
        z-index: 10;
    }
    
    .dlc-chat-footer {
        padding: 8px 12px;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
    
    .dlc-float-button {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
        /* Safe area for mobile */
        bottom: max(16px, calc(env(safe-area-inset-bottom) + 8px));
        right: max(16px, calc(env(safe-area-inset-right) + 8px));
    }
    
    .dlc-float-button svg {
        width: 28px;
        height: 28px;
    }
    
    /* Larger touch targets on mobile */
    .dlc-btn-icon {
        width: 40px;
        height: 40px;
    }
    
    .dlc-btn-send {
        width: 44px;
        height: 44px;
    }
    
    /* Better message bubbles on mobile */
    .dlc-message-bubble {
        font-size: 15px;
        max-width: 85%;
    }
    
    /* Quick actions better on mobile */
    .dlc-quick-action {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    /* Better form fields on mobile */
    .dlc-form-input,
    .dlc-form-textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 14px;
    }
    
    .dlc-input-field {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    /* Handover form on mobile */
    .dlc-handover-form {
        padding: 16px;
        overflow-y: auto;
        max-height: calc(100vh - 80px);
    }
}

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

/* Print */
@media print {
    .dlc-chat-widget {
        display: none !important;
    }
}

textarea.dlc-input-field:focus {
    background-color: #fff;
}