/* Modern Chatbot Styles */
.modern-chatbot {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    z-index: 999999 !important;
    position: relative !important;
}

/* Toggle Button */
.chatbot-toggle {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #00283c 0%, #004d6b 100%) !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    box-shadow: 0 8px 32px rgba(0, 40, 60, 0.4) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
    pointer-events: auto !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: transform !important;
    isolation: isolate !important;
    contain: layout style paint !important;
}

.chatbot-toggle:hover {
    transform: scale(1.1) translateZ(0) !important;
    -webkit-transform: scale(1.1) translateZ(0) !important;
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.6) !important;
}

.chatbot-toggle:active {
    transform: scale(0.95) translateZ(0) !important;
    -webkit-transform: scale(0.95) translateZ(0) !important;
}

.chatbot-toggle:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(0, 40, 60, 0.3) !important;
}

/* Chat Container */
.chatbot-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 999997;
}

.chatbot-container.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #00283c 0%, #004d6b 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 20px;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Messages Area */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    scroll-behavior: smooth;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message Styles */
.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.bot-message {
    align-items: flex-start;
}

.bot-message .message-content {
    background: linear-gradient(135deg, #00283c 0%, #004d6b 100%);
    color: white;
    border-bottom-left-radius: 6px;
    box-shadow: none;
}

.user-message {
    align-items: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, #00283c 0%, #004d6b 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.message-time {
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
    margin-left: 16px;
    margin-right: 16px;
}

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

/* Form */
.chatbot-form {
    padding: 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.input-group {
    display: flex;
    gap: 0px;
    align-items: center;
    background: #f1f5f9;
    border-radius: 25px;
    padding: 4px;
    transition: box-shadow 0.2s;
    box-sizing: border-box;
    width: 100%;
}

.input-group:focus-within {
    box-shadow: none;
}

#chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    color: #1e293b;
    box-sizing: border-box;
    min-width: 0;
}

#chatbot-input::placeholder {
    color: #94a3b8;
}

#chatbot-send {
    background: linear-gradient(135deg, #00283c 0%, #004d6b 100%) !important;
    border: none !important;
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s !important;
    flex-shrink: 0 !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    min-width: 80px !important;
    height: auto !important;
    width: auto !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: unset !important;
    margin-right: 12px !important;
    box-sizing: border-box;
}

#chatbot-send:hover {
    transform: scale(1.05);
}

#chatbot-send:active {
    transform: scale(0.95);
}

#chatbot-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Powered by text */
.chatbot-powered-by {
    text-align: center !important;
    font-size: 12px !important;
    color: #64748b !important;
    margin-top: 4px !important;
    font-style: italic !important;
    opacity: 0.5 !important;
    letter-spacing: 0.5px !important;
}

/* Loading Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #00283c 0%, #004d6b 100%);
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    max-width: 80%;
    margin-bottom: 16px;
    border-bottom-left-radius: 6px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing 1.4s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .chatbot-container {
        width: calc(100vw - 40px);
        max-height: calc(100dvh - 140px);
        height: auto;
        bottom: 80px;
        right: 20px;
        left: 20px;
    }
    .chatbot-toggle {
        bottom: 15px !important;
        right: 15px !important;
        width: 55px !important;
        height: 55px !important;
    }
    .input-group {
        padding: 2px;
        overflow: hidden;
    }
    #chatbot-send {
        margin-right: 0 !important;
        min-width: 60px !important;
        padding: 8px 8px !important;
    }
    #chatbot-input {
        padding: 10px 10px;
    }
}

/* Body scroll lock fyrir chatbot */
body.chatbot-scroll-lock {
    overflow: hidden !important;
    touch-action: none;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .chatbot-container {
        background: #1e293b;
        color: #f1f5f9;
    }
    .chatbot-messages {
        background: #0f172a;
    }
    .bot-message .message-content {
        background: linear-gradient(135deg, #00283c 0%, #004d6b 100%);
        color: white;
    }
    .input-group {
        background: #334155;
        gap: 0px;
    }
    #chatbot-input {
        color: #f1f5f9;
    }
    #chatbot-input::placeholder {
        color: #64748b;
    }
    .chatbot-form {
        background: #1e293b;
        border-top-color: #334155;
    }
    .modern-chatbot .chatbot-messages a {
      color: #f2d347 !important;
      text-decoration: underline !important;
    }
    .modern-chatbot .chatbot-messages a:hover {
      color: #FFC107 !important;
    }
    .product-card {
      margin-bottom: 1.5rem;
    }
   .chatbot-toggle {
       width: 60px !important;
       height: 60px !important;
       min-width: 60px !important;
       min-height: 60px !important;
       padding: 0 !important;
       overflow: visible !important;
       display: flex !important;
       align-items: center !important;
       justify-content: center !important;
   }
   .chatbot-toggle img {
       width: 50px !important;
       height: 50px !important;
       object-fit: contain;
       display: block;
       margin: 0 auto;
   }
}

#chatbot-input:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Product link styling */
.skoÃ°a-vÃ¶ru {
    color: #FFD700 !important;
    font-weight: bold !important;
    text-decoration: none !important;
    margin-left: 5px !important;
    cursor: pointer !important;
    display: inline-block !important;
    background: rgba(255, 215, 0, 0.1) !important;
    padding: 2px 6px !important;
    border-radius: 4px !important;
    transition: all 0.2s ease !important;
}

.skoÃ°a-vÃ¶ru:hover {
    color: #FFC107 !important;
    text-decoration: underline !important;
    background: rgba(255, 215, 0, 0.2) !important;
    transform: translateY(-1px) !important;
}

/* Also style any link in chatbot messages */
.chatbot-messages a {
    color: #FFD700 !important;
    font-weight: bold !important;
    text-decoration: none !important;
    cursor: pointer !important;
    transition: color 0.2s ease !important;
}

.chatbot-messages a:hover {
    color: #FFC107 !important;
    text-decoration: underline !important;
}

/* Product Image Styling */
.product-image {
    max-width: 150px !important;
    max-height: 150px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 8px !important;
    margin: 8px 0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: transform 0.2s ease !important;
    display: block !important;
    object-fit: contain !important;
}

.product-image:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

/* Dark mode product images - keep images unchanged (no forced background/border) */
@media (prefers-color-scheme: dark) {
    .product-image {
        border: none !important;
        background: transparent !important;
    }
}

/* Product card layout */
.product-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 14px 16px;
    margin: 12px 0;
}
.product-card .product-title {
    font-weight: 700;
    font-size: 16px;
    margin-bottom: 8px;
}
.product-card .product-price {
    font-weight: 700;
    margin-top: 8px;
    margin-bottom: 6px;
}
.product-card .product-desc {
    opacity: 0.9;
    margin-bottom: 10px;
}
.product-card .skoða-vöru {
    display: inline-block;
    background: transparent;
    padding: 0;
}