/* ===== Reset & Layout ===== */
/* Set full width and height for main containers */
html, body, #n8n-chat {
    width: 100%;
    height: 100%;
}

/* ===== Light Theme Variables ===== */
/* Define CSS variables for light theme */
:root {
    --chat--color-primary: #e74266;
    --chat--color-primary-shade-50: #db4061;
    --chat--color-primary-shade-100: #cf3c5c;
    --chat--color-secondary: #20b69e;
    --chat--color-secondary-shade-50: #1ca08a;
    --chat--color-white: #fff;
    --chat--color-light: #f2f4f8;
    --chat--color-dark: #101330;
    --chat--color-medium: #d2d4d9;
    --chat--color-disabled: #777980;
    --chat--color-typing: #404040;
    --chat--input--text-color: initial;

    --chat--spacing: 1rem;
    --chat--border-radius: 0.25rem;
    --chat--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;

    --chat--window--width: 400px;
    --chat--window--height: 600px;
    --chat--window--z-index: 9999;
    --chat--window--border: 1px solid #e6e9f1;
    --chat--window--border-radius: var(--chat--border-radius);

    --chat--header--background: var(--chat--color-dark);
    --chat--header--color: var(--chat--color-light);

    --chat--message--font-size: 1rem;
    --chat--message--padding: var(--chat--spacing);
    --chat--message--border-radius: var(--chat--border-radius);
    --chat--message-line-height: 1.5;
    --chat--message--bot--background: var(--chat--color-white);
    --chat--message--bot--color: var(--chat--color-dark);
    --chat--message--user--background: var(--chat--color-secondary);
    --chat--message--user--color: var(--chat--color-white);

    --chat--toggle--size: 64px;
    --chat--toggle--border-radius: 50%;
    --chat--toggle--background: var(--chat--color-primary);

    --chat--textarea--height: 50px;
    --chat--input--font-size: inherit;
    --chat--input--background: var(--chat--color-white);

    --chat--button--color: var(--chat--color-light);
    --chat--button--background: var(--chat--color-primary);

    --chat--body--background: var(--chat--color-light);
    --chat--footer--background: var(--chat--color-light);
    --chat--footer--color: var(--chat--color-dark);
}

/* ===== Dark Theme Variables ===== */
/* Override CSS variables for dark mode */
html.dark-mode {
    --chat--color-light: #181818;
    --chat--color-dark: #f2f4f8;
    --chat--color-white: #222;
    --chat--color-medium: #333;
    --chat--header--background: #101330;
    --chat--header--color: #f2f4f8;
    --chat--input--text-color: #fff;
}

/* ===== Custom Overrides ===== */
/* Limit chat message width */
.chat-message {
    max-width: 50%;
}

/* Add logo before chat heading */
.chat-heading h1::before {
    content: '';
    display: inline-block;
    vertical-align: middle;
    width: 45px;
    height: 45px;
    margin-right: 6px;
    background: url('logo.png') center/cover no-repeat;
}

/* Adjust chat header heading and description spacing */
.n8n-chat .chat-header .chat-heading h1 {
    margin-bottom: 0px !important;
}
.n8n-chat .chat-header .chat-heading p {
    margin: 0 !important;
    font-size: 0.95em !important;
}

/* Hide welcome message */
.n8n-chat-welcome {
    display: none !important;
}

/* ===== Reset chat button ===== */
/* Style for chat reset button */
#chat-reset {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    color: #f2f4f8;
}

/* ===== Theme toggle button ===== */
/* Style for theme toggle button */
#theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8em;
    vertical-align: middle;
    padding-left: 8px;
    color: #f1c40f;}
#theme-toggle:active {
    transform: scale(0.88);
}
#theme-toggle svg {
    width: 28px;
    height: 28px;
    transition: transform 0.68s cubic-bezier(0.21, 1, 0.30 1);
}
#theme-toggle:active svg {
    transform: scale(1.28);
}

/* ===== Hide Powered by n8n ===== */
/* Hide "Powered by n8n" branding */
.n8n-chat-powered-by,
.n8n-chat-powered-by *,
div[class*="powered-by"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* ===== Reduce header height ===== */
/* Reduce chat header padding */
.n8n-chat .chat-header {
    padding: 0 12px !important;

}

/* ===== Login Overlay ===== */
/* Full screen overlay for login form */
#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--chat--color-light);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#login-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Login form container */
#login-form-container {
    background: var(--chat--color-white);
    border-radius: var(--chat--border-radius);
    padding: 2.5rem;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--chat--color-medium);
}

/* Login content wrapper */
#login-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

/* Login header */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 1rem;
    border-radius: var(--chat--border-radius);
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--chat--color-dark);
    margin: 0 0 0.5rem 0;
    font-family: var(--chat--font-family);
}

.login-header p {
    font-size: 0.95rem;
    color: var(--chat--color-disabled);
    margin: 0;
    font-family: var(--chat--font-family);
}

/* Google Sign-In button wrapper */
.g_id_signin {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Google Sign-In button styling adjustments */
.g_id_signin iframe,
.g_id_signin div {
    margin: 0 auto;
}

/* Error message */
.error-message {
    background: #fee;
    color: #c33;
    padding: 0.75rem;
    border-radius: var(--chat--border-radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-family: var(--chat--font-family);
    border: 1px solid #fcc;
}


/* Dark mode adjustments for login */
html.dark-mode #login-overlay {
    background: var(--chat--color-light);
}

html.dark-mode #login-form-container {
    background: var(--chat--color-white);
    border-color: var(--chat--color-medium);
}


/* Hide chat when login overlay is visible */
#login-overlay:not(.hidden) ~ #n8n-chat,
#login-overlay:not(.hidden) ~ #chat-reset {
    display: none;
}