/* ============================================
   BASE STYLES
   Using CSS variables with fallbacks
   BrandingService will override these
   ============================================ */
html, body {
    font-family: var(--tenant-font-family, 'Helvetica Neue', Helvetica, Arial, sans-serif);
    color: var(--tenant-text, #212529);
    background-color: var(--tenant-background, #ffffff);
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--tenant-primary, #0071c1);
}

a:hover, .btn-link:hover {
    color: var(--tenant-primary-hover, #005a9e);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem var(--tenant-primary, #258cfb);
}

.content {
    padding-top: 1.1rem;
}

/* Allow wide content (data tables) to scroll horizontally */
.mud-main-content {
    overflow-x: auto !important;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#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 {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5z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MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

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

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto 0 auto;
}

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

        .loading-progress circle:last-child {
            stroke: var(--tenant-primary, #1b6ec2);
            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: #c02d76;
}

/* Login page logo */
.login-logo {
    height: 64px;
    max-width: 100%;
}

/* Side nav / header logo */
.nav-logo {
    height: 36px;
    max-width: 100%;
}

/* ============================================
   DARK SIDEBAR NAV LINK OVERRIDES
   MudBlazor's hover styles override scoped ::deep
   so these must live in global CSS
   ============================================ */
.mud-drawer .mud-nav-link {
    color: rgba(255, 255, 255, 0.85) !important;
}

.mud-drawer .mud-nav-link *  {
    color: inherit !important;
}

.mud-drawer .mud-nav-link:hover,
.mud-drawer .mud-nav-link:hover * {
    color: #ffffff !important;
    background-color: transparent;
}

.mud-drawer .mud-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.10) !important;
}

.mud-drawer .mud-nav-link.active,
.mud-drawer .mud-nav-link.active * {
    color: #ffffff !important;
}

.mud-drawer .mud-nav-link.active {
    background-color: rgba(255, 255, 255, 0.18) !important;
}

.mud-drawer .mud-nav-link .mud-nav-link-icon {
    color: rgba(255, 255, 255, 0.7) !important;
}

.mud-drawer .mud-nav-link:hover .mud-nav-link-icon,
.mud-drawer .mud-nav-link.active .mud-nav-link-icon {
    color: #ffffff !important;
}

/* ============================================
   CHECK FOR UPDATES BUTTON
   Matches sidebar navigation styling
   ============================================ */
.nav-link.check-updates-btn {
    color: #d7d7d7; /* Light gray text to match other nav items */
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

    .nav-link.check-updates-btn:hover {
        color: #ffffff; /* White on hover */
        background-color: rgba(255, 255, 255, 0.1); /* Subtle highlight */
    }

    .nav-link.check-updates-btn:active,
    .nav-link.check-updates-btn:focus {
        color: #ffffff;
        background-color: rgba(255, 255, 255, 0.15);
        box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
    }

/* Description text styling */
.check-updates-description {
    color: #999999; /* Muted gray for description */
    font-size: 0.75rem;
    line-height: 1.3;
}

/* ============================================
   DASHBOARD GRID STYLES (Gridstack)
   Phase 9B: Refined card elevation, clean headers
   ============================================ */

/* Grid Container */
.grid-stack {
    background: transparent;
    min-height: 200px;
    overflow: visible;
}

/* Individual Grid Items */
.grid-stack-item {
    transition: none;
}

/* The content wrapper — flush tiles (LeadConnector style), padding inside */
.grid-stack-item > .grid-stack-item-content {
    background: var(--tenant-surface, #ffffff);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: absolute;
    inset: 0;
    transition: box-shadow 0.2s ease;
}

/* Hover: subtle lift */
.grid-stack-item:hover > .grid-stack-item-content {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Widget Cards inside Grid Items */
.grid-stack-item .card {
    height: 100%;
    margin-bottom: 0 !important;
    border: none;
    box-shadow: none;
}

.grid-stack-item .card-body {
    overflow: auto;
    flex: 1;
    min-height: 0;
}

/* Edit Mode — slightly more prominent hover */
.grid-stack.edit-mode .grid-stack-item:hover > .grid-stack-item-content {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
}

/* Widget Header — clean, minimal */
.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--tenant-surface-border, rgba(0, 0, 0, 0.06));
    background-color: transparent;
    cursor: grab;
    user-select: none;
    transition: background-color 0.15s ease;
    flex-shrink: 0;
}

.widget-header:hover {
    background-color: var(--tenant-primary-light, rgba(0, 0, 0, 0.02));
}

.widget-header:active {
    cursor: grabbing;
    background-color: var(--tenant-primary-light, rgba(0, 0, 0, 0.04));
}

/* When layout is locked, default cursor */
.grid-stack:not(.edit-mode) .widget-header {
    cursor: default;
}

.grid-stack:not(.edit-mode) .widget-header:hover {
    background-color: transparent;
}

.widget-header h6 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--tenant-text, #374151);
}

.widget-header .widget-actions {
    display: flex;
    gap: 0.25rem;
}

/* Drag Handle — hidden by default, visible on hover */
.widget-drag-handle {
    cursor: move;
    padding: 0.625rem 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.widget-drag-handle .drag-icon {
    color: transparent;
    font-size: 0.75rem;
    transition: color 0.2s ease;
}

/* Show drag grip on hover */
.grid-stack-item:hover .widget-drag-handle .drag-icon {
    color: var(--tenant-text-light, #9ca3af);
}

/* In edit mode, always show drag grip */
.grid-stack.edit-mode .widget-drag-handle .drag-icon {
    color: var(--tenant-primary, #6366f1);
}

.grid-stack.edit-mode .widget-drag-handle {
    background-color: transparent;
}

.widget-drag-handle:hover {
    background-color: transparent;
}

/* Hide drag handle when not in edit mode */
.grid-stack:not(.edit-mode) .drag-icon {
    display: none;
}

/* Dragging State */
.grid-stack-item.dragging {
    z-index: 1000 !important;
    opacity: 0.95;
}

.grid-stack-item.dragging > .grid-stack-item-content {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 8px 16px rgba(0, 0, 0, 0.1) !important;
    transform: scale(1.02);
    border-color: var(--tenant-primary, #6366f1) !important;
}

/* Resizing State */
.grid-stack-item.resizing {
    z-index: 1000 !important;
}

.grid-stack-item.resizing > .grid-stack-item-content {
    border-color: var(--tenant-primary, #6366f1) !important;
}

/* Placeholder */
.grid-stack-placeholder > .placeholder-content {
    background-color: var(--tenant-primary-light, rgba(99, 102, 241, 0.06)) !important;
    border: 2px dashed var(--tenant-primary, rgba(99, 102, 241, 0.25)) !important;
    border-radius: 12px;
}

/* Resize Handles */
.ui-resizable-handle {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.grid-stack-item:hover .ui-resizable-handle {
    opacity: 1;
}

.ui-resizable-se {
    background: linear-gradient(135deg, transparent 50%, var(--tenant-primary, rgba(99, 102, 241, 0.2)) 50%);
    width: 14px;
    height: 14px;
    border-radius: 0 0 12px 0;
}

.ui-resizable-sw,
.ui-resizable-ne,
.ui-resizable-nw {
    display: none !important;
}

.ui-resizable-e,
.ui-resizable-w {
    width: 8px;
    background-color: transparent;
}

.ui-resizable-n,
.ui-resizable-s {
    height: 8px;
    background-color: transparent;
}

.grid-stack-item:hover .ui-resizable-se {
    background: linear-gradient(135deg, transparent 50%, var(--tenant-primary, rgba(99, 102, 241, 0.35)) 50%);
}

/* Widget Size Preset Buttons */
.widget-size-presets {
    display: none;
}

.grid-stack.edit-mode .widget-size-presets {
    display: flex;
    gap: 0.25rem;
}

.widget-size-presets .btn {
    padding: 0.125rem 0.375rem;
    font-size: 0.7rem;
}

/* Edit Mode Toggle */
.edit-mode-btn {
    transition: all 0.2s ease;
}

.edit-mode-btn.active {
    background-color: var(--tenant-primary, #6366f1) !important;
    color: #fff !important;
    border-color: var(--tenant-primary, #6366f1) !important;
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .grid-stack > .grid-stack-item {
        width: 100% !important;
        left: 0 !important;
    }

    .drag-icon,
    .widget-size-presets {
        display: none !important;
    }

    .widget-header {
        cursor: default;
    }

    .grid-stack-item > .grid-stack-item-content {
        border-radius: 8px;
    }
}

/* Summary Cards Widget */
.summary-cards-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.5rem;
    padding: 0.75rem;
    flex: 1;
    align-content: center;
    overflow: hidden;
    min-width: 0;
}

@media (max-width: 1400px) {
    .summary-cards-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 0.35rem;
    }
}

@media (max-width: 1199.98px) {
    .summary-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767.98px) {
    .summary-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Summary Card Item */
.summary-card-item {
    text-align: center;
    padding: 0.5rem 0.375rem;
    border-radius: 10px;
    background-color: var(--tenant-background, #f9fafb);
    min-width: 0;
    overflow: hidden;
    border: 1px solid transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.summary-card-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.summary-card-item.primary {
    background-color: rgba(var(--tenant-primary-rgb, 99, 102, 241), 0.06);
    border-color: rgba(var(--tenant-primary-rgb, 99, 102, 241), 0.12);
}

.summary-card-item.success {
    background-color: rgba(16, 185, 129, 0.06);
    border-color: rgba(16, 185, 129, 0.12);
}

.summary-card-item.warning {
    background-color: rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.12);
}

.summary-card-item.danger {
    background-color: rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.12);
}

.summary-card-item .label {
    font-size: 0.65rem;
    color: var(--tenant-text-light, #6b7280);
    margin-bottom: 0.125rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.summary-card-item .value {
    font-size: 1.75rem;
    font-weight: 300;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.5px;
}

/* Value colors using tenant palette */
.summary-card-item .value.text-primary {
    color: var(--tenant-primary, #4f46e5) !important;
}

.summary-card-item .value.text-info {
    color: #0891b2 !important;
}

.summary-card-item .value.text-warning {
    color: #d97706 !important;
}

.summary-card-item .value.text-danger {
    color: #dc2626 !important;
}

.summary-card-item .value.text-success {
    color: #059669 !important;
}

/* Chart container within grid items */
.chart-container {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 100px;
    padding: 0.75rem;
    overflow: hidden;
}

.chart-container canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Loading overlay */
.grid-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

/* Hidden widget */
.widget-hidden {
    display: none !important;
}

/* ============================================
   HERO COMMAND STRIP
   Phase 9A: Fixed section above GridStack
   ============================================ */

.dashboard-hero {
    position: relative;
    border-radius: 16px;
    padding: 1.5rem 1.75rem 1.25rem;
    margin-bottom: 1.25rem;
    overflow: hidden;
    background: var(--tenant-surface, #ffffff);
    border: 1px solid rgba(0, 0, 0, 0.04);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Connected-dots canvas behind hero content */
.dashboard-hero .hero-canvas-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    z-index: 0;
}

/* All hero content sits above the canvas */
.dashboard-hero .hero-content {
    position: relative;
    z-index: 1;
    pointer-events: none;
}

.dashboard-hero .hero-content > * {
    pointer-events: auto;
}

/* Greeting */
.hero-greeting {
    font-size: 1.375rem;
    font-weight: 300;
    color: var(--tenant-text, #111827);
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.hero-greeting strong {
    font-weight: 600;
}

/* Hero metric cards */
.hero-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.hero-metric-card {
    background: var(--tenant-background, #f9fafb);
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hero-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hero-metric-card .metric-value {
    font-size: 1.75rem;
    font-weight: 300;
    color: var(--tenant-text, #111827);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.hero-metric-card .metric-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tenant-text-light, #6b7280);
    margin-top: 0.125rem;
}

.hero-metric-card .metric-delta {
    font-size: 0.7rem;
    font-weight: 600;
    margin-top: 0.125rem;
}

.hero-metric-card .metric-delta.positive {
    color: #059669;
}

.hero-metric-card .metric-delta.negative {
    color: #dc2626;
}

.hero-metric-card .metric-delta.neutral {
    color: var(--tenant-text-light, #9ca3af);
}

/* Next event card */
.hero-next-event {
    background: linear-gradient(135deg, var(--tenant-primary, #6366f1), var(--tenant-primary-hover, #4f46e5));
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--tenant-button-text, #ffffff);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
}

.hero-next-event:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(var(--tenant-primary-rgb, 99, 102, 241), 0.3);
    color: var(--tenant-button-text, #ffffff);
    text-decoration: none;
}

.hero-next-event .next-event-label {
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.hero-next-event .next-event-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin-top: 0.125rem;
}

.hero-next-event .next-event-meta {
    font-size: 0.75rem;
    opacity: 0.85;
    margin-top: 0.25rem;
}

/* Oracle insight ticker */
.hero-oracle-ticker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    min-height: 1.5rem;
}

.hero-oracle-ticker .ticker-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tenant-primary, #6366f1), var(--tenant-primary-hover, #4f46e5));
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-oracle-ticker .ticker-icon i {
    font-size: 0.6rem;
    color: #fff;
}

.hero-oracle-ticker .ticker-text {
    font-size: 0.8rem;
    color: var(--tenant-text-light, #6b7280);
    font-style: italic;
    transition: opacity 0.4s ease;
    line-height: 1.3;
}

.hero-oracle-ticker .ticker-text.fading {
    opacity: 0;
}

.hero-oracle-ticker .hero-embed-link {
    flex-shrink: 0;
    font-size: 0.7rem;
    color: #C4C9D2;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: color 0.15s ease;
    text-decoration: none;
    margin-left: auto;
}

.hero-oracle-ticker .hero-embed-link:hover {
    color: #6366F1;
}

@media (max-width: 767.98px) {
    .dashboard-hero {
        padding: 1rem 1.25rem;
        border-radius: 12px;
    }

    .hero-greeting {
        font-size: 1.125rem;
    }

    .hero-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero-metric-card .metric-value {
        font-size: 1.375rem;
    }
}

