/* ========================================= */
/* RESPARKE ANALYTICS - COMPLETE STYLES     */
/* Updated with New Dashboard Controls      */
/* ========================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 80px 20px 40px 20px;
    overflow-x: hidden;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* ========================================= */
/* HEADER                                    */
/* ========================================= */

.header {
    background: white;
    border-radius: 16px;
    padding: 24px 30px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: #503F93;
    font-size: 28px;
    font-weight: 600;
    margin: 0;
}

.btn-secondary {
    padding: 10px 20px;
    background: #e5e7eb;
    color: #374151;
    border: none;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #d1d5db;
}

/* Top navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 0 20px;
    z-index: 1100;
}

.nav-title {
    font-size: 16px;
    font-weight: 700;
    color: #5233a6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-title-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-subtitle {
    font-size: 12px;
    color: #6b7280;
}

.nav-actions {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.nav-spacer {
    width: 120px;
}

.nav-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-logo img {
    height: 36px;
    width: auto;
}

.nav-menu-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: #f3f4f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.nav-menu-btn img {
    width: 24px;
    height: 24px;
    display: block;
}

.nav-menu-btn:hover {
    background: #e5e7eb;
}

.nav-menu {
    position: absolute;
    top: 54px;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border-radius: 12px;
    min-width: 200px;
    padding: 8px 0;
    display: none;
    z-index: 1101;
}

.nav-menu.open {
    display: block;
}

.nav-menu a,
.nav-menu button {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    background: none;
    border: none;
    color: #111827;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
}

.nav-menu a:hover,
.nav-menu button:hover {
    background: #f3f4f6;
}

.nav-menu #forceRefreshBtn {
    border-top: 1px solid #e5e7eb;
    margin-top: 4px;
    padding-top: 14px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: #5233a6;
    margin-bottom: 16px;
}

/* Connection status pill */
.connection-status {
    position: fixed;
    top: 74px;
    right: 20px;
    z-index: 1100;
    background: white;
    padding: 10px 14px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.status-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
}

.status-text {
    color: #6b7280;
}

/* ========================================= */
/* CONTROLS CARD                             */
/* ========================================= */

.controls-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.search-section {
    margin-bottom: 0;
}

.search-section input[type="text"] {
    font-size: 16px;
    padding: 12px 16px;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Form Elements - Consistent Heights */
input[type="text"],
input[type="date"],
select {
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    width: 100%;
    height: 42px;
    transition: border-color 0.2s;
    background: white;
    box-sizing: border-box;
}

/* Date input specific styling */
input[type="date"] {
    padding-right: 10px;
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    margin-left: 4px;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus {
    outline: none;
    border-color: #7c3aed;
}

/* Select dropdown styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

/* ========================================= */
/* STATS CARDS - COMPACT & CONTROLLED       */
/* ========================================= */

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    min-height: 90px;
    max-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #7c3aed;
    line-height: 1;
    margin: 0;
}

.stat-card .stat-label {
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #6b7280;
    line-height: 1.3;
    margin: 0;
}

/* ========================================= */
/* FACILITY CARDS - HORIZONTAL COMPACT      */
/* ========================================= */

.facilities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.facilities-grid.list-mode {
    display: block;
    grid-template-columns: none;
    gap: 0;
    width: 100%;
}

.facility-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    overflow: hidden;
    cursor: pointer;
}

.facility-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.15);
}

/* Card Header - Dynamic gradient set via JavaScript */
.card-header {
    /* background will be set inline based on engagement % */
    padding: 14px 16px;
    color: white;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.card-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.facility-info {
    flex: 1;
    min-width: 0;
    max-width: calc(100% - 180px);
}

.facility-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 3px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.facility-id {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 500;
    white-space: nowrap;
    margin-left: 8px;
}

.facility-network {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 500;
    line-height: 1.3;
    word-wrap: break-word;
}

.facility-migration-status {
    display: inline-block;
    margin-top: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 700;
    text-transform: capitalize;
}

.facility-migration-complete {
    background: #d1fae5;
    color: #065f46;
}

.facility-migration-partial {
    background: #fef3c7;
    color: #92400e;
}

.facility-migration-pending {
    background: #e0e7ff;
    color: #4338ca;
}

.facility-migration-blocked {
    background: #fee2e2;
    color: #991b1b;
}

.engagement-display {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.15);
    padding: 8px 12px;
    border-radius: 8px;
    flex-shrink: 0;
}

.star-rating {
    font-size: 9px;
    line-height: 1;
    display: flex;
    gap: 2px;
    margin-top: 2px;
}

.engagement-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.engagement-number {
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.engagement-text {
    font-size: 9px;
    opacity: 0.9;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.engagement-percent {
    background: rgba(255,255,255,0.25);
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Card Body - Stats Breakdown */
.card-body {
    padding: 14px 16px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.breakdown-items {
    display: flex;
    gap: 8px;
    flex: 1;
}

.breakdown-item {
    flex: 1;
    padding: 12px 8px;
    background: #f9fafb;
    border-radius: 8px;
    text-align: center;
    border-top: 3px solid;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.breakdown-item.video { border-top-color: #3b82f6; }
.breakdown-item.music { border-top-color: #22c55e; }
.breakdown-item.slideshow { border-top-color: #f59e0b; }

.breakdown-label {
    font-size: 9px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.breakdown-value {
    font-size: 14px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.breakdown-unit {
    font-size: 9px;
    color: #6b7280;
    font-weight: 600;
    margin-top: 2px;
}

.total-box {
    width: 90px;
    text-align: center;
    padding: 12px 8px;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 8px;
    flex-shrink: 0;
}

.total-value {
    font-size: 18px;
    font-weight: 700;
    color: #d97706;
    line-height: 1;
    margin-bottom: 4px;
}

.total-label {
    font-size: 9px;
    color: #92400e;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stats-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 3px solid;
}

.stat-item.video { border-left-color: #3b82f6; }
.stat-item.music { border-left-color: #10b981; }
.stat-item.slideshow { border-left-color: #f59e0b; }

.stat-item-label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.stat-item-value {
    font-size: 15px;
    font-weight: 700;
    color: #374151;
}

/* Total Box - Gold Gradient */
/* Total box removed in favor of stat tiles */

/* ========================================= */
/* TABLE VIEW - COMPACT HORIZONTAL          */
/* ========================================= */

.facilities-list {
    background: white;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.facilities-table {
    width: 100%;
    border-collapse: collapse;
}

.facilities-table thead {
    background: linear-gradient(135deg, #7c3aed 0%, #503F93 100%);
    color: white;
}

.facilities-table th {
    padding: 16px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.facilities-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.facilities-table tbody tr:nth-child(even) {
    background: #f9fafb;
}

.facilities-table tbody tr:hover {
    background: #ede9fe;
    transform: scale(1.005);
    cursor: pointer;
}

.facilities-table td {
    padding: 10px 12px;
    font-size: 13px;
    vertical-align: middle;
}

/* Table Cell Styles */
.table-facility-name {
    font-weight: 600;
    color: #374151;
    line-height: 1.4;
}

.table-facility-network {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
}

.table-engagement {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.table-star-rating {
    font-size: 12px;
    white-space: nowrap;
}

.table-days {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

.table-percentage {
    background: #ede9fe;
    color: #7c3aed;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.table-stat-value {
    font-weight: 600;
    color: #374151;
}

.table-total-box {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 700;
    color: #92400e;
    display: inline-block;
}

/* ========================================= */
/* LOADING & EMPTY STATES                   */
/* ========================================= */

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.no-results {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
    font-size: 16px;
}

/* ========================================= */
/* Facility Detail Page                      */
/* ========================================= */

.facility-detail-page {
    background: #f5f5f5;
    padding: 20px 0 40px 0;
}

.facility-detail-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.facility-top-actions {
    margin-bottom: 16px;
}

.facility-summary-card {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 24px;
    padding: 0 4px;
}

.facility-summary-left {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.facility-summary-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.detail-title {
    font-size: 30px;
    font-weight: 700;
    color: #5233a6;
}

.detail-subtitle {
    font-size: 15px;
    color: #6b7280;
    font-weight: 500;
}

.detail-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #6b7280;
}

.detail-id {
    font-family: 'Courier New', monospace;
    color: #9ca3af;
    font-weight: 600;
    font-size: 11px;
}

.detail-date-range {
    color: #6b7280;
}

.star-rating {
    font-size: 22px;
    color: #fbbf24;
}

.facility-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.facility-stat-card {
    background: white;
    border-radius: 12px;
    padding: 18px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
}

.facility-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #5233a6;
    margin-bottom: 6px;
}

.facility-stat-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-height: 32px;
    display: flex;
    align-items: center;
}

.facility-stat-breakdown {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.video { background: #3b82f6; }
.legend-dot.music { background: #22c55e; }
.legend-dot.slideshow { background: #f59e0b; }

.facility-date-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.facility-date-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-date-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.facility-date-range {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.facility-date-input {
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    min-width: 160px;
}

.facility-date-display {
    font-size: 13px;
    color: #6b7280;
    font-weight: 600;
}

.donut-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.donut-canvas {
    width: 260px;
    height: 260px;
}

.donut-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 14px;
    color: #374151;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.facility-charts-row {
    margin-bottom: 20px;
}

.chart-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 20px;
}

.chart-title {
    font-size: 18px;
    font-weight: 600;
    color: #5233a6;
    margin-bottom: 16px;
}

.chart-container {
    position: relative;
    height: 300px;
}

.daily-chart-container {
    position: relative;
    height: 400px;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #7c3aed;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

.loading-text {
    margin-top: 20px;
    font-size: 18px;
    color: #503F93;
    font-weight: 600;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    background: white;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.error-message h2 {
    color: #ef4444;
    margin-bottom: 15px;
}

.error-message p {
    color: #666;
    margin-bottom: 20px;
}

.compact-return {
    margin-bottom: 16px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ========================================= */
/* RESPONSIVE DESIGN                        */
/* ========================================= */

@media (max-width: 1200px) {
    .filters-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .facilities-grid {
        grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    }
}

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

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 16px;
    }
    
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-cards {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
    
    .facilities-grid {
        grid-template-columns: 1fr;
    }
    
    .facilities-table {
        font-size: 12px;
    }
    
    .facilities-table th,
    .facilities-table td {
        padding: 8px 6px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 0 10px;
    }
    
    .header h1 {
        font-size: 22px;
    }
    
    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        min-height: 80px;
        max-height: 100px;
    }
    
    .stat-value {
        font-size: 24px !important;
    }
    
    .stat-label {
        font-size: 8px !important;
    }
}

/* ========================================= */
/* UTILITY CLASSES                          */
/* ========================================= */

.hidden {
    display: none !important;
}

.text-purple {
    color: #7c3aed;
}

.text-gray {
    color: #6b7280;
}

.fw-bold {
    font-weight: 700;
}

.fw-semibold {
    font-weight: 600;
}

.mt-16 {
    margin-top: 16px;
}

.mb-20 {
    margin-bottom: 20px;
}

.is-hidden {
    display: none;
}

/* Single Row Grid: 4 stats + donut */
.facility-stats-grid-single-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr) 1.5fr;
    gap: 16px;
    margin-bottom: 30px;
}

/* Stat cards in single row */
.facility-stats-grid-single-row .facility-stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid #f0f0f0;
}

/* Donut card in same row */
.facility-stats-grid-single-row .facility-donut-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    height: 140px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    border: 1px solid #f0f0f0;
}

/* Stat values - centered */
.facility-stats-grid-single-row .facility-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #7c3aed;
    margin-bottom: 10px;
    text-align: center;
    line-height: 1;
}

/* Stat labels - centered */
.facility-stats-grid-single-row .facility-stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Donut canvas wrapper */
.facility-stats-grid-single-row .donut-canvas {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
}

.facility-stats-grid-single-row .donut-canvas canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Donut legend */
.facility-stats-grid-single-row .donut-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.facility-stats-grid-single-row .donut-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.facility-stats-grid-single-row .legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block;
}

.facility-stats-grid-single-row .legend-dot.video {
    background: #3b82f6;
}

.facility-stats-grid-single-row .legend-dot.music {
    background: #10b981;
}

.facility-stats-grid-single-row .legend-dot.slideshow {
    background: #f59e0b;
}

/* Responsive breakpoints */
@media (max-width: 1400px) {
    .facility-stats-grid-single-row {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .facility-stats-grid-single-row .facility-donut-card {
        grid-column: 1 / -1;
        height: 160px;
    }
    
    .facility-stats-grid-single-row .donut-canvas {
        width: 110px;
        height: 110px;
    }
}

@media (max-width: 768px) {
    .facility-stats-grid-single-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .facility-stats-grid-single-row .facility-stat-value {
        font-size: 24px;
    }
    
    .facility-stats-grid-single-row .facility-stat-label {
        font-size: 11px;
    }
    
    .facility-stats-grid-single-row .facility-donut-card {
        flex-direction: column;
        height: auto;
        padding: 30px 20px;
    }
    
    .facility-stats-grid-single-row .donut-legend {
        margin-top: 15px;
    }
}
/* ========================================
   FACILITY DETAIL PAGE - SINGLE ROW LAYOUT
   Add these styles to your existing styles.css
   ======================================== */

/* Facility top actions - add spacing */
.facility-top-actions {
    margin-top: 20px;
}

/* Ensure preview bar chart fills container width */
.chart-container canvas {
    width: 100% !important;
}

/* Single Row Grid: 4 stats + donut */
.facility-stats-grid-single-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr) 1.5fr;
    gap: 16px;
    margin-bottom: 30px;
}

/* Stat cards in single row */
.facility-stats-grid-single-row .facility-stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid #f0f0f0;
}

/* Donut card in same row */
.facility-stats-grid-single-row .facility-donut-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    height: 140px;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 20px;
    border: 1px solid #f0f0f0;
}

/* Stat values - centered */
.facility-stats-grid-single-row .facility-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #7c3aed;
    margin-bottom: 10px;
    text-align: center;
    line-height: 1;
}

/* Stat labels - centered */
.facility-stats-grid-single-row .facility-stat-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Donut canvas wrapper */
.facility-stats-grid-single-row .donut-canvas {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
}

.facility-stats-grid-single-row .donut-canvas canvas {
    max-width: 100%;
    max-height: 100%;
}

/* Donut legend */
.facility-stats-grid-single-row .donut-legend {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.facility-stats-grid-single-row .donut-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
}

.facility-stats-grid-single-row .legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
    display: inline-block;
}

.facility-stats-grid-single-row .legend-dot.video {
    background: #3b82f6;
}

.facility-stats-grid-single-row .legend-dot.music {
    background: #10b981;
}

.facility-stats-grid-single-row .legend-dot.slideshow {
    background: #f59e0b;
}

/* Responsive breakpoints */
@media (max-width: 1400px) {
    .facility-stats-grid-single-row {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .facility-stats-grid-single-row .facility-donut-card {
        grid-column: 1 / -1;
        height: 160px;
    }
    
    .facility-stats-grid-single-row .donut-canvas {
        width: 110px;
        height: 110px;
    }
}

@media (max-width: 768px) {
    .facility-stats-grid-single-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .facility-stats-grid-single-row .facility-stat-value {
        font-size: 24px;
    }
    
    .facility-stats-grid-single-row .facility-stat-label {
        font-size: 11px;
    }
    
    .facility-stats-grid-single-row .facility-donut-card {
        flex-direction: column;
        height: auto;
        padding: 30px 20px;
    }
    
    .facility-stats-grid-single-row .donut-legend {
        margin-top: 15px;
    }
}

/* ========================================
   FACILITY DATE CONTROLS - CONSISTENT STYLING
   ======================================== */

/* Date controls card for facility detail page */
.facility-date-controls-card {
    margin-bottom: 30px;
}

/* Update filters grid for 5 columns (2 dates + units + button + display) */
.facility-date-controls-card .filters-grid {
    grid-template-columns: repeat(5, 1fr);
}

/* Field group for button alignment */
.field-group-button button,
button.field-group-button {
    width: 100%;
    height: 42px;
    margin: 0;
    background: linear-gradient(135deg, #7c3aed 0%, #5233a6 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.2);
}

.field-group-button button:hover,
button.field-group-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(124, 58, 237, 0.3);
    background: linear-gradient(135deg, #8b5cf6 0%, #6b46c1 100%);
}

.field-group-button button:active,
button.field-group-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(124, 58, 237, 0.2);
}

/* Date range display field */
.field-group-display .date-range-display {
    height: 42px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Responsive adjustments for facility date controls */
@media (max-width: 1200px) {
    .facility-date-controls-card .filters-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .field-group-display {
        grid-column: 1 / -1;
    }
}

@media (max-width: 768px) {
    .facility-date-controls-card .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .field-group-display {
        grid-column: 1 / -1;
    }
}

@media (max-width: 640px) {
    .facility-date-controls-card .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .field-group-button,
    .field-group-display {
        grid-column: 1;
    }
}

/* ========================================
   END OF COMBINED STYLES
   Original: 1280 lines
   Added: Facility single-row layout + date controls
   Total lines will be displayed below
   ======================================== */
/* ========================================
   FACILITY ANALYTICS SECTIONS - CSS
   Add these styles to your styles.css
   ======================================== */

/* Analytics Row - 2 Column Grid */
.analytics-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

/* Analytics Donut Section */
.analytics-donut-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.analytics-donut-container {
    width: 260px;
    height: 260px;
    margin: 20px 0;
}

.analytics-legend {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 300px;
}

.analytics-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

/* Analytics List Section */
.analytics-list-section {
    display: flex;
    flex-direction: column;
}

.analytics-list-container {
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal overflow */
    width: 100%; /* Take full container width */
}

.analytics-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: #6b7280;
    font-size: 14px;
}

/* Analytics List Item */
.analytics-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.2s;
    width: 100%; /* Take full container width */
    max-width: 100%; /* Don't exceed container */
    box-sizing: border-box; /* Include padding in width calculation */
}

.analytics-list-item:hover {
    background: #f9fafb;
}

.analytics-list-item:last-child {
    border-bottom: none;
}

.analytics-rank {
    font-size: 18px;
    font-weight: 700;
    color: #7c3aed;
    min-width: 45px;
}

.analytics-content {
    flex: 1;
    min-width: 0;
}

.analytics-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    transition: color 0.2s;
}

.analytics-list-item[data-truncated="true"] .analytics-title {
    cursor: pointer;
}

.analytics-list-item[data-truncated="true"] .analytics-title:hover {
    color: #7c3aed;
}

.analytics-list-item.expanded .analytics-title {
    white-space: normal;
    word-wrap: break-word;
}

.analytics-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.analytics-list-item.expanded .analytics-subtitle {
    white-space: normal;
    word-wrap: break-word;
}

.analytics-count {
    font-size: 14px;
    font-weight: 600;
    color: #7c3aed;
    background: #f3f4f6;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

/* Analytics Pagination */
.analytics-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    margin-top: auto;
}

.analytics-pagination button {
    padding: 8px 16px;
    background: #e5e7eb;
    color: #374151;
    border: none;
    border-radius: 6px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.analytics-pagination button:hover:not(:disabled) {
    background: #d1d5db;
}

.analytics-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.analytics-pagination button.active {
    background: #7c3aed;
    color: white;
}

.analytics-pagination-info {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .analytics-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .analytics-donut-container {
        width: 200px;
        height: 200px;
    }
    
    .analytics-list-item {
        padding: 10px 12px;
    }
    
    .analytics-rank {
        font-size: 16px;
        min-width: 40px;
    }
    
    .analytics-title {
        font-size: 13px;
    }
    
    .analytics-subtitle {
        font-size: 11px;
    }
}
