/* Modern UI Tokens & Glassmorphism */
:root {
    --bg-light: #f5f2eb; /* Light beige */
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --card-bg: #e61931; /* LG Active Red */
    --card-text: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-highlight: rgba(255, 255, 255, 0.15);
    --accent-red: #e61931;
    --accent-purple: #8b5cf6;
    --accent-blue: #3b82f6;
    --card-shadow: 0 10px 30px rgba(230, 25, 49, 0.3);
    --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Be Vietnam Pro', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: 'Outfit', sans-serif;
}

/* Dynamic Animated Background Mesh */
.mesh-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    background: var(--bg-light);
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.2;
    border-radius: 50%;
    animation: drift 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, #e61931 0%, transparent 70%);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, #ffffff 0%, transparent 70%);
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 40vw;
    height: 40vw;
    background: radial-gradient(circle, #e61931 0%, transparent 60%);
    opacity: 0.1;
    animation-delay: -10s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10vw, -10vh) scale(1.1); }
}

/* Layout */
.portal-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 2rem;
    position: relative;
    z-index: 1;
}

.portal-header {
    text-align: center;
    margin-bottom: 1.5rem;
    animation: fadeDown 1s ease-out;
}

.portal-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--accent-red);
    letter-spacing: -1px;
}

.portal-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 300;
}

/* Language Switcher */
.lang-switcher {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.lang-btn {
    background: none;
    border: none;
    color: var(--text-main);
    opacity: 0.5;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    padding: 0.2rem 0.4rem;
    font-family: 'Be Vietnam Pro', sans-serif;
}

.lang-btn:hover {
    opacity: 0.8;
}

.lang-btn.active {
    opacity: 1;
    color: var(--accent-red);
}

.lang-divider {
    color: var(--text-main);
    opacity: 0.3;
    font-size: 0.8rem;
}

/* Grid & Cards */
.category-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    perspective: 1000px;
}

.category-card {
    background: var(--card-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 1.25rem 1rem;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.6s forwards ease-out;
    color: var(--card-text);
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, var(--glass-highlight) 0%, transparent 100%);
    opacity: 0;
    transition: var(--transition);
}

.category-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(230, 25, 49, 0.4);
}

.category-card:hover::before {
    opacity: 1;
}

/* Active state logic */
.category-card.active {
    box-shadow: 0 0 0 4px #fff, 0 0 0 6px var(--accent-red), var(--card-shadow);
}

.card-icon {
    width: calc(100% + 2rem);
    height: 180px;
    margin: -1.25rem -1rem 1rem -1rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.category-card:hover .product-image {
    transform: scale(1.08);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--card-text);
}

.card-desc {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.85);
    line-height: 1.4;
    margin-bottom: 1rem;
    flex-grow: 1;
}

.card-link {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50px;
    color: #fff;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 600;
    transition: var(--transition);
    z-index: 2;
}

.category-card:hover .card-link {
    background: #fff;
    color: var(--accent-red);
}

.card-link:hover {
    transform: translateY(-2px);
}

/* Chatbot Indicator */
.chatbot-indicator {
    position: fixed;
    top: 9rem;
    left: 2rem;
    background: #ffffff;
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transform: translateX(-150%);
    transition: var(--transition);
}

.chatbot-indicator.visible {
    transform: translateX(0);
}

.indicator-glow {
    width: 12px;
    height: 12px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    animation: pulse 2s infinite;
}

.indicator-text {
    font-size: 0.9rem;
    color: var(--text-primary);
}
.indicator-text span {
    color: var(--text-secondary);
}
.indicator-text strong {
    color: var(--text-primary);
    margin-left: 0.25rem;
    font-family: 'Outfit', sans-serif;
}

/* Custom Chat Widget */
#custom-chat-widget {
    position: fixed;
    top: 2rem;
    left: 2rem;
    z-index: 1000;
}

.custom-chat-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #ffffff;
    color: white;
    border: none;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    animation: aiPulse 2.5s infinite, gradientMove 3s ease infinite;
}

@keyframes aiPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(255, 255, 255, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.custom-chat-btn:hover {
    transform: scale(1.08) !important;
    box-shadow: 0 6px 25px rgba(230, 25, 49, 0.8);
}

.robot-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chat-speech-bubble {
    position: absolute;
    top: 50%;
    left: 110px;
    transform: translateY(-50%);
    background-color: #ffffff;
    color: var(--accent-red);
    padding: 12px 20px;
    border-radius: 20px;
    border-top-left-radius: 4px;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 10px 25px rgba(230, 25, 49, 0.25);
    white-space: nowrap;
    animation: floatBubble 3s ease-in-out infinite;
    pointer-events: none;
    font-family: 'Be Vietnam Pro', sans-serif;
}

.chat-speech-bubble::before {
    content: '';
    position: absolute;
    top: 15px;
    left: -8px;
    width: 0;
    height: 0;
    border-top: 10px solid #ffffff;
    border-left: 10px solid transparent;
}

@keyframes floatBubble {
    0%, 100% { transform: translateY(-50%); }
    50% { transform: translateY(-60%); }
}

.custom-chat-window {
    position: absolute;
    top: 110px;
    left: 0;
    width: 350px;
    background: #ffffff;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px) scale(0.95);
    transform-origin: top left;
    transition: var(--transition);
}

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

.switch-bot-btn {
    background: var(--accent-red);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 4px;
    transition: var(--transition);
}

.switch-bot-btn:hover {
    background: #c4152a;
    transform: scale(1.05);
}

/* Hide default Chatbase button so our custom robot button can trigger it */
#chatbase-bubble-button {
    opacity: 0 !important;
    pointer-events: none !important;
    width: 0 !important;
    height: 0 !important;
    z-index: -9999 !important;
}

.chat-header {
    background: #f8f9fa;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-red);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
}

.chat-header h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.chat-status {
    font-size: 0.75rem;
    color: #22c55e;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.close-chat-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-chat-btn:hover {
    color: var(--text-primary);
}

.chat-body {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
}

.chat-message {
    background: #f1f5f9;
    padding: 1rem;
    border-radius: 12px;
    border-top-left-radius: 2px;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.chat-options-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.chat-option-btn {
    background: transparent;
    border: 1px solid var(--accent-red);
    color: var(--accent-red);
    padding: 0.5rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.chat-option-btn:hover {
    background: var(--accent-red);
    color: white;
}

/* Animations */
@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Footer */
.portal-footer {
    text-align: center;
    padding: 2rem 1rem 3rem 1rem;
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
}

.portal-footer p {
    margin-bottom: 0.5rem;
}

.portal-footer strong {
    color: var(--accent-red);
    font-size: 1.2rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (max-width: 768px) {
    .portal-title {
        font-size: 2rem;
    }
    .portal-container {
        padding: 1rem 1rem;
    }
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .category-grid {
        grid-template-columns: 1fr;
    }
}
