﻿/* --- Dark Theme Palette --- */
:root {
    /* Tailwind 'Slate' Dark Palette */
    --color-background: #1f2937;  /* slate-800 */
    --color-card-bg: #374151;     /* slate-700 */
    --color-border: #4b5563;      /* slate-600 */
    --color-text-primary: #f3f4f6;  /* slate-100 */
    --color-text-secondary: #9ca3af; /* slate-400 */
    --color-accent: #007989;

    /* ---
    [NEW] Radzen Global Theme Overrides
    This is the correct way to theme Radzen components.
    --- */

    /* General */
    --rz-body-background-color: var(--color-background);
    --rz-body-color: var(--color-text-primary);
    --rz-card-background-color: var(--color-card-bg);
    --rz-card-border: 1px solid var(--color-border);
    --rz-card-box-shadow: none;

    /* Form Inputs */
    --rz-input-background-color: var(--color-background);
    --rz-input-border-color: var(--color-border);
    --rz-input-color: var(--color-text-primary);
    --rz-input-hover-border-color: var(--color-accent);
    --rz-input-focus-border-color: var(--color-accent);
    --rz-input-focus-box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);

    /* Dropdown */
    --rz-dropdown-background-color: var(--color-background);
    --rz-dropdown-panel-background-color: var(--color-card-bg);
    --rz-dropdown-panel-border: 1px solid var(--color-border);
    --rz-dropdown-item-hover-background-color: var(--color-accent);
    --rz-dropdown-item-hover-color: var(--color-text-primary);

    /* Numeric */
    --rz-spinner-button-background-color: var(--color-border);
    --rz-spinner-button-hover-background-color: var(--color-accent);
    --rz-spinner-button-color: var(--color-text-primary);

    /* Dialogs */
    --rz-dialog-title-background-color: var(--color-card-bg);
    --rz-dialog-title-color: var(--color-text-primary);
    --rz-dialog-title-border-bottom: 1px solid var(--color-border);
    --rz-dialog-content-background-color: var(--color-card-bg);
    --rz-dialog-content-color: var(--color-text-secondary);

    /* Buttons */
    --rz-button-secondary-background-color: var(--color-border);
    --rz-button-secondary-color: var(--color-text-primary);
    --rz-button-secondary-hover-background-color: #5a6573;
    --rz-button-prime-background-color: var(--color-accent);
    --rz-button-prime-color: #fff;

    /* Notification */
    --rz-notification-background-color: var(--color-card-bg);
    --rz-notification-border: 1px solid var(--color-border);
    --rz-notification-color: var(--color-text-primary);
    --rz-notification-icon-color: var(--color-text-secondary);
    --rz-notification-success-background-color: #1e4620;
    --rz-notification-success-border-color: #28a745;
    --rz-notification-warning-background-color: #573a00;
    --rz-notification-warning-border-color: #ffc107;
    --rz-notification-error-background-color: #572020;
    --rz-notification-error-border-color: #dc3545;
    --rz-notification-info-background-color: #003c57;
    --rz-notification-info-border-color: #0dcaf0;

    /* Tooltip */
    --rz-tooltip-background-color: var(--color-background);
    --rz-tooltip-color: var(--color-text-primary);
    --rz-tooltip-border: 1px solid var(--color-border);
}

/* General Layout */
body, html {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    background-color: var(--color-background);
    color: var(--color-text-primary);
}

.main-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.header {
    position: relative;
    background: var(--color-card-bg);
    padding: 0 8px;
    color: var(--color-text-primary);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.logo img {
    height: 24px;
    vertical-align: middle;
}

.content {
    flex-grow: 1;
    padding: 2px 8px 6px 8px;
    overflow-y: auto;
    position: relative;
    background: var(--color-background);
}

.footer {
    text-align: center;
    color: var(--color-text-secondary);
    background: var(--color-card-bg);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
    padding: 2px 24px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1;
}


.footer-refresh-status {
    display: flex;
    align-items: center;
}

/* Spinner for loading indicator */
.spinner {
    display: inline-block;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    width: 14px;
    height: 14px;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Dashboard Grid */
.dashboard-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: baseline;
}

.dashboard-card {
    background: var(--color-card-bg);
    padding: 6px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    min-width: 370px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: fit-content;
    height: fit-content;
}

.fit-container {
    text-align: -webkit-center;
}

.pretty-radzen-grid {
    border-radius: 12px;
}

.dashboard-card.wide {
    flex-basis: 100%;
}

.dashboard-card h3 {
    margin-top: 0;
    font-size: 1.1em;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}

/* --- Spinner Animation --- */
.spinner {
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-left-color: #ffffff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.loading-indicator .spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #2c3e50;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.pretty-table {
    table-layout: auto;
    max-width: 100%;
    width: 100%;
    border-radius: 4px;
    overflow-x: auto;
    background-color: var(--color-card-bg);
    margin: 4px 0;
    font-size: 0.85em;
}

.th-center th {
    text-align: center !important;
}

.pretty-table th {
    font-weight: 600;
    padding: 5px 8px;
    border: none;
    border-bottom: 2px solid var(--color-border);
    border-radius: 0;
    text-align: center;
    white-space: nowrap;
    top: 0;
    background-color: var(--color-background);
    font-size: 0.8em;
    color: var(--color-text-secondary);
}

.pretty-table td {
    padding: 4px 8px;
    text-align: left;
}

.pretty-table a { text-decoration: none; }

.pretty-table tbody tr:nth-child(even) {
    background-color: #2a3a50; /* A slightly lighter dark for rows */
}

.pretty-table tbody tr:hover {
    background-color: var(--color-border);
}

.pretty-table img,
.rz-grid-table img {
    background: #f3f4f6;
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    object-fit: contain;
    box-sizing: border-box;
    width: 40px;
    height: 40px;
}

.form-group {
    padding: 4px;
    flex-grow: 1;
    max-width: 400px;
    border-radius: 8px;
    background-color: var(--color-card-bg);
    border: 1px solid var(--color-border);
    box-shadow: none;
}

/* --- Bootstrap Form Overrides --- */
.form-label {
    color: var(--color-text-secondary);
}

.form-control {
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
}

.form-control:focus {
    background-color: var(--color-background);
    border-color: var(--color-accent);
    color: var(--color-text-primary);
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.25);
}

/* Fix for browser autofill */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus,
.form-control:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--color-background) inset !important;
    -webkit-text-fill-color: var(--color-text-primary) !important;
    border: 1px solid var(--color-border);
}

.framed-label {
    text-align: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-primary); /* <-- CHANGED from --color-text-secondary */
    padding-bottom: 8px;
    margin: 4px 4px 10px 4px;
    border-bottom: 1px solid var(--color-border);
    width: auto;
}

.header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: center;
    font-size: 1.1em;
}

.header-stat-item {
    display: flex;
    gap: 8px;
    align-items: baseline;
}

.dashboard-header-stat-item {
    display: flex;
    gap: 8px;
    align-items: center;
}


/* Page loading overlay */
.page-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(40, 49, 60, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.loading-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    width: 100%;
}

.widgets-container {
    display: flex;
    gap: 24px;
    padding: 8px;
    min-height: 250px;
    justify-content: space-around;
    flex-wrap: wrap;
    flex-grow: 1;
}

.widget-item {
    flex-shrink: 0;
    align-content: center;
    width: max-content;
    background-color: #bfbfbf00;
    border-radius: 8px;
    padding: 1px;
    min-width: 350px;
    max-width: 370px;
}

.widgets-container::-webkit-scrollbar {
    height: 8px;
}

.widgets-container::-webkit-scrollbar-track {
    background: #1f2935;
    border-radius: 4px;
}

.widgets-container::-webkit-scrollbar-thumb {
    background-color: #567;
    border-radius: 4px;
}

/* Now Playing containers */
.now-playing-item {
    flex: 2 1 600px;
    display: flex;
    flex-direction: column;
    min-width: 370px;
    max-width: 850px;
    font-size: small;
}

.top-songs-item {
    flex: 1 1 372px;
    display: flex;
    flex-direction: column;
    min-width: 372px;
    background: transparent;
    border: none;
    border-radius: 0;
}

.bottom-content-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin-top: 12px;
    overflow-x: auto;
}

.chart-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: var(--color-card-bg);
    border-radius: 8px;
}

.chart-wrapper {
    position: relative;
    flex-grow: 1;
}

.apexcharts-toolbar {
    z-index: 0 !important;
}

.error-message {
    color: red;
    font-weight: bold;
    padding: 10px;
    border: 1px solid red;
    background-color: #ffe6e6;
    border-radius: 4px;
    margin: 10px 0;
}

.no-data-message {
    color: #ff660a;
    font-weight: bold;
    padding: 10px;
    border: 1px solid #f7ff00;
    background-color: #ffe6e6;
    border-radius: 4px;
    margin: 10px 0;
}

/* Summary Card */
.stats-summary-list {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    justify-content: space-evenly;
}

.stats-summary-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.95em;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
    flex-direction: column;
    align-items: center;
}

.stats-summary-item:last-child {
    border-bottom: none;
}

.stats-summary-label {
    color: var(--color-text-secondary);
    font-weight: 500;
    text-align: center;
}

.stats-summary-value {
    font-weight: 700;
    font-size: 1.5em;
    color: var(--color-text-primary);
    width: 100%;
    text-align: center;
}

.summary-icon {
    color: var(--color-accent);
    font-size: 32px;
}

.dashboard-header-icon-container {
    text-align: center;
    height: 24px; 
    width: 24px; 
    margin-right: 4px;
}

.dashboard-summary-icon {
    color: var(--color-accent);
    font-size: 24px;
}

/* Grid width helpers */
.max-width {
    max-width: 1200px;
}
.min-width-1400 {
    min-width: 1400px;
}
.min-width-1200 {
    min-width: 1200px;
}
.min-width-1000 {
    min-width: 1000px;
}

/* Login Page */
.login-logo-container {
    text-align: center;
    margin-bottom: 16px;
    background: var(--color-accent);
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    justify-content: center;
    align-content: center;
    align-items: center;
    padding: 8px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.login-text {
    text-align: end;
    width: 100%;
    padding-right: 4px;
    align-content: center;
    color: var(--color-text-primary);
}

/* Bootstrap Alert & Button Overrides */
.alert-danger {
    color: #f8d7da;
    background-color: #572020;
    border-color: #dc3545;
}

.btn-primary {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

.btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* General Card Override */
.card {
    background-color: var(--color-card-bg);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
}

.card-body {
    padding: 24px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--color-background);
}

::-webkit-scrollbar-thumb {
    background-color: var(--color-border);
    border-radius: 10px;
    background-clip: padding-box;
    border: 3px solid transparent;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-text-secondary);
}

/* Page Summary Bar */
.header-summary {
    border-bottom: 1px solid var(--color-border);
    box-shadow: none;
    margin: 4px;
    background: var(--color-card-bg);
    border-radius: 4px;
}
.stat-label {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.dashboard-stat-label {
    font-weight: 600;
    color: var(--color-text-secondary);
    min-width: max-content;
    font-size: medium;
}

.stat-value {
    font-weight: bold;
    color: var(--color-text-primary);
    font-size: 1.2em;
}

/* --- Modal Backdrop Blur & Darken --- */
.rz-dialog-mask {
    backdrop-filter: blur(4px);
    background-color: rgb(191 191 191 / 76%); /* Darker overlay */
}

/* --- Darken Radzen Dialog Content --- */
.rz-dialog-content {
    background-color: var(--color-background); /* Use the dark background */
}

/* --- Darken Custom GroupName Prompt --- */
/* This targets the custom prompt from your screenshot */
.group-prompt-container {
    background-color: var(--color-background);
}

/* Style for the "additional controls" slot in the UserSettingsBar */
.user-bar-control-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-bar-control-group label {
    font-weight: 600;
    color: var(--color-text-secondary);
}

.user-bar-select {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid var(--color-border);
    background-color: var(--color-background);
    color: var(--color-text-primary);
    font-weight: 500;
}

.user-bar-select:hover {
    border-color: var(--color-accent);
}

.flex-row-container {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-wrap: wrap;
}

.rz-tabview-panel {
    padding: 0;
}

.rz-tabview-panels {
    background: transparent;
    padding: 4px;
}

.rz-tabview-selected {
    background: #1f2937 !important;
    border-radius: 6px !important;
    box-shadow: 0 1px 4px 1px #0000009e;
}

.rz-tabview-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text-primary);
}

ul[role=tablist] {
    flex-wrap: wrap;
}

.apexcharts-point-annotations:hover image {
    opacity: 0.1;
    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.apexcharts-point-annotations image {
    clip-path: circle(48%);
    opacity: 0.9;
    transition: transform 0.2s ease-in-out;
    shape-rendering: geometricPrecision;

    z-index: 999;
    
}

.apexcharts-point-annotations image:hover {
    opacity: 1 !important;
    clip-path: none;
    transform: scale(1.8);
    z-index: 1001;
    /* --- THE FIX --- */
    /* This forces the center calculation to be relative to the image itself, not the chart */
    transform-box: fill-box;
    /* This sets the anchor point for the scale to that center */
    transform-origin: center;
}

/* Tooltip Content Styling */
.tooltip-header {
    margin-bottom: 8px;
    border-bottom: 1px solid #4b5563; /* slate-600 */
    padding-bottom: 4px;
    font-weight: bold;
    color: #f3f4f6; /* slate-100 */
    font-size: 1.1em;
}

.tooltip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
    gap: 15px; /* Space between name and value */
}

.tooltip-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tooltip-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.tooltip-series-name {
    color: #9ca3af; /* slate-400 */
    font-size: 0.9em;
}

.tooltip-value {
    color: #fff;
    font-weight: bold;
}

/* --- Mobile Override for Radzen Dropdowns (Station Selector) --- */
@media (max-width: 768px) {
    /* Target the popup panel generated by RadzenDropDown */
    .rz-dropdown-panel {
        /* Override JS-calculated positioning */
        position: fixed !important;

        /* Force vertical position */
        top: 40px !important;

        /* Stick to left */
        left: 10px !important;

        /* Full width minus margins */
        width: calc(100vw - 20px) !important;
        min-width: unset !important;

        /* Constrain max width */
        max-width: 370px !important;

        /* Enable scrolling */
        max-height: 80vh !important;

        /* Visual separation */
        box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
        border: 1px solid var(--color-accent) !important;
        z-index: 2000 !important;
    }
}

/* --- Blazor Reconnect Modal Styling --- */

#components-reconnect-modal {
    /* Full screen overlay */
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10000; /* Higher than Radzen dialogs */

    /* Theme colors */
    background-color: rgba(31, 41, 55, 0.95); /* Matches --color-background with opacity */
    backdrop-filter: blur(5px); /* Blur the content behind */
    color: var(--color-text-primary);

    /* Layout */
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: inherit;
}

/* Show the modal when Blazor applies these classes */
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}

/* Hide specific sections by default */
#components-reconnect-modal .show,
#components-reconnect-modal .failed,
#components-reconnect-modal .rejected {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background-color: var(--color-card-bg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    min-width: 300px;
}

/* Show specific content based on state */
#components-reconnect-modal.components-reconnect-show .show {
    display: flex;
}

#components-reconnect-modal.components-reconnect-failed .failed {
    display: flex;
}

#components-reconnect-modal.components-reconnect-rejected .rejected {
    display: flex;
}

/* Typography */
#components-reconnect-modal p {
    margin: 0 0 1rem 0;
    font-weight: 600;
    font-size: 1.1rem;
}

/* Button Styling (matches your .btn-primary) */
#components-reconnect-modal button.reload {
    background-color: var(--color-accent);
    color: white;
    border: 1px solid var(--color-accent);
    padding: 8px 24px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

#components-reconnect-modal button.reload:hover {
    background-color: #0056b3; /* Darker accent on hover */
    box-shadow: 0 0 8px rgba(0, 121, 137, 0.5);
}

/* Reuse your existing spinner logic but ensure visibility */
#components-reconnect-modal .spinner {
    display: block;
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--color-accent);
}

/* --- Show Analytics Page Specific Styles --- */

/* 1. The Main Container */
.analytics-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 2. The Header Bar */
.analytics-header {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    background-color: var(--color-card-bg);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-info {
    margin-left: auto;
    align-self: center;
    color: var(--color-text-primary);
    font-size: 1.1em;
}

/* 3. THE GRID LAYOUT (This replaces the old .analytics-grid) */
.analytics-dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    gap: 16px;
    width: 100%;
}

/* 4. The Card Wrapper */
.analytics-dashboard-grid .dashboard-card {
    /* Reset inherited width behaviors */
    width: 100%;
    min-width: 0; /* Critical for CSS Grid to allow content shrinking */
    height: auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;

    /* Inherit your global card styles */
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 6px;
}

/* 5. The Wide Card (Top Row) */
.analytics-dashboard-grid .dashboard-card.wide {
    grid-column: span 2; /* Spans both columns */
}

/* 6. The Chart Container */
.chart-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden; /* Prevents SVG overflow */
}

/* 7. The Stats Footer (Now sits below the chart) */
.stat-footer {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--color-border);
    font-size: 0.9em;
    text-align: center;
    background-color: var(--color-card-bg);
    z-index: 10;
}

.stat-footer strong {
    color: var(--color-accent);
    font-size: 1.2em;
}

/* 8. Mobile Responsiveness */
@media (max-width: 1000px) {
    .analytics-dashboard-grid {
        grid-template-columns: 1fr; /* Switch to single column */
    }

    .analytics-dashboard-grid .dashboard-card.wide {
        grid-column: span 1;
    }
}

.no-data, .info-message {
    text-align: center;
    color: var(--color-text-secondary);
    margin-top: 40px;
    font-size: 1.1em;
}