/* =========================================================
   Temperature Dashboard / Report - Premium UI
   ========================================================= */

:root {
    --primary-color: #2e7d32;
    --primary-dark: #1b5e20;
    --primary-light: #4caf50;
    --bg-main: #f3f5f8;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10);
    --radius-sm: 8px;
    --radius-md: 14px;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.temp-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 8px 16px 48px;
}

/* --- Header --- */
.dashboard-header {
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 48%, #43a047 100%);
    color: #fff;
    border-radius: var(--radius-md);
    padding: 22px 26px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 10px 28px rgba(46, 125, 50, 0.28);
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}
.dashboard-header img {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: #fff;
    padding: 5px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}
.header-kicker {
    margin: 0 0 2px;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.8;
    font-weight: 600;
}
.dashboard-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.header-sub {
    margin: 4px 0 0;
    font-size: 13px;
    opacity: 0.9;
}
.period-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

/* --- Cards --- */
.premium-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 18px;
    overflow: visible;
}
.filter-card {
    margin-bottom: 16px;
}

.card-header-gradient {
    background: #f8fafc;
    color: var(--text-primary);
    padding: 13px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}
.card-header-gradient h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #0f172a;
}
.card-header-gradient h3 .glyphicon {
    color: var(--primary-color);
}
.card-header-gradient.temp-header h3 .glyphicon { color: #ef6c00; }
.card-header-gradient.humidity-header h3 .glyphicon { color: #0277bd; }
.card-header-gradient.records-header h3 .glyphicon { color: #1e3c72; }
.card-header-gradient.abnormal-header h3 .glyphicon { color: #c62828; }

.header-badge {
    background: #eef2ff;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 999px;
}
.abnormal-header .header-badge {
    background: #fee2e2;
    color: #991b1b;
}

.card-body {
    padding: 18px 20px;
}
.filter-body { padding: 16px 20px 8px; }
.chart-body { padding: 16px 18px 18px; }

/* --- Filter --- */
.filter-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 14px;
    align-items: end;
}
.filter-grid > .form-group { flex: 1 1 220px; }
.filter-grid > .form-group:nth-child(2),
.filter-grid > .form-group:nth-child(3) { flex: 0 1 130px; }
.filter-grid > .filter-actions { flex: 0 1 240px; }
.form-group {
    margin-bottom: 12px;
}
.form-group label {
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.form-control {
    border-radius: var(--radius-sm);
    border: 1px solid #cbd5e1;
    height: 40px;
    padding: 8px 12px;
    font-size: 14px;
    box-shadow: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
    outline: none;
}
.form-control.input-sm {
    height: 34px;
    font-size: 13px;
}
.bootstrap-select > .dropdown-toggle {
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    background: #fff !important;
}
.filter-actions { margin-bottom: 12px; }
.filter-action-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- KPI --- */
.kpi-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
}
.kpi-grid > .kpi-card { flex: 1 1 260px; }
.kpi-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-height: 96px;
}
.kpi-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    font-size: 16px;
}
.kpi-records .kpi-icon { background: linear-gradient(135deg, #1e3c72, #2a5298); }
.kpi-temp .kpi-icon { background: linear-gradient(135deg, #ef6c00, #ff9800); }
.kpi-hum .kpi-icon { background: linear-gradient(135deg, #0277bd, #29b6f6); }
.kpi-alert .kpi-icon { background: linear-gradient(135deg, #c62828, #ef5350); }
.kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 2px;
}
.kpi-value {
    font-size: 22px;
    font-weight: 800;
    line-height: 1.2;
    color: #0f172a;
    letter-spacing: -0.03em;
}
.kpi-value.avg { color: #2e7d32; }
.kpi-hint {
    margin-top: 4px;
    font-size: 12px;
    color: #64748b;
}
.kpi-hint .min { color: #1565c0; font-weight: 700; }
.kpi-hint .max { color: #c62828; font-weight: 700; }

/* --- Charts --- */
.charts-grid {
    display: flex;
    flex-wrap: wrap;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 18px;
}
.charts-grid .premium-card {
    margin-bottom: 0;
    flex: 0 0 auto;
    width: 100%;
}
.chart-wrapper {
    position: relative;
    width: 100%;
    min-height: 240px;
}
.chart-wrapper canvas {
    width: 100% !important;
    max-height: 280px;
}

/* --- Tables --- */
.table-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}
.per-page-label {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}
.per-page-select {
    width: auto;
    display: inline-block;
    min-width: 70px;
}
.table-custom-responsive {
    border-radius: var(--radius-sm);
    overflow: auto;
    border: 1px solid var(--border-color);
    background: #fff;
    -webkit-overflow-scrolling: touch;
}
.table-custom {
    margin-bottom: 0;
    font-size: 13px;
    min-width: 680px;
}
.table-custom thead th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 11px 10px;
    vertical-align: middle;
    white-space: nowrap;
}
.table-custom tbody tr:hover { background-color: #f8fafc; }
.table-custom td {
    padding: 10px;
    vertical-align: middle;
    border-color: #f1f5f9;
}
.col-num { width: 48px; }

.shift-badge {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.shift-morning { background: #e0f2fe; color: #0369a1; }
.shift-afternoon { background: #fef3c7; color: #b45309; }
.shift-night { background: #f3e8ff; color: #7e22ce; }

.btn-premium-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    padding: 9px 16px;
    height: 40px;
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.25);
}
.btn-premium-primary:hover,
.btn-premium-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    color: #fff;
}
.btn-premium-default {
    background: #fff;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 9px 14px;
    height: 40px;
}
.btn-premium-default:hover {
    background: #f1f5f9;
    color: #1e293b;
}

.pagination-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
    padding: 6px 0;
}
.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}
.pagination { margin: 0; }
.pagination > li > a {
    color: #475569;
    border-color: #e2e8f0;
    padding: 5px 11px;
    font-size: 13px;
}
.pagination > .active > a,
.pagination > .active > a:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

@media (max-width: 1199px) {
    .filter-grid > .form-group { flex-basis: 31%; }
    .filter-grid > .filter-actions { flex-basis: 100%; }
}

@media (max-width: 991px) {
    .kpi-grid > .kpi-card,
    .charts-grid .premium-card { flex-basis: calc(50% - 8px); }
}

@media (max-width: 768px) {
    .temp-container { padding: 0 10px 36px; }
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }
    .dashboard-header h2 { font-size: 18px; }
    .filter-grid > .form-group,
    .kpi-grid > .kpi-card,
    .charts-grid .premium-card { flex-basis: 100%; }
    .card-body { padding: 14px; }
    .filter-action-btns .btn { flex: 1; }
    .pagination-wrapper {
        justify-content: center;
        text-align: center;
    }
    .table-toolbar { justify-content: flex-start; }
    .period-chip { white-space: normal; }
}

@supports (display: grid) {
    .filter-grid {
        display: grid;
        grid-template-columns: minmax(220px, 1.4fr) 140px 130px minmax(180px, 1.2fr) auto;
    }
    .filter-grid > .form-group,
    .filter-grid > .filter-actions { flex: initial; }

    .kpi-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }
    .kpi-grid > .kpi-card { flex: initial; }

    .charts-grid {
        display: grid;
        grid-template-columns: 1fr;
    }
    .charts-grid .premium-card { flex: initial; }

    @media (max-width: 1199px) {
        .filter-grid {
            grid-template-columns: 1fr 1fr 1fr;
        }
        .filter-actions { grid-column: 1 / -1; }
    }

    @media (max-width: 991px) {
        .kpi-grid,
        .charts-grid {
            grid-template-columns: 1fr;
        }
    }

    @media (max-width: 768px) {
        .filter-grid,
        .kpi-grid,
        .charts-grid {
            grid-template-columns: 1fr;
        }
    }
}

/* Fix bootstrap-select dropdown being clipped under card/frame */
.bootstrap-select .dropdown-menu {
    z-index: 9999 !important;
}
