:root {
    --bg-color: #0f1115;
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    background-image: linear-gradient(rgba(15, 17, 21, 0.85), rgba(15, 17, 21, 0.85)), url('background.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    max-width: 900px;
    height: 90vh;
    /* Leave some breathing room */
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    overflow: hidden;
    margin: 0 20px;
}

/* Header */
.chat-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.logo {
    font-weight: 600;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px var(--accent-glow);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo img {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.company-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    margin-bottom: 4px;
    margin-left: 44px;
    /* Align with text start approximately */
}

.status-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    margin-left: 44px;
    /* Align status with text too */
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    gap: 8px;
}

.lang-btn {
    background-color: rgba(255, 255, 255, 0.1);
    background-size: cover;
    background-position: center;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    /* Force clipping */
}

.lang-btn[data-lang="pl"] {
    /* Using inline SVG with ZOOM to ensure it covers the circle completely */
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect width="32" height="16" fill="white"/><rect y="16" width="32" height="16" fill="%23DC143C"/></svg>');
    background-size: 180%;
    /* Aggressive zoom */
    background-position: center;
    background-repeat: no-repeat;
}

.lang-btn[data-lang="en"] {
    background-image: url('/images/en.png?v=3');
    background-size: 160%;
    /* Zoom to crop baked-in border */
    background-repeat: no-repeat;
}

.lang-btn[data-lang="es"] {
    background-image: url('/images/es.png?v=3');
    background-size: 160%;
    /* Zoom to crop baked-in border */
    background-repeat: no-repeat;
}

.lang-btn:hover {
    transform: scale(1.1);
    filter: grayscale(0);
    opacity: 1;
    background-color: rgba(255, 255, 255, 0.1);
}

.lang-btn.active {
    filter: grayscale(0);
    opacity: 1;
    border: 2px solid var(--accent-color);
    /* Restored visible border */
    box-shadow: 0 0 10px var(--accent-glow);
    background-color: rgba(59, 130, 246, 0.2);
}


.dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 15px;
    max-width: 80%;
    animation: fadeIn 0.3s ease-out;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message.user .content {
    background: var(--accent-color);
    color: white;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.message.system .content {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 18px 18px 18px 4px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.message.user .avatar {
    background: linear-gradient(135deg, #10b981, #059669);
}

.content {
    padding: 14px 20px;
    line-height: 1.5;
    font-size: 0.95rem;
}

/* Input Area */
.chat-input-area {
    padding: 20px 30px;
    border-top: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
}

.input-wrapper {
    display: flex;
    gap: 15px;
    background: var(--input-bg);
    padding: 8px 8px 8px 20px;
    border-radius: 50px;
    border: 1px solid var(--glass-border);
    transition: box-shadow 0.3s ease;
}

.input-wrapper:focus-within {
    box-shadow: 0 0 0 2px var(--accent-color);
}

input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    outline: none;
    font-family: inherit;
}

button {
    background: var(--accent-color);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

button:active {
    transform: scale(0.95);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-items: center;
    height: 100%;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

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

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}
/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-container {
        height: 100vh;
        /* Fallback for browsers that don't support dvh */
        height: 100dvh;
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
    }

    .chat-header {
        padding: 15px 20px;
    }
    
    .chat-history {
        padding: 20px;
    }
    
    .chat-input-area {
        padding: 16px 20px;
    }
    
    .company-desc {
        display: none;
    }
    
    .status-indicator {
        margin-top: 2px;
    }
}

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

    .logo {
        font-size: 1.1rem;
    }
    
    .logo img {
        height: 28px;
    }
    
    .chat-history {
        padding: 16px;
        gap: 16px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .content {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
    
    .avatar {
        width: 32px;
        height: 32px;
        font-size: 0.7rem;
    }

    .chat-input-area {
        padding: 12px 16px;
    }

    .input-wrapper {
        padding: 8px 8px 8px 16px;
    }
    
    button {
        width: 40px;
        height: 40px;
    }
    
    .lang-switcher {
        gap: 6px;
    }
    
    .lang-btn {
        width: 28px;
        height: 28px;
    }
}