/* ================================================= */
/* --- THEME: CSS Custom Properties               --- */
/* ================================================= */

:root {
    --color-bg-page: #ffffff;
    --color-bg-surface: #f0f5ff;
    --color-bg-input: #ffffff;
    --color-bg-header: #ffffff;
    --color-bg-bubble-tint: #d8eaff;
    --color-bg-hover: #e5f0ff;
    --color-bg-dropdown: #ffffff;
    --color-bg-details-toggle: #edf2ff;
    --color-bg-messages: #ffffff;
    --color-bg-input-area: #ffffff;
    --color-bg-citation-input: #f5f8ff;
    --color-text-primary: #1a1a2e;
    --color-text-secondary: #666;
    --color-text-muted: #999;
    --color-text-placeholder: #bbb;
    --color-border-primary: #e0e0e0;
    --color-border-teal: rgba(135, 206, 235, 0.5);
    --color-border-panel: rgba(135, 206, 235, 0.5);
    --color-shadow-dropdown: rgba(0, 0, 0, 0.15);
    --color-shadow-card: rgba(135, 206, 235, 0.25);
    --color-shadow-card-hover: rgba(135, 206, 235, 0.4);
    --color-xp-bar-track: #e0e0e0;
    --color-brand-blue: #3f51b5;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg-page: #0f1117;
        --color-bg-surface: #1a1d27;
        --color-bg-input: #1f2230;
        --color-bg-header: #12151f;
        --color-bg-bubble-tint: #1a2035;
        --color-bg-hover: #1e2438;
        --color-bg-dropdown: #1a1d27;
        --color-bg-details-toggle: #1a1d27;
        --color-bg-messages: #12151f;
        --color-bg-input-area: #12151f;
        --color-bg-citation-input: #1f2230;
        --color-text-primary: #e8eaf0;
        --color-text-secondary: #9da3b4;
        --color-text-muted: #7e8694;
        --color-text-placeholder: #4b5563;
        --color-border-primary: #2d3148;
        --color-border-teal: rgba(135, 206, 235, 0.2);
        --color-border-panel: rgba(135, 206, 235, 0.2);
        --color-shadow-dropdown: rgba(0, 0, 0, 0.4);
        --color-shadow-card: rgba(0, 0, 0, 0.3);
        --color-shadow-card-hover: rgba(135, 206, 235, 0.15);
        --color-xp-bar-track: #2d3148;
        --color-brand-blue: #5c6bc0;
    }
}

[data-theme="dark"] {
    --color-bg-page: #0f1117;
    --color-bg-surface: #1a1d27;
    --color-bg-input: #1f2230;
    --color-bg-header: #12151f;
    --color-bg-bubble-tint: #1a2035;
    --color-bg-hover: #1e2438;
    --color-bg-dropdown: #1a1d27;
    --color-bg-details-toggle: #1a1d27;
    --color-bg-messages: #12151f;
    --color-bg-input-area: #12151f;
    --color-bg-citation-input: #1f2230;
    --color-text-primary: #e8eaf0;
    --color-text-secondary: #9da3b4;
    --color-text-muted: #7e8694;
    --color-text-placeholder: #4b5563;
    --color-border-primary: #2d3148;
    --color-border-teal: rgba(135, 206, 235, 0.2);
    --color-border-panel: rgba(135, 206, 235, 0.2);
    --color-shadow-dropdown: rgba(0, 0, 0, 0.4);
    --color-shadow-card: rgba(0, 0, 0, 0.3);
    --color-shadow-card-hover: rgba(135, 206, 235, 0.15);
    --color-xp-bar-track: #2d3148;
    --color-brand-blue: #5c6bc0;
}

/* --- Theme-based logo switching --- */
.logo-dark { display: none; }
.logo-light { display: block; }

[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .logo-light { display: none; }
    :root:not([data-theme="light"]) .logo-dark { display: block; }
}

/* BubbleChat Branded Colors */
html, body {
    height: 100%;
    /* Use -webkit-fill-available on iOS Safari to fill the visual viewport,
       not the layout viewport that includes browser chrome */
    height: -webkit-fill-available;
    margin: 0;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    overflow: hidden;
    background-color: var(--color-bg-page);
    color: var(--color-text-primary);
}

.main-layout {
    display: flex;
    flex-direction: column;
    /* 100dvh (dynamic viewport height) shrinks to exclude the browser UI bar on mobile Safari.
       Falls back to 100vh on browsers that don't support dvh. */
    height: 100vh;
    height: 100dvh;
}

.content {
    flex-grow: 1;
    overflow-y: auto;
    width: 100%;
}

.page {
    max-width: 1200px; 
    margin: 0 auto;    
    flex-grow: 1;      
    padding-top: 1.1rem;
}

h1 {
    font-size: 2.5em;
    color: var(--color-brand-blue);
}

h2 {
    font-size: 2em;
    color: #4A90E2;
}

.header-section {
    text-align: center;
    margin-bottom: 40px;
}

.header-section h1 {
    color: var(--color-brand-blue); /* Brand Deep Blue */
    margin-bottom: 10px;
}


.subtitle {
    color: var(--color-text-secondary);
    margin-bottom: 50px;
    font-size: 1.1em;
}

h1:focus {
    outline: none;
}

/* Links and Link Buttons */
a, .btn-link {
    color:  var(--color-brand-blue); /* Deep Blue from Logo Typography */
    background-color: transparent;
    border: none;
}

/* Dropdown links must follow theme text color, not link color */
a.dropdown-item {
    color: var(--color-text-primary);
    background: none;
}

a.dropdown-item:hover {
    background-color: var(--color-bg-hover);
    color: #87ceeb;
}

/* Active Links/Buttons */
a:active, .btn-link:active,
a.active, .btn-link.active,
.nav-link.active {
    color: #87ceeb; /* Vibrant Teal Accent */
}

/* Focused Links/Buttons */
a:focus, .btn-link:focus,
a.active:focus, .btn-link.active:focus {
    color: #87ceeb; /* Vibrant Teal Accent */
    outline: none;
}

/* Primary Buttons */
.btn-primary {
    color: #fff;
    background-color: #5090b5; /* Muted Teal */
    border-color: #5090b5;
}

/* Focus Ring for Buttons and Form Controls */
/* This overrides the default blue focus ring that might appear on elements like your login form inputs. */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #87ceeb; /* Vibrant Teal Glow */
}

/* Validation Success (Overrides the default green outline) */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #87ceeb; /* Vibrant Teal Accent */
}

/* Validation Error */
.invalid {
    outline: 1px solid #e57373; /* Soft Red for Errors */
}

.validation-message {
    color: #e57373; /* Soft Red for Errors */
}

/* Error UI */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    /* Updated background color for error boundary */
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #e57373;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--color-border-primary);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #87ceeb; /* Vibrant Teal Accent */
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

code {
    color: #e57373; /* Soft Red for code highlights */
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ================================================= */
/* --- BubbleChat: GLOBAL FORM & BUTTON STYLES --- */
/* ================================================= */

/* --- General Form Group Structure (For consistent spacing) --- */
.form-group {
    margin-bottom: 20px;
    width: 100%;
}

/* --- Form Labels --- */
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--color-brand-blue); /* Deep Blue from logo typography */
    font-size: 0.9rem;
}

/* --- Input Fields (The Bubble Look) --- */
/* Target Blazor's .form-control class for styling all inputs */
.form-control {
    color: var(--color-text-primary);
    background-color: var(--color-bg-input);
}

.form-group .form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(135, 206, 235, 0.5); /* Soft teal border */
    border-radius: 15px; /* Pill-like shape */
    font-size: 1rem;
    color: var(--color-text-primary);
    background-color: var(--color-bg-input);
    transition: border-color 0.3s, box-shadow 0.3s;
    box-sizing: border-box;
}

/* --- Autofill Override (prevent browser light background) --- */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--color-bg-input) inset;
    -webkit-text-fill-color: var(--color-text-primary);
    transition: background-color 5000s ease-in-out 0s;
}

/* --- Input Focus/Active Styles (Teal Glow) --- */
.form-group .form-control:focus {
    outline: none;
    border-color: #87ceeb; /* Bright teal */
    box-shadow: 0 0 0 3px rgba(135, 206, 235, 0.4);
}

.btn {
    border-radius: 18px; /* Applied to ALL buttons for the Bubble Shape */
    padding: 8px 20px;   /* Standardized padding for a good pill look */
}

/* --- Primary Button (BubbleChat Teal) --- */
.btn-primary {
    width: 100%;
    padding: 8px 20px;
    background-color: #5090b5;
    color: white;
    border: none;
    border-radius: 18px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
    box-shadow: 0 4px 10px rgba(80, 144, 181, 0.3);
}

.btn-primary:hover {
    background-color: #6aadda;
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(135, 206, 235, 0.4);
}

/* --- Secondary Button (Ghost/Cancel Style) --- */
.btn-secondary {
    width: 100%;
    padding: 8px 20px;
    background-color: transparent;
    color: #87ceeb;
    border: 2px solid rgba(135, 206, 235, 0.5);
    border-radius: 18px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.btn-secondary:hover {
    background-color: rgba(135, 206, 235, 0.1);
    border-color: #87ceeb;
    color: #6aadda;
}

/* --- Validation Error Messages --- */
.validation-message {
    color: #e57373;
    font-size: 0.85rem;
    margin-top: 5px;
    display: block;
}

.validation-summary {
    color: #e57373;
    font-size: 0.85rem;
    margin-top: -10px;
    margin-bottom: 15px;
    list-style-type: none;
    padding-left: 0;
}

/* --- Modal Styles --- */

.modal-form {
    background: linear-gradient(160deg, var(--color-bg-surface), var(--color-bg-page));
    border-radius: 20px; /* Soft, rounded corners for the 'bubble' feel */
    padding: 40px;
    width: 90%;
    max-width: 400px; /* Control the size */
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px var(--color-shadow-card-hover), 0 0 0 10px rgba(135, 206, 235, 0.15);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Subtle, dark translucency */
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Modal Header Styles */
.modal-header {
    text-align: center;
    margin-bottom: 10px;
    border-bottom: 2px solid rgba(135, 206, 235, 0.3);
    padding-bottom: 15px;
}

.modal-header h2 {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--color-brand-blue); /* Deep Blue */
    font-size: 1.8rem;
    font-weight: 600;
}


/* --- Core Bubble Item Styles --- */

.bubble-item {
    /* Enforces a circular shape and fixed size */
    width: 250px;
    height: 250px;
    background: linear-gradient(135deg, var(--color-bg-bubble-tint), var(--color-bg-page)); /* Bubbly gradient */
    border: 3px solid #87ceeb; /* Vibrant Teal */
    border-radius: 50%; /* Makes it circular */
    box-shadow: 0 6px 20px var(--color-shadow-card), inset 0 -4px 12px rgba(135, 206, 235, 0.08);
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    /* Content Layout */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    position: relative; /* Needed for absolute positioning of tooltip */
    overflow: hidden; /* Important to keep the circle shape */
}

.bubble-item:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 28px var(--color-shadow-card-hover), inset 0 -4px 12px rgba(135, 206, 235, 0.12);
}

.bubble-name {
    font-size: 1.5em;
    font-weight: 700;
    color: #4A90E2;
    margin: 15px 0;
    line-height: 1.2;
}

.bubble-tag {
    display: inline-block;
    font-size: 0.8em;
    font-weight: 600;
    color: var(--color-text-primary);
    background: linear-gradient(135deg, var(--color-bg-hover), var(--color-bg-surface));
    padding: 3px 8px;
    border-radius: 12px;
    margin-bottom: 5px;
}

/* --- Placeholder Bubble for Dicsover/Create Bubble --- */
.placeholder-bubble {
    background: var(--color-bg-surface);
    border: 3px dashed rgba(135, 206, 235, 0.5); /* Dashed Light Teal */
    color: #aaa;
}

.placeholder-bubble:hover {
    border-color: #6aadda;
    color: var(--color-brand-blue);
    background: var(--color-bg-bubble-tint);
}

.placeholder-bubble .icon-plus {
    font-size: 3em;
    font-weight: 100;
    margin-bottom: 5px;
    line-height: 1;
}

.placeholder-bubble .bubble-name {
    font-size: 1.2em;
}

.username-border-label {
    position: absolute;
    top: -10px;
    left: 35px;
    z-index: 2;
}

.user-name-text {
    font-size: 0.9em;
    font-weight: 700;
    padding: 2px 4px;

    background-color: var(--color-bg-page);

    color: var(--color-text-primary);
}

.user-color-Blue   { color: #1E88E5 !important; }
.user-color-Green  { color: #43A047 !important; }
.user-color-Purple { color: #8E24AA !important; }
.user-color-Red    { color: #E53935 !important; }
.user-color-Orange { color: #FB8C00 !important; }
.user-color-Yellow { color: #F9A825 !important; }
.user-color-Grey   { color: #757575 !important; }
.user-color-Brown  { color: #6D4C41 !important; }
.user-color-Pink   { color: #D81B60 !important; }
.user-color-Teal   { color: #00897B !important; }

/* User color CSS variables — used for background-color (e.g. member-color-dot) */
:root {
    --user-color-Blue:   #1E88E5;
    --user-color-Green:  #43A047;
    --user-color-Purple: #8E24AA;
    --user-color-Red:    #E53935;
    --user-color-Orange: #FB8C00;
    --user-color-Yellow: #F9A825;
    --user-color-Grey:   #757575;
    --user-color-Brown:  #6D4C41;
    --user-color-Pink:   #D81B60;
    --user-color-Teal:   #00897B;
}

/* --- Citation Indicator Style --- */
.citation-link {
    display: inline-flex;
    align-items: center;
    color: #4A90E2;
    margin-left: 5px;
    padding: 2px;
    border-radius: 4px;
    transition: background 0.2s;
}

.citation-link:hover {
    background: rgba(74, 144, 226, 0.1);
}

.username {
    font-weight: 700;
    font-size: 0.95em;
    margin-right: 8px;
}

.timestamp {
    font-size: 0.8em;
    color: var(--color-text-muted);
}
