/* Custom MudBlazor Theme Enhancements */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=PT+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap');
/* Cool Linen light-theme fonts: Cabin (body) + Fraunces (headings) */
@import url('https://fonts.googleapis.com/css2?family=Cabin:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Fraunces:opsz,wght@9..144,500;9..144,600&display=swap');

body {
    font-family: 'PT Sans', sans-serif;
}

/* ===== Cool Linen typography — light theme only ===== */
[data-theme="light"] html,
[data-theme="light"] body {
    font-family: 'Cabin', system-ui, sans-serif;
}

[data-theme="light"] {
    --mud-typography-default-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-body1-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-body2-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-button-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-caption-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-subtitle1-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-subtitle2-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-overline-family: 'Cabin', system-ui, sans-serif;
    --mud-typography-h1-family: 'Fraunces', Georgia, serif;
    --mud-typography-h2-family: 'Fraunces', Georgia, serif;
    --mud-typography-h3-family: 'Fraunces', Georgia, serif;
    --mud-typography-h4-family: 'Fraunces', Georgia, serif;
    --mud-typography-h5-family: 'Fraunces', Georgia, serif;
    --mud-typography-h6-family: 'Fraunces', Georgia, serif;
}

[data-theme="light"] h1, [data-theme="light"] h2, [data-theme="light"] h3,
[data-theme="light"] h4, [data-theme="light"] h5, [data-theme="light"] h6,
[data-theme="light"] .mud-typography-h1, [data-theme="light"] .mud-typography-h2,
[data-theme="light"] .mud-typography-h3, [data-theme="light"] .mud-typography-h4,
[data-theme="light"] .mud-typography-h5, [data-theme="light"] .mud-typography-h6 {
    font-family: 'Fraunces', Georgia, serif;
}

/* Preserve the brand/logo wordmark display fonts — never override with Fraunces.
   .welcome-title (ASKSWAMYS.AI), .ayra-brand-title, .search-logo-title use Anton;
   .ayra-brand-subtitle uses Roboto Condensed. Higher specificity wins over the heading rule above. */
[data-theme="light"] .welcome-title,
[data-theme="light"] .ayra-brand-title,
[data-theme="light"] .search-logo-title {
    font-family: 'Anton', sans-serif;
}

[data-theme="light"] .ayra-brand-subtitle {
    font-family: 'Roboto Condensed', sans-serif;
}

/* AppBar Enhancements */
.mud-appbar {
    background: var(--appbar-bg) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.mud-appbar .mud-text {
    color: var(--appbar-text) !important;
    font-weight: 600;
}

/* Drawer Enhancements */
.mud-drawer {
    background: var(--drawer-bg) !important;
    border-right: 1px solid var(--border-color) !important;
}

.mud-drawer-header {
    background: var(--drawer-header-bg, var(--drawer-bg)) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

/* Navigation Links */
.mud-nav-link {
    border-radius: 8px !important;
    margin-bottom: 4px;
    transition: all 0.5s ease-in-out;
}

.mud-nav-link:hover {
    background: var(--bg-hover) !important;
    transform: translateX(4px);
}

.mud-nav-link.active {
    background: var(--surface-hover) !important;
    border-left: 3px solid var(--accent-primary);
}

.mud-nav-group .mud-nav-group-header {
    color: var(--text-secondary) !important;
    font-weight: 500;
    padding: 8px 16px;
}

/* Custom Chip Styling */
.user-chip {
    background: var(--surface-color) !important;
    color: var(--accent-primary) !important;
    border: 1px solid var(--border-color) !important;
}

/* Menu and Button Enhancements */
/* ===== Button hover ====================================================
   MudBlazor 8 emits a single combined class per filled button —
   .mud-button-filled-{color} — NOT .mud-button-filled.mud-button-{color}.
   The old per-colour rules used the latter and never matched (dead rules);
   buttons fell through to MudBlazor's native :hover, which paints
   var(--mud-palette-{color}-darken). Those *-darken vars are undefined under
   our custom palettes, so the hover background resolved to transparent and
   read as BLACK over the page. Filled icon buttons carry the same
   .mud-button-filled-{color} class, so the colour-mix rules below cover them
   too. Outlined/text hovers are handled further down. ==================== */

/* Icon button hover — shade the rendered colour via filter (brighten in dark,
   deepen in light). This works for ANY icon button (plain, or filled/coloured)
   and can never force it to a flat grey/transparent. MudBlazor's own subtle
   overlay still gives plain icon buttons their neutral hover feedback. */
.mud-icon-button:hover:not(:disabled) {
    filter: brightness(1.12);
    transition: filter 0.2s ease;
}
[data-theme="light"] .mud-icon-button:hover:not(:disabled) {
    filter: brightness(0.92);
}

/* Filled buttons — re-assert the base palette colour on hover (so MudBlazor's
   native :hover, which paints the undefined *-darken vars, can't take over) and
   shade it in-family with filter. No color-mix, so it resolves in every browser. */
.mud-button-filled-primary:hover:not(:disabled)   { background-color: var(--mud-palette-primary)   !important; }
.mud-button-filled-secondary:hover:not(:disabled) { background-color: var(--mud-palette-secondary) !important; }
.mud-button-filled-tertiary:hover:not(:disabled)  { background-color: var(--mud-palette-tertiary)  !important; }
.mud-button-filled-info:hover:not(:disabled)      { background-color: var(--mud-palette-info)      !important; }
.mud-button-filled-success:hover:not(:disabled)   { background-color: var(--mud-palette-success)   !important; }
.mud-button-filled-warning:hover:not(:disabled)   { background-color: var(--mud-palette-warning)   !important; }
.mud-button-filled-error:hover:not(:disabled)     { background-color: var(--mud-palette-error)     !important; }
.mud-button-filled-dark:hover:not(:disabled)      { background-color: var(--mud-palette-dark)      !important; }

[class*="mud-button-filled-"]:hover:not(:disabled) { filter: brightness(1.12); transition: filter 0.15s ease; }
[data-theme="light"] [class*="mud-button-filled-"]:hover:not(:disabled) { filter: brightness(0.92); }

/* ===== Theme-variant visibility utilities ==============================
   Render both a dark- and a light-variant element (e.g. a logo image pair) and
   let CSS show the correct one for the active theme. This swaps INSTANTLY on a
   theme switch via the <html data-theme> attribute — with no C# re-render — so
   it avoids the stale-variant bug where a component that reads
   ThemeService.IsDarkMode keeps the old image/colour until it happens to
   re-render. Dark is the default (shown when no data-theme is set). */
[data-theme="light"] .theme-only-dark { display: none !important; }
[data-theme="dark"] .theme-only-light,
:root:not([data-theme]) .theme-only-light { display: none !important; }

/* Outlined buttons - lighter border and background on hover */
.mud-button-outlined:hover:not(:disabled) {
    border-color: currentColor !important;
    opacity: 0.8 !important;
}

/* Text buttons - lighter background on hover */
.mud-button-text:hover:not(:disabled) {
    background-color: rgba(156, 163, 175, 0.1) !important;
    filter: brightness(1.1) !important;
}

/* Light theme - use darker hover for text buttons */
[data-theme="light"] .mud-button-text:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 0.08) !important;
    filter: brightness(0.98) !important;
}

.mud-menu .mud-list-item:hover {
    background: var(--bg-hover) !important;
}

/* Custom Divider */
.custom-divider {
    background-color: var(--border-color) !important;
    margin: 8px 0;
}

/* Main Content Area */
.mud-main-content {
    background: var(--bg-primary) !important;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-default);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* Icon Button Enhancements */
.mud-icon-button {
    transition: all 0.5s ease-in-out;
}

.mud-icon-button:hover:not(:disabled) {
    background: var(--bg-hover) !important;
    transform: scale(1.1);
    filter: brightness(1.15) !important;
}

/* Light theme - use warm linen hover background for icon buttons */
[data-theme="light"] .mud-icon-button:hover:not(:disabled) {
    background: var(--bg-hover) !important;
    filter: brightness(0.97) !important;
}

/* Logo and Branding */
.brand-text {
    background: linear-gradient(45deg, #9ca3af, #6b7280);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

/* Cool Linen light theme - gold brand gradient */
[data-theme="light"] .brand-text {
    background: linear-gradient(45deg, #a9761f, #936414);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Button Palette dark theme - gold brand gradient (was old grey) */
[data-theme="dark"] .brand-text,
:root:not([data-theme]) .brand-text {
    background: linear-gradient(45deg, #e0a536, #c08f2a);
    -webkit-background-clip: text;
    background-clip: text;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .mud-appbar .mud-text {
        font-size: 1rem;
    }

    .mud-drawer {
        width: 240px !important;
    }
    
    /* Ensure proper spacing in mobile appbar */
    .mud-appbar .mud-stack {
        gap: 4px !important;
    }
    
    /* Hide user chip on very small screens */
    .user-chip {
        max-width: 120px;
        overflow: hidden;
    }
}

@media (max-width: 480px) {
    /* On very small screens, hide the user chip completely */
    .user-chip {
        display: none !important;
    }
    
    /* Reduce spacing even more */
    .mud-appbar .mud-stack {
        gap: 2px !important;
    }
}

/* Animation Enhancements */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Focus States */
.mud-nav-link:focus,
.mud-icon-button:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Progress Circular spinner colour scheme:
   • Slate, default Dark, and Cool Linen (light, no palette) -> logo blue
   • all other palettes (Warm Paper, Sand & Ink, Midnight Oak, Espresso) -> accent */
.mud-progress-circular {
    color: var(--accent-primary) !important;
}

/* Logo-blue spinner for Slate, default Dark, and Cool Linen */
:root:not([data-theme]) .mud-progress-circular,
[data-theme="dark"]:not([data-palette]) .mud-progress-circular,
[data-theme="dark"][data-palette="slate"] .mud-progress-circular,
[data-theme="light"]:not([data-palette]) .mud-progress-circular {
    color: var(--logo-blue) !important;
}

/* Snackbar Success Color - More vibrant green in light mode */
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-snackbar-content,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-snackbar-content-wrapper {
    background-color: var(--success-color) !important; /* Cool Linen forest green */
}

[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-icon-root,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success i,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-snackbar-icon {
    color: white !important;
}

[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-snackbar-message,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-snackbar-message *,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-typography {
    color: white !important;
}

[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-snackbar-close-button,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-success .mud-icon-button {
    color: white !important;
}

/* Snackbar Error Color - use theme variable in light mode */
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-snackbar-content,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-snackbar-content-wrapper {
    background-color: var(--error-color) !important;
}

[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-icon-root,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error i,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-snackbar-icon {
    color: #ffffff !important;
}

[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-snackbar-message,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-snackbar-message *,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-typography {
    color: #ffffff !important;
}

[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-snackbar-close-button,
[data-theme="light"] .mud-snackbar.mud-snackbar-filled-error .mud-icon-button {
    color: #ffffff !important;
}

/* Filled Error Alerts - use theme variable in light mode */
[data-theme="light"] .mud-alert.mud-alert-filled-error,
[data-theme="light"] .mud-alert.mud-alert-filled-error .mud-alert-message {
    background-color: var(--error-color) !important;
    color: #ffffff !important;
}

[data-theme="light"] .mud-alert.mud-alert-filled-error .mud-alert-icon {
    color: #ffffff !important;
}

/* Light theme: ensure white text on vibrant filled Success/Error buttons and chips */
[data-theme="light"] .mud-button-filled.mud-button-success,
[data-theme="light"] .mud-chip-filled.mud-chip-success {
    color: #ffffff !important;
}

[data-theme="light"] .mud-button-filled.mud-button-error,
[data-theme="light"] .mud-chip-filled.mud-chip-error {
    color: #ffffff !important;
}

/* SparkleIcon animation — keyframes live here (global) so the name is
   never mangled by component-scoped CSS bundling */
@keyframes sparkle-color-shift {
    0%   { fill: orange;       stroke: orange; }
    20%  { fill: purple;       stroke: purple; }
    40%  { fill: indigo;       stroke: indigo; }
    60%  { fill: mediumpurple; stroke: mediumpurple; }
    80%  { fill: greenyellow;  stroke: greenyellow; }
    100% { fill: orange;       stroke: orange; }
}