:root {
    --background: oklch(1 0 0);
    --foreground: oklch(0.13 0.028 261.692);
    --card: oklch(1 0 0);
    --card-foreground: oklch(0.13 0.028 261.692);
    --popover: oklch(1 0 0);
    --popover-foreground: oklch(0.13 0.028 261.692);
    --primary: oklch(0.60 0.13 163);
    --primary-foreground: oklch(0.98 0.02 166);
    --secondary: oklch(0.967 0.001 286.375);
    --secondary-foreground: oklch(0.21 0.006 285.885);
    --muted: oklch(0.967 0.003 264.542);
    --muted-foreground: oklch(0.551 0.027 264.364);
    --accent: oklch(0.60 0.13 163);
    --accent-foreground: oklch(0.98 0.02 166);
    --destructive: oklch(0.577 0.245 27.325);
    --destructive-foreground: oklch(0.985 0.002 247.839);
    --border: oklch(0.928 0.006 264.531);
    --input: oklch(0.928 0.006 264.531);
    --ring: oklch(0.707 0.022 261.325);
    --primary-rgb: 0, 166, 126; /* Approximate RGB for the primary green */
    --destructive-rgb: 220, 38, 38;
}

.dark {
    --background: oklch(0.13 0.028 261.692);
    --foreground: oklch(0.985 0.002 247.839);
    --card: oklch(0.21 0.034 264.665);
    --card-foreground: oklch(0.985 0.002 247.839);
    --popover: oklch(0.21 0.034 264.665);
    --popover-foreground: oklch(0.985 0.002 247.839);
    --primary: oklch(0.70 0.15 162);
    --primary-foreground: oklch(0.26 0.05 173);
    --secondary: oklch(0.274 0.006 286.033);
    --secondary-foreground: oklch(0.985 0 0);
    --muted: oklch(0.278 0.033 256.848);
    --muted-foreground: oklch(0.707 0.022 261.325);
    --accent: oklch(0.70 0.15 162);
    --accent-foreground: oklch(0.26 0.05 173);
    --destructive: oklch(0.704 0.191 22.216);
    --destructive-foreground: oklch(0.985 0.002 247.839);
    --border: rgba(255, 255, 255, 0.1);
    --input: rgba(255, 255, 255, 0.15);
    --ring: oklch(0.551 0.027 264.364);
    --primary-rgb: 34, 197, 129; /* Brighter RGB for dark mode primary */
    --destructive-rgb: 248, 113, 113;
}

body { 
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--foreground);
    transition: background-color 0.3s, color 0.3s;
}

.gradient-text {
    background: linear-gradient(to right, oklch(0.70 0.15 162), oklch(0.274 0.006 286.033));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Fix for input text visibility and minimal borders in both themes */
input, textarea, select {
    color: var(--foreground) !important;
    background-color: var(--background) !important;
    caret-color: var(--primary) !important;
    border: 1px solid var(--border) !important;
}

input:focus, textarea:focus, select:focus {
    background-color: var(--background) !important;
    border-color: var(--primary) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--primary) !important;
}

/* Chatbot Specific: Remove the white/background shadow ring on focus */
.chatbot-input-area textarea:focus {
    box-shadow: none !important;
    border-color: var(--primary) !important;
    outline: none !important;
}

.dark input, .dark textarea, .dark select {
    background-color: oklch(0.18 0.028 261.692) !important; /* Slightly lighter than background for contrast */
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.dark input:focus, .dark textarea:focus, .dark select:focus {
    background-color: oklch(0.18 0.028 261.692) !important;
    border-color: var(--primary) !important;
}

input::placeholder, textarea::placeholder {
    color: var(--muted-foreground) !important;
}

[x-cloak] { display: none !important; }

/* Soften all primary-colored borders in dark mode globally */
.dark .border-primary\/20 {
    border-color: rgba(var(--primary-rgb), 0.1) !important;
}
.dark .border-destructive\/20 {
    border-color: rgba(var(--destructive-rgb), 0.1) !important;
}
.dark .border-primary\/10 {
    border-color: rgba(var(--primary-rgb), 0.05) !important;
}

/* Specific fixes for UI elements that use primary borders */
.dark [class*="border-primary"],
.dark [class*="border-destructive"] {
    border-color: rgba(var(--primary-rgb), 0.1) !important;
}

.dark [class*="border-destructive"] {
    border-color: rgba(var(--destructive-rgb), 0.1) !important;
}

/* Ensure the featured plan border stays visible but not "glowing" */
.dark .border-2.border-primary {
    border-color: var(--primary) !important;
    opacity: 0.8;
}

/* Autofill fix for dark mode */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus, 
input:-webkit-autofill:active {
    -webkit-text-fill-color: var(--foreground) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--background) inset !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Chatbot Widget Styles */
#chatbot-widget {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

#chatbot-widget * {
    pointer-events: auto;
}

#chatbot-button {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    flex-shrink: 0 !important;
    border-radius: 50% !important;
    background: var(--primary) !important;
    color: white !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border: none !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
    padding: 0 !important;
    position: relative !important;
    z-index: 100001 !important;
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
    overflow: hidden !important;
    margin: 0 !important;
}

#chatbot-button i {
    font-size: 28px !important;
    color: #ffffff !important;
    pointer-events: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 0 !important;
}

#chatbot-button i.fa-comment-dots {
    /* Font Awesome speech bubbles often look slightly off-center because of the tail */
    /* This nudge helps it look more visually centered in a circle */
    transform: translateY(-1px) !important;
}

#chatbot-button i[style*="display: none"] {
    display: none !important;
}

#chatbot-button:hover {
    transform: scale(1.05) !important;
    filter: brightness(1.1) !important;
}

[x-cloak] { 
    display: none !important; 
}

#chatbot-window {
    position: fixed;
    /* Collapsed coordinates */
    top: calc(100vh - 1.5rem - 80px - 600px);
    left: calc(100vw - 1.5rem - 380px);
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 10001;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
    will-change: top, left, width, height;
}

#chatbot-window.is-expanded {
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 100px) !important;
    max-height: none !important;
    border-radius: 0 0 24px 24px !important;
    z-index: 100000 !important;
    margin: 0 !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    border: none !important;
}

/* Chatbot Notification Bubble */
#chatbot-notification {
    position: relative;
    margin-bottom: 15px;
    width: 240px;
    background: var(--background);
    border: 1px solid var(--primary);
    border-radius: 20px;
    padding: 12px 16px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 99;
    cursor: pointer;
    transition: all 0.3s ease;
}

#chatbot-notification::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 22px; /* Center of 60px button is 30px. Notification is aligned right. 30px - (15px/2) = 22.5px */
    width: 15px;
    height: 15px;
    background: var(--background);
    border-right: 1px solid var(--primary);
    border-bottom: 1px solid var(--primary);
    transform: rotate(45deg);
    pointer-events: none;
}

#chatbot-notification:hover {
    transform: translateY(-5px);
    border-color: oklch(from var(--primary) calc(l + 0.05) c h);
}

.dark #chatbot-window {
    background: var(--card);
    border-color: var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

.chatbot-header {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    color: var(--primary-foreground);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px 20px 0 0;
}

#chatbot-window.is-expanded .chatbot-header {
    border-radius: 0;
    padding: 1rem 15% !important;
}

.chatbot-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: inherit;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.chatbot-header i.fa-robot {
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.15);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.chatbot-header h3 {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--background);
}

#chatbot-window.is-expanded .chatbot-messages {
    padding: 2rem 15% !important;
}

.dark .chatbot-messages {
    background: var(--background);
}

.message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.message.ai {
    align-self: flex-start;
    background: var(--muted);
    color: var(--muted-foreground);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.03);
}

.dark .message.ai {
    background: var(--card);
    color: var(--foreground);
    border: 1px solid var(--border);
}

.message.user {
    align-self: flex-end;
    background: var(--primary);
    color: var(--primary-foreground);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.2);
}

.message.ai p { margin-bottom: 0.5rem; }
.message.ai p:last-child { margin-bottom: 0; }
.message.ai ul, .message.ai ol { margin: 0.5rem 0; padding-left: 1.25rem; }
.message.ai li { margin-bottom: 0.25rem; }
.message.ai a { color: var(--primary); text-decoration: underline; font-weight: 600; }
.message.ai code { background: rgba(0,0,0,0.05); padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.9em; }
.dark .message.ai code { background: rgba(255,255,255,0.1); }
.message.ai strong { font-weight: 700; }

.chatbot-input-area {
    margin: 1rem;
    padding: 6px 6px 6px 16px;
    border: 1px solid var(--border);
    border-radius: 100px; /* More rounded pill shape */
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--background);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden; /* Ensures background stays within rounded corners */
}

.chatbot-input-area:focus-within {
    border-color: var(--primary);
    background: oklch(0.18 0.028 261.692); /* Use the gray the user likes for the whole area */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dark .chatbot-input-area:focus-within {
    background: oklch(0.18 0.028 261.692);
}

#chatbot-window.is-expanded .chatbot-input-area {
    margin: 2rem 15% !important;
    padding: 6px 6px 6px 20px;
}

.chatbot-input-area textarea {
    flex: 1;
    padding: 0 !important;
    background: transparent !important; /* Ensure textarea itself never has a background */
    border: none !important;
    font-size: 0.95rem;
    line-height: 40px !important;
    min-height: 40px !important;
    height: 40px !important;
    max-height: 120px !important;
    resize: none;
    outline: none !important;
    box-shadow: none !important;
    margin: 0;
    overflow-y: hidden;
}

.chatbot-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
}

.chatbot-send-btn i {
    transform: translate(-1px, 1px);
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.chatbot-logo-container {
    position: relative;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chatbot-logo-shield {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}

.chatbot-logo-face {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -45%);
    font-size: 9px;
    color: white;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.chatbot-send-btn:hover {
    background: oklch(from var(--primary) calc(l + 0.05) c h);
    opacity: 0.9;
    transform: scale(1.05);
}

.chatbot-send-btn i {
    font-size: 1.1rem;
    transform: translate(-1px, 1px); /* Fine-tune centering */
}

.chatbot-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.typing-indicator {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 10px 18px;
    background: var(--muted);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 8px;
}

.typing-dots {
    display: flex;
    gap: 3px;
    margin-bottom: 4px; /* Align with text baseline */
}

.typing-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted-foreground);
    letter-spacing: 0.01em;
}

.typing-dot {
    width: 4px;
    height: 4px;
    background: var(--muted-foreground);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

@media (max-width: 640px) {
    #chatbot-window {
        width: 100vw !important;
        height: 100vh !important;
        max-height: none !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
    }

    .chatbot-input-area {
        margin: 0.75rem !important;
        padding: 4px 4px 4px 12px !important;
    }

    .chatbot-header {
        padding: 1rem !important;
    }
}

