/* Dashboard Exact Styling - Matching Design Image */

/* Design tokens for device analytics cards (Figma design spec) */
:root {
    --spacing-padding-spacing-16: 16px;
    --spacing-padding-spacing-20: 20px;
    --spacing-gap-gap-2: 2px;
}

body {
    background-color: #f8f9fa; /* Light grey background for the dashboard */
}

/* Page-specific gray background - use {% block body_class %}page-gray-bg{% endblock %} in templates */
/* This overrides section-improvements.css white background with !important */
body.page-gray-bg {
    background-color: #d1d5db !important; /* Tailwind gray-300 */
}

/* Base card styling */
.summary-card,
.alerts-panel,
.collectors-panel,
.dashboard-card {
    background-color: #ffffff;
    border-radius: var(--border-border-radius-rounded-base, 12px);
    border: var(--border-border-width-border, 1px) solid
        var(--colors-border-border-base, #e5e7eb);
    box-shadow: 0 1px 0.5px 0.05px rgba(29, 41, 61, 0.02);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Summary Card Specifics - KPI Cards (Figma alignment Phase 3) */
/* Layout: icon on right, title/value stacked on left */
.summary-card,
a.summary-card {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    text-decoration: none;
    color: inherit;
    min-height: 100px;
}

a.summary-card:hover {
    text-decoration: none;
    color: inherit;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.15s ease;
}

/* Content block: stacked vertically with title on top, value below */
.summary-card-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

/* Icon positioned on the right (Figma: 40x40px rounded) */
.summary-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
    background-color: var(--color-metric-icon-bg, #e6f7ed);
    color: var(--color-metric-icon, #004f3b);
    font-size: 18px;
}

/* Label on top (Figma: smaller, muted text) */
.summary-card-label {
    color: var(--colors-text-text-body, #6b7280);
    font-family: var(--typography-font-family-font-base, "Ubuntu Sans");
    font-size: 14px;
    font-style: normal;
    font-weight: 500;
    line-height: 1.4;
}

/* Subtitle below label (Figma alignment) */
.summary-card-subtitle {
    color: var(--colors-text-text-muted, #9ca3af);
    font-family: var(--typography-font-family-font-base, "Ubuntu Sans");
    font-size: 12px;
    font-weight: 400;
    line-height: 1.3;
    margin-top: -4px;
}

/* Large value below title (Figma: bold, prominent) */
.summary-card-value {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

/* Panel Headers (for Recent Alerts and Data Collectors Status) */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px; /* Reduced from 16px for tighter spacing */
}

.panel-title {
    color: var(--colors-text-text-heading, #101828);
    font-family: var(--typography-font-family-font-base, "Ubuntu Sans");
    font-size: var(--typography-font-size-text-lg, 18px);
    font-style: normal;
    font-weight: 500;
    line-height: var(--typography-line-height-leading-7, 28px);
}

.panel-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--themes-border-border-radius-rounded-sm, 4px);
    background-color: var(--color-brand-green);
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    box-shadow: 0 1px 0.5px 0.05px rgba(29, 41, 61, 0.02);
    transition: background-color 0.2s ease-in-out;
}

.panel-button:hover {
    background-color: var(--color-brand-green-hover);
    color: white;
    text-decoration: none;
}

/* Recent Alerts Panel */
.alerts-list {
    display: flex;
    flex-direction: column;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb; /* Subtle border */
    background-color: #ffffff;
    margin-bottom: 8px;
}

.alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 16px;
    flex-shrink: 0;
}

.alert-icon.severity-critical {
    background-color: #fef2f2; /* Light Red Background */
    color: #dc2626; /* Dark Red Icon */
    border: 1px solid #fecaca; /* Red border for emphasis */
}
.alert-icon.severity-major {
    background-color: #fff7ed; /* Light Orange Background */
    color: #ea580c; /* Dark Orange Icon */
    border: 1px solid #fed7aa; /* Orange border */
}
.alert-icon.severity-warning {
    background-color: #fffbeb; /* Light Yellow Background */
    color: #d97706; /* Dark Yellow Icon */
    border: 1px solid #fde68a; /* Yellow border */
}
.alert-icon.severity-minor {
    background-color: #eff6ff; /* Light Blue Background */
    color: #2563eb; /* Dark Blue Icon */
    border: 1px solid #bfdbfe; /* Blue border */
}
.alert-icon.severity-info {
    background-color: #ecfeff; /* Light Cyan Background */
    color: #0891b2; /* Dark Cyan Icon */
    border: 1px solid #a7f3d0; /* Cyan border */
}
.alert-icon.severity-error {
    background-color: #fef2f2; /* Light Red Background */
    color: #dc2626; /* Dark Red Icon */
    border: 1px solid #fecaca; /* Red border */
}
.alert-icon.severity-neutral {
    background-color: #f8fafc; /* Light Grey Background */
    color: #64748b; /* Dark Grey Icon */
    border: 1px solid #e2e8f0; /* Grey border */
}

/* Severity dot - 8px colored circle (Figma alignment Phase 5) */
.severity-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px; /* Align with first line of text */
}

.alert-content {
    flex-grow: 1;
}

.alert-title {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1.4;
    margin-bottom: 4px;
}

.alert-subtitle {
    font-size: 14px;
    color: #6b7280;
    font-weight: 400;
}

/* Data Collectors Status Panel */
.collectors-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
}

.summary-count {
    font-size: 36px;
    font-weight: 700;
    line-height: 1;
}

.summary-label {
    font-size: 16px;
    color: #343a40;
}

.status-categories {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 16px;
}

.status-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
    min-width: 0;
}

.category-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
}

.category-icon.status-connected {
    background-color: #e6fff3 !important;
    color: #16a34a !important;
} /* Very Light Green Background, Green Icon */
.category-icon.status-disconnected {
    background-color: #fef0f2 !important;
    color: #dc2626 !important;
} /* Light Red Background, Red Icon */
.category-icon.status-other {
    background-color: #eff6ff !important;
    color: #1c398e !important;
} /* Light Blue Background, Blue Icon */

.category-label {
    font-size: 16px;
    font-weight: 600;
    color: #343a40;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    min-width: 0;
}

.collector-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.collector-item {
    font-size: 14px;
    color: #343a40;
    padding: 4px 0;
}

.orange-text {
    color: orange;
}

/* Time Filter Pills (Figma alignment — individual rounded buttons) */
.time-filter-pill {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #525252;
    background-color: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition:
        background-color 0.15s ease,
        color 0.15s ease;
    line-height: 1.4;
    white-space: nowrap;
}

.time-filter-pill:hover {
    background-color: #f5f5f5;
}

.time-filter-pill.active {
    background-color: var(--color-banner-gradient-start, #e8f9f3);
    color: var(--color-brand-green, #25af88);
}

/* Card Divider - Gray horizontal line below title section */
.dashboard-card-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 12px 0 16px 0;
    width: 100%;
}

/* Large Count Display - For Total Devices card */
.device-count-display {
    font-size: 64px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
    text-align: center;
}

/* Chart with Side Legend Layout */
.chart-with-legend {
    display: flex;
    align-items: center;
    gap: 16px;
}

.chart-with-legend .chart-area {
    flex: 1;
    min-width: 0;
}

/* Low Battery Devices List */
.low-battery-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    overflow-y: auto;
}

/* Dashboard cards: balanced, consistent layout */
/* All four cards equal width on desktop for visual consistency */
#device-analytics-charts-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: stretch;
}

@media (min-width: 768px) {
    #device-analytics-charts-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    #device-analytics-charts-container {
        /* Total Devices 20% narrower, Device Status & Importance 10% wider each */
        grid-template-columns: 0.8fr 1.1fr 1.1fr minmax(0, 1fr);
    }
}

#device-analytics-charts-container > div {
    display: flex;
    height: 100%;
}

/* All cards: unified styling (border-radius 8px, #DCDCDC border, #FDFDFD background) */
#device-analytics-charts-container .device-analytics-card-total .dashboard-card,
#device-analytics-charts-container .device-analytics-card-chart .dashboard-card,
#device-analytics-charts-container
    .device-analytics-card-low-battery
    .dashboard-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    padding: var(--spacing-padding-spacing-16, 16px)
        var(--spacing-padding-spacing-20, 20px);
    border-radius: 8px;
    border: 1px solid #dcdcdc;
    background: #fdfdfd;
    box-shadow: none;
}

#device-analytics-charts-container
    .device-analytics-card-total
    .dashboard-card {
    gap: var(--spacing-gap-gap-2, 2px);
    align-items: stretch;
}

#device-analytics-charts-container
    .device-analytics-card-chart
    .dashboard-card {
    align-items: stretch;
}

#device-analytics-charts-container
    .device-analytics-card-low-battery
    .dashboard-card {
    gap: var(--spacing-gap-gap-2, 2px);
    align-items: stretch;
}

#device-analytics-charts-container .dashboard-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
}

#device-analytics-charts-container .dashboard-card .chart-container {
    flex-shrink: 0;
    /* Height is set inline via CHART_HEIGHT_DONUT - grid will equalize all cards */
}

#device-analytics-charts-container .dashboard-card .low-battery-list {
    flex: 1;
    min-height: 0;
}

.low-battery-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.low-battery-item .device-name {
    font-size: 14px;
    color: #4a5565;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.low-battery-item .battery-percentage {
    font-size: 14px;
    font-weight: 500;
    color: #dc2626;
    min-width: 40px;
    text-align: right;
}

.low-battery-item .battery-bar {
    width: 60px;
    height: 4px;
    background-color: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.low-battery-item .battery-bar-fill {
    height: 100%;
    background-color: #dc2626;
    border-radius: 2px;
}

.low-battery-item .battery-bar-fill.battery-bar-critical {
    background-color: #991b1b;
}

/* Recent Alerts Panel — full-width (Figma alignment) */
.recent-alerts-panel {
    background-color: #ffffff;
    border-radius: 8px;
    border: 1px solid #d9d9d9;
    overflow: hidden;
}

.recent-alerts-panel-header {
    padding: 16px 24px;
    border-bottom: 1px solid #dcdcdc;
}

.recent-alerts-panel-body {
    padding: 8px 16px;
}

.recent-alert-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.recent-alert-row:hover {
    background-color: #f9fafb;
}

.recent-alert-row:hover .w-4.h-4.text-gray-400 {
    color: var(--color-brand-green, #25af88);
}

.recent-alerts-panel-footer {
    padding: 16px 24px;
    border-top: 1px solid #dcdcdc;
    display: flex;
    justify-content: center;
}

.recent-alerts-view-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--color-brand-green, #25af88);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
}

.recent-alerts-view-all:hover {
    color: #1f9a74;
    text-decoration: none;
}

/* Placeholder Widget Styles (Dashboard Figma alignment - Coming Soon state) */
.placeholder-widget {
    background-color: #f9fafb;
    border: 1px dashed #d1d5db;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0.85;
}

.placeholder-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.placeholder-widget-title {
    color: #6b7280;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
}

.placeholder-widget-badge {
    background-color: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.placeholder-widget-subtitle {
    color: #9ca3af;
    font-size: 12px;
    margin: 0;
}

.placeholder-widget-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background-color: #f3f4f6;
    border-radius: 8px;
    gap: 8px;
}

.placeholder-widget-icon {
    width: 48px;
    height: 48px;
    color: #d1d5db;
}

.placeholder-widget-text {
    color: #9ca3af;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
