/* Chatbot Container - Apple/Tesla Minimalism with Colly Flowtech Brand */
.colly-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: 100vw; /* aldrig bredare än fönstret */
    height: 70vh; /* procent av höjden istället för fast 760px */
    max-height: 760px; /* tak på stora skärmar */
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    display: none;
    flex-direction: column;
    border: 1px solid rgba(27, 43, 95, 0.04); /* supertunn, nästan osynlig kort-ram */
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.colly-chatbot-container.open {
    display: flex;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header - Professional Sophisticated Design */
.colly-chatbot-header {
    background: #E6E6E6;
    color: #000000;
    padding: 24px 24px 20px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-radius: 16px 16px 0 0;
    border-bottom: 1px solid rgba(27, 43, 95, 0.08);
    flex-shrink: 0;
    position: relative;
}

.colly-chatbot-header h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    .colly-chatbot-input-wrapper {
        padding: 16px 20px 18px 20px;
        background: transparent;
        border-top: none;
        border-radius: 0 0 16px 16px;
        flex-shrink: 0;
    }
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: -0.2px;
    color: #000000;
    line-height: 1.2;
}

.colly-chatbot-close {
    background: none;
    border: none;
    color: #ACACAB;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    margin-top: -4px;
}

.colly-chatbot-close:hover {
    background: rgba(172, 172, 171, 0.1);
    color: #1B2B5F;
}

.colly-chatbot-close:active {
    background: rgba(172, 172, 171, 0.2);
    transform: scale(0.95);
}

.colly-chatbot-header-content {
    display: flex;
    flex-direction: column;
}

.colly-chatbot-header-subtitle {
    font-size: 13px;
    color: #ACACAB;
    font-weight: 400;
    line-height: 1.3;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.colly-chatbot-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.colly-chatbot-avatar {
    width: 72px;
    height: 72px;
    border-radius: 0;
    background-color: transparent;
    background-image: url('../images/chat-bot-avatar.svg');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    margin-left: -4px;
    flex-shrink: 0;
    border: none;
}

.colly-chatbot-title-block h3 {
    margin: 0 0 2px 0;
}

.colly-chatbot-title-block .colly-chatbot-header-subtitle {
    margin: 0;
}

/* Messages - Minimalistisk stil med animationer */
.colly-chatbot-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.colly-chatbot-legal {
    margin-top: 2px;
    text-align: center;
    font-size: 11px;
    color: rgba(27, 43, 95, 0.6);
    font-weight: 400;
}

.colly-chatbot-legal a {
    color: rgba(27, 43, 95, 0.85);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.colly-chatbot-legal a:hover,
.colly-chatbot-legal a:focus-visible {
    color: #1B2B5F;
}

/* Custom scrollbar */
.colly-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.colly-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.colly-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(172, 172, 171, 0.3);
    border-radius: 3px;
}

.colly-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(172, 172, 171, 0.5);
}

/* Textarea scrollbar */
.colly-chatbot-input textarea::-webkit-scrollbar {
    width: 4px;
}

.colly-chatbot-input textarea::-webkit-scrollbar-track {
    background: transparent;
}

.colly-chatbot-input textarea::-webkit-scrollbar-thumb {
    background: rgba(172, 172, 171, 0.3);
    border-radius: 2px;
}

.colly-chatbot-input textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(172, 172, 171, 0.5);
}

.colly-chatbot-message {
    max-width: 90%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.35;
    word-wrap: break-word;
    font-family: 'Open Sans', sans-serif;
    font-weight: 400;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    opacity: 0;
    animation: fadeInMessage 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transform: translateY(10px);
}

@keyframes fadeInMessage {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.colly-chatbot-message.bot {
    background: #F8F9FA;
    color: #000000;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(27, 43, 95, 0.08);
}

/* Bot message content – mer luft mellan rader och snyggare listor */
.colly-chatbot-message.bot .colly-chatbot-message-content {
    display: flex;
    flex-direction: column;
    gap: 6px; /* vertikalt mellanrum mellan rader/block */
    line-height: 1.6;
}

.colly-chatbot-message.bot .colly-chatbot-message-content .list-item {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.colly-chatbot-message.bot .colly-chatbot-message-content .list-bullet {
    font-size: 14px;
    line-height: 1.2;
    margin-top: 3px;
}

.colly-chatbot-message.bot .colly-chatbot-message-content .spacer-line {
    height: 6px; /* extra luft för tomma rader (\n\n) */
}

.colly-chatbot-message.user {
    background: #E9F4F7;
    color: #000000;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(27, 43, 95, 0.2);
}

/* Typing Indicator - Förbättrad animation */
.colly-chatbot-message.typing {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: #F8F9FA;
    color: #000000;
    font-style: normal;
    font-size: 13px;
    opacity: 1;
    border: 1px solid rgba(27, 43, 95, 0.08);
}

.colly-chatbot-message.typing::before {
    content: 'Skriver';
}

/* Ingen text, endast tre prickar som indikerar att botten skriver */
.colly-chatbot-message.typing::before {
    content: '';
    margin-right: 0;
}

.colly-chatbot-message.typing .typing-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #1B2B5F;
    display: inline-block;
    margin: 0 1px;
    opacity: 0.3;
    animation: typingDotBounce 1.2s infinite ease-in-out;
}

.colly-chatbot-message.typing .typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.colly-chatbot-message.typing .typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingDotBounce {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.3;
    }
    40% {
        transform: translateY(-3px);
        opacity: 1;
    }
}

/* Input - Minimalistisk design */
.colly-chatbot-input {
    padding: 18px 20px 14px 20px;
    background: transparent; /* inget extra vitt "kort" runt bubblan */
    border-top: none; /* ingen linje ovanför bubblan */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 16px 16px;
    flex-shrink: 0;
}

.colly-chatbot-input textarea {
    flex: 1 1 auto;
    margin-top: 0;
    width: 100%;
    max-width: 100%;
    padding: 10px 44px 10px 14px; /* behåll nuvarande storlek och form */
    border: 1px solid rgba(27, 43, 95, 0.2); /* grå INK-outline i viloläge */
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    font-family: 'Open Sans', sans-serif;
    transition: all 0.2s ease;
    background: #ffffff;
    height: 36px;
    max-height: 120px;
    line-height: 1.4;
    color: #000000;
    resize: none;
    overflow: hidden;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    position: relative;
}

.colly-chatbot-input textarea:focus {
    border-color: #1B2B5F; /* samma ram, men INK-färg vid fokus */
    box-shadow: none;
    outline: none;
    transform: translateY(-1px);
}

.colly-chatbot-input textarea::placeholder {
    color: #ACACAB;
}

.colly-chatbot-input button {
    position: relative;
    margin-left: -28px; /* finjustera så högerkant får samma luft som vänster */
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    height: 20px;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent; /* dölj eventuell text */
    font-size: 0;
}

.colly-chatbot-input button svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #000000; /* svart outline på planet */
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Trigger Button - Professional Sophisticated Design */
.colly-chatbot-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    background: #ffffff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(27, 43, 95, 0.12), 0 1px 3px rgba(0, 0, 0, 0.08);
    z-index: 9998;
    transition: all 0.2s ease;
    border: 1px solid rgba(27, 43, 95, 0.08);
    background-image: url('../images/colly-logo.png');
    background-size: 28px 28px;
    background-repeat: no-repeat;
    background-position: center;
}

.colly-chatbot-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(27, 43, 95, 0.15), 0 3px 10px rgba(0, 0, 0, 0.1);
    border-color: rgba(27, 43, 95, 0.2);
}

.colly-chatbot-trigger:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(27, 43, 95, 0.1);
}

.colly-chatbot-trigger.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.colly-chatbot-trigger.has-notification {
    border-color: #1B2B5F;
}

.colly-chatbot-trigger.has-notification::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #1B2B5F;
    border-radius: 50%;
    border: 2px solid white;
    animation: subtlePulse 3s infinite;
}

@keyframes subtlePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Escalation Support Buttons */
.colly-chatbot-message.escalation {
    background: #ffffff;
    border: 1px solid rgba(27, 43, 95, 0.12);
    border-radius: 14px;
    padding: 18px 18px 16px 18px;
    margin: 10px 0;
    box-shadow: 0 2px 10px rgba(27, 43, 95, 0.1);
    max-width: 90%;
    align-self: flex-start;
}

.escalation-text {
    font-weight: 500;
    color: #000000;
    margin-bottom: 16px;
    font-size: 15px;
    line-height: 1.6;
}

.escalation-buttons {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    justify-content: flex-start;
}

.escalation-btn {
    padding: 8px 18px;
    border: 1.2px solid;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 80px;
    font-family: 'Arial', sans-serif;
    background: transparent;
}

.escalation-yes {
    color: #1B2B5F;
    border-color: #1B2B5F;
}

.escalation-yes:hover:not(:disabled) {
    background: #1B2B5F;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(27, 43, 95, 0.25);
}

.escalation-no {
    color: #ACACAB;
    border-color: #ACACAB;
}

.escalation-no:hover:not(:disabled) {
    background: #ACACAB;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(172, 172, 171, 0.25);
}

.escalation-btn:active:not(:disabled) {
    transform: translateY(0);
}

.escalation-btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

/* Contact Form - Minimalistisk stil */
.contact-form {
    background: #ffffff;
    border: 1px solid rgba(27, 43, 95, 0.15);
    border-radius: 16px;
    padding: 20px;
    margin: 8px 0;
    box-shadow: 0 2px 12px rgba(27, 43, 95, 0.08);
    max-width: 90%;
    align-self: flex-start;
}

.contact-form-header h4 {
    margin: 0 0 6px 0;
    color: #000000;
    font-size: 16px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: -0.2px;
}

.contact-form-header p {
    margin: 0 0 16px 0;
    color: #ACACAB;
    font-size: 13px;
    font-family: 'Open Sans', sans-serif;
    line-height: 1.5;
}

.contact-form-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contact-form-fields input {
    padding: 10px 14px;
    border: 1px solid rgba(27, 43, 95, 0.2);
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    height: 40px;
    color: #000000;
}

.contact-form-fields input:focus {
    outline: none;
    border-color: #1B2B5F;
    box-shadow: 0 0 0 3px rgba(27, 43, 95, 0.1);
    transform: translateY(-1px);
}

.contact-form-fields input::placeholder {
    color: #ACACAB;
}

.contact-form-submit {
    background: #1B2B5F;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    font-family: 'Open Sans', sans-serif;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 10px;
    height: 40px;
    box-shadow: 0 2px 8px rgba(27, 43, 95, 0.15);
}

.contact-form-submit:hover:not(:disabled) {
    background: #142046;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(27, 43, 95, 0.25);
}

.contact-form-submit:active:not(:disabled) {
    transform: translateY(0);
}

.contact-form-submit:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    background: #ACACAB;
}

.contact-form-success {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, #E9F4F7 0%, #F8F9FA 100%);
    border: 1px solid rgba(27, 43, 95, 0.2);
    border-radius: 12px;
    color: #000000;
}

.contact-form-success p {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

.privacy-notice {
    margin: 8px 0 0 0;
    padding: 8px 10px;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 6px;
    border: 1px solid rgba(27, 43, 95, 0.06);
}

.privacy-notice p {
    font-size: 11px;
    color: #000000;
    margin: 0;
    line-height: 1.4;
    font-style: italic;
    opacity: 0.7;
}

/* Mobile & Tablet Responsive */
@media (max-width: 768px) {
    .colly-chatbot-container {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height för mobil */
        border-radius: 0;
    }
    
    .colly-chatbot-header {
        padding: 20px 20px 16px 20px;
        border-radius: 0;
    }
    
    .colly-chatbot-messages {
        padding: 16px;
        gap: 10px;
    }
    
    .colly-chatbot-message {
        max-width: 90%;
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .colly-chatbot-input {
        padding: 16px 16px 20px 16px;
        gap: 8px;
    }
    
    .colly-chatbot-input textarea {
        height: 40px;
        max-height: 100px;
        font-size: 14px;
        padding: 10px 14px;
    }
    
    .colly-chatbot-input button {
        height: 40px;
        font-size: 14px;
    }
    
    .colly-chatbot-trigger {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
        background-size: 24px 24px;
        border-radius: 14px;
    }
    
    .escalation-buttons {
        flex-direction: column;
    }
    
    .escalation-btn {
        width: 100%;
    }
    
    .contact-form,
    .colly-chatbot-message.escalation {
        max-width: 95%;
    }
}

/* Laptop / mindre desktop – gör widgeten lite kompaktare */
@media (max-width: 1200px) and (min-width: 769px) {
    .colly-chatbot-container {
        width: 340px;
        height: 65vh;
        max-height: 720px;
    }

    .colly-chatbot-header {
        padding: 18px 18px 14px 14px;
    }

    .colly-chatbot-avatar {
        width: 60px;
        height: 60px;
        margin-left: -2px;
    }

    .colly-chatbot-messages {
        padding: 18px;
    }

    .colly-chatbot-header h3 {
        font-size: 17px;
    }
}

/* Tablet specific (mellan mobil och desktop) */
@media (min-width: 769px) and (max-width: 1024px) {
    .colly-chatbot-container {
        width: 400px;
        height: 560px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible för keyboard navigation */
.colly-chatbot-input textarea:focus-visible,
.colly-chatbot-input button:focus-visible,
.escalation-btn:focus-visible,
.contact-form-submit:focus-visible,
.colly-chatbot-close:focus-visible {
    outline: 2px solid #1B2B5F;
    outline-offset: 2px;
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .colly-chatbot-trigger {
        width: 64px;
        height: 64px;
    }
    
    .escalation-btn,
    .contact-form-submit,
    .colly-chatbot-input button {
        min-height: 44px; /* Större touch targets */
    }
}