/**
 * MaatwerkWeb Chat Widget Styles
 * Responsive design with MaatwerkWeb logo
 * 
 * @version 1.0.0
 */

:root {
    --mww-primary-color: #00429D;
    --mww-secondary-color: #0E85DF;
    --mww-text-color: #333333;
    --mww-light-gray: #f5f5f5;
    --mww-border-color: #e0e0e0;
    --mww-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --mww-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --mww-white: #ffffff;
    --mww-success: #28a745;
    --mww-error: #dc3545;
    --mww-warning: #ffc107;
}

/* ===================================
   Chat Bubble
   =================================== */

.mww-chat-bubble {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mww-primary-color);
    box-shadow: var(--mww-shadow);
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mww-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: var(--mww-shadow-lg);
}

.mww-chat-bubble.mww-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.mww-bubble-icon {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mww-bubble-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.mww-bubble-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--mww-error);
    color: var(--mww-white);
    border-radius: 50%;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ===================================
   Chat Window
   =================================== */

.mww-chat-window {
    position: fixed;
    width: 380px;
    height: 600px;
    background: var(--mww-white);
    border-radius: 12px;
    box-shadow: var(--mww-shadow-lg);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    animation: mww-slide-up 0.3s ease;
}

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

/* ===================================
   Header
   =================================== */

.mww-chat-header {
    background: var(--mww-primary-color);
    color: var(--mww-white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mww-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.mww-header-icon {
    width: 40px;
    height: 40px;
    background: var(--mww-secondary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mww-header-icon svg {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.mww-header-title {
    display: flex;
    flex-direction: column;
}

.mww-header-name {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

.mww-header-status {
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.3;
}

.mww-close-btn {
    background: transparent;
    border: none;
    color: var(--mww-white);
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mww-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ===================================
   Content Area
   =================================== */

.mww-chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===================================
   Start Form
   =================================== */

.mww-start-form {
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mww-start-form h3 {
    margin: 0;
    font-size: 24px;
    color: var(--mww-text-color);
    font-weight: 600;
}

.mww-start-form p {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.5;
}

.mww-form-group {
    display: flex;
    flex-direction: column;
}

.mww-form-group input {
    padding: 12px 16px;
    border: 2px solid var(--mww-border-color);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.mww-form-group input:focus {
    outline: none;
    border-color: var(--mww-primary-color);
}

.mww-form-error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.4;
}

.mww-start-btn {
    background: var(--mww-primary-color);
    color: var(--mww-white);
    border: none;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.mww-start-btn:hover {
    background: var(--mww-secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 66, 157, 0.3);
}

.mww-start-btn:active {
    transform: translateY(0);
}

/* ===================================
   Messages Container
   =================================== */

.mww-messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafafa;
}

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

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

.mww-messages-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.mww-messages-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ===================================
   Messages
   =================================== */

.mww-message {
    display: flex;
    animation: mww-fade-in 0.3s ease;
}

@keyframes mww-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mww-message-customer {
    justify-content: flex-end;
}

.mww-message-staff,
.mww-message-system {
    justify-content: flex-start;
}

.mww-message-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mww-message-sender {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    padding: 0 4px;
}

.mww-message-text {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.mww-message-customer .mww-message-text {
    background: var(--mww-primary-color);
    color: var(--mww-white);
    border-bottom-right-radius: 4px;
}

.mww-message-staff .mww-message-text {
    background: var(--mww-white);
    color: var(--mww-text-color);
    border: 1px solid var(--mww-border-color);
    border-bottom-left-radius: 4px;
}

.mww-message-system .mww-message-text {
    background: var(--mww-light-gray);
    color: #666;
    font-style: italic;
    border-radius: 12px;
    text-align: center;
    max-width: 100%;
}

.mww-message-time {
    font-size: 11px;
    color: #999;
    padding: 0 4px;
}

.mww-message-customer .mww-message-time {
    text-align: right;
}

/* ===================================
   Footer / Input Area
   =================================== */

.mww-chat-footer {
    padding: 16px;
    background: var(--mww-white);
    border-top: 1px solid var(--mww-border-color);
}

.mww-input-container {
    position: relative;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.mww-input-container textarea {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--mww-border-color);
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.mww-input-container textarea:focus {
    outline: none;
    border-color: var(--mww-primary-color);
}

.mww-input-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.mww-attach-btn,
.mww-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mww-attach-btn {
    background: transparent;
    color: #666;
}

.mww-attach-btn:hover {
    background: var(--mww-light-gray);
    color: var(--mww-primary-color);
}

.mww-send-btn {
    background: var(--mww-primary-color);
    color: var(--mww-white);
}

.mww-send-btn:hover {
    background: var(--mww-secondary-color);
    transform: scale(1.05);
}

.mww-send-btn:active {
    transform: scale(0.95);
}

.mww-char-count {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 4px;
}

/* ===================================
   Mobile Responsiveness
   =================================== */

@media (max-width: 768px) {
    .mww-chat-bubble {
        width: 56px;
        height: 56px;
    }
    
    .mww-bubble-icon {
        width: 32px;
        height: 32px;
    }

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

    .mww-message-content {
        max-width: 85%;
    }

    .mww-start-form {
        padding: 24px 20px;
    }
}

@media (max-width: 480px) {
    .mww-chat-header {
        padding: 14px 16px;
    }

    .mww-header-icon {
        width: 36px;
        height: 36px;
    }

    .mww-header-name {
        font-size: 15px;
    }

    .mww-header-status {
        font-size: 12px;
    }

    .mww-messages-container {
        padding: 16px 12px;
    }

    .mww-chat-footer {
        padding: 12px;
    }
}

/* ===================================
   Dark Theme Support (Optional)
   =================================== */

@media (prefers-color-scheme: dark) {
    .mww-chat-window[data-theme="auto"] {
        background: #1e1e1e;
        color: #ffffff;
    }

    .mww-chat-window[data-theme="auto"] .mww-messages-container {
        background: #252525;
    }

    .mww-chat-window[data-theme="auto"] .mww-message-staff .mww-message-text {
        background: #2d2d2d;
        color: #ffffff;
        border-color: #404040;
    }

    .mww-chat-window[data-theme="auto"] .mww-form-group input,
    .mww-chat-window[data-theme="auto"] .mww-input-container textarea {
        background: #2d2d2d;
        color: #ffffff;
        border-color: #404040;
    }

    .mww-chat-window[data-theme="auto"] .mww-chat-footer {
        background: #1e1e1e;
        border-color: #404040;
    }

    .mww-chat-window[data-theme="auto"] .mww-start-form h3 {
        color: #ffffff;
    }

    .mww-chat-window[data-theme="auto"] .mww-start-form p {
        color: #cccccc;
    }
}

/* ===================================
   Animations & Transitions
   =================================== */

@keyframes mww-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.mww-bubble-badge {
    animation: mww-pulse 2s infinite;
}

/* ===================================
   Loading States
   =================================== */

.mww-message.is-sending .mww-message-text {
    opacity: 0.7;
}

.mww-message.is-sending .mww-message-text::after {
    content: '...';
    animation: mww-dots 1.4s infinite;
}

@keyframes mww-dots {
    0%, 20% {
        content: '.';
    }
    40% {
        content: '..';
    }
    60%, 100% {
        content: '...';
    }
}

/* ===================================
   Accessibility
   =================================== */

.mww-chat-bubble:focus,
.mww-close-btn:focus,
.mww-start-btn:focus,
.mww-send-btn:focus,
.mww-attach-btn:focus {
    outline: 2px solid var(--mww-primary-color);
    outline-offset: 2px;
}

.mww-form-group input:focus,
.mww-input-container textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 66, 157, 0.1);
}

/* ===================================
   Print Styles
   =================================== */

@media print {
    .mww-chat-bubble,
    .mww-chat-window {
        display: none !important;
    }
}
