/* Home Style CSS - Refined */
/* Remove PHP comment from CSS - Process server-side or use JS */
:root {
  --theme-color: #0d6efd;
  --theme-contrast: #ffffff;
  --page-bg-1: #f6f8fb;
  --page-bg-2: #ffffff;
  --muted: #6c757d;
  --card-radius: 12px;
  --card-shadow: 0 6px 18px rgba(20, 24, 40, 0.06);
  --glass-bg: rgba(255, 255, 255, 0.6);
}

/* Replace universal selector with specific resets */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, var(--page-bg-1) 0%, var(--page-bg-2) 100%);
  color: #222;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Header / nav - Fixed position property with fallback */
.dashboard-nav {
  position: -webkit-sticky; /* Safari */
  position: sticky;
  top: 0;
  z-index: 1050;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px); /* Safari */
  background: rgba(255, 255, 255, 0.66);
  border-bottom: 1px solid rgba(30, 40, 50, 0.04);
  padding: 8px 16px;
  box-shadow: 0 2px 12px rgba(20, 24, 40, 0.03);
}

/* Desktop tabs */
.nav-tabs-custom {
  display: flex;
  flex-wrap: wrap;
}

.nav-tabs-custom .nav-link {
  border: none;
  color: #333;
  padding: 10px 16px;
  border-radius: 10px;
  margin-right: 6px;
  transition: all 0.18s ease;
  text-decoration: none;
  white-space: nowrap;
}

.nav-tabs-custom .nav-link:hover {
  background: rgba(0, 0, 0, 0.04);
}

.nav-tabs-custom .nav-link.active {
  background: linear-gradient(90deg, var(--theme-color), color-mix(in srgb, var(--theme-color) 70%, #000000 10%));
  color: var(--theme-contrast);
  box-shadow: 0 6px 18px rgba(13, 110, 253, 0.12);
}

.nav-dropdown-custom .dropdown-menu {
  border-radius: 10px;
  min-width: 220px;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Mobile bottom nav (fixed) */
.nav-underline-custom {
  display: none;
}

@media (max-width: 767.98px) {
  .nav-tabs-custom {
    display: none;
  }
  
  .nav-underline-custom {
    position: fixed;
    bottom: 10px;
    left: 12px;
    right: 12px;
    z-index: 1060;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: space-around;
    padding: 8px 12px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(20, 24, 40, 0.08);
    border: 1px solid rgba(30, 40, 50, 0.04);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }
  
  .nav-underline-custom .nav-link {
    color: #444;
    padding: 8px;
    font-size: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
  }
  
  /* Add padding to body to prevent content from hiding behind bottom nav */
  body {
    padding-bottom: 80px;
  }
}

/* Theme card style */
.theme-card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  background: linear-gradient(180deg, #fff, #fbfdff);
  border-top: 4px solid var(--theme-color);
  margin-bottom: 1.5rem;
}

.theme-card .card-body {
  padding: 1.5rem;
}

.theme-card .card-body > h2 {
  margin: 0 0 0.5rem 0;
  font-weight: 600;
  letter-spacing: -0.2px;
  font-size: 1.5rem;
}

.theme-card .card-body small {
  color: var(--muted);
  display: block;
  margin-bottom: 1rem;
}

/* Button theme */
.btn-theme {
  background: var(--theme-color);
  color: var(--theme-contrast);
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  transition: all 0.18s ease;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  text-decoration: none;
  line-height: 1.5;
}

.btn-theme:hover {
  background: color-mix(in srgb, var(--theme-color) 90%, #000000);
  color: var(--theme-contrast);
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(13, 110, 253, 0.15);
}

.btn-theme:active {
  transform: translateY(1px);
}

.btn-theme:focus {
  outline: 2px solid rgba(13, 110, 253, 0.3);
  outline-offset: 2px;
}

/* Summary boxes */
.summary-box {
  border-radius: 12px;
  padding: 1.5rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1px solid rgba(0, 0, 0, 0.05);
  margin-bottom: 1rem;
}

.summary-box:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(20, 24, 40, 0.08);
}

.summary-box i {
  display: block;
  font-size: 28px;
  margin-bottom: 0.75rem;
  color: rgba(0, 0, 0, 0.55);
}

.summary-box h3 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0.25rem 0;
}

.summary-box p {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

/* Sensor badge (top nav) */
.sensor-badge {
  display: inline-block;
  background: linear-gradient(90deg, var(--theme-color), #3b82f6);
  color: #fff;
  font-weight: 600;
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 999px;
  margin-left: 8px;
  box-shadow: 0 6px 14px rgba(13, 110, 253, 0.12);
  transform-origin: center;
  animation: pulseBadge 2.6s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pulseBadge {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.06);
    opacity: 0.85;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Summary state classes */
.temp-cold {
  background: linear-gradient(90deg, #e9f2ff, #fff);
  color: #0275d8;
  border-left: 4px solid #0275d8;
}

.temp-mild {
  background: linear-gradient(90deg, #fff7e6, #fff);
  color: #d48806;
  border-left: 4px solid #d48806;
}

.temp-hot {
  background: linear-gradient(90deg, #fff0f0, #fff);
  color: #c82333;
  border-left: 4px solid #c82333;
}

/* Table improvements */
.table-theme {
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.table-theme thead th {
  position: -webkit-sticky; /* Safari */
  position: sticky;
  top: 0;
  background: var(--theme-color);
  color: var(--theme-contrast);
  border: none;
  font-weight: 600;
  padding: 1rem;
  text-align: left;
}

.table-theme tbody td {
  padding: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.table-theme tbody tr:hover {
  background: rgba(13, 110, 253, 0.03);
}

.table-theme tbody tr:last-child td {
  border-bottom: none;
}

/* Skeleton loading for charts and table rows */
.loading {
  position: relative;
  overflow: hidden;
  min-height: 40px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
}

.loading::after {
  content: '';
  position: absolute;
  left: -150px;
  top: 0;
  height: 100%;
  width: 150px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0));
  animation: loading-shimmer 1.6s infinite;
}

@keyframes loading-shimmer {
  0% {
    left: -150px;
  }
  100% {
    left: 100%;
  }
}

/* Logos bar adjustments */
.logo-bar {
  padding: 18px 8px;
  background: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 24px;
}

.logo-bar img {
  max-height: 56px;
  opacity: 0.95;
  filter: drop-shadow(0 8px 18px rgba(20, 24, 40, 0.06));
  transition: opacity 0.2s ease;
}

.logo-bar img:hover {
  opacity: 1;
}

/* Minor utilities */
.text-muted {
  color: var(--muted) !important;
}

.badge-live {
  background: linear-gradient(90deg, #2dd4bf, #06b6d4);
  color: #fff;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 12px;
  box-shadow: 0 6px 18px rgba(6, 182, 212, 0.12);
  display: inline-block;
  font-size: 0.875rem;
}

/* Additional fixes */
a {
  color: var(--theme-color);
  text-decoration: none;
}

a:hover {
  color: color-mix(in srgb, var(--theme-color) 80%, #000000);
  text-decoration: underline;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Container padding for mobile */
.container, .container-fluid {
  padding-left: 16px;
  padding-right: 16px;
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
  .dashboard-nav {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.95);
  }
  
  .nav-underline-custom {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: rgba(255, 255, 255, 0.95);
  }
}

/* Print styles */
@media print {
  .nav-underline-custom,
  .dashboard-nav,
  .sensor-badge,
  .badge-live {
    display: none !important;
  }
  
  .theme-card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
}

/* Chart styling */
.chart-container {
    position: relative;
    height: 180px;
    width: 100%;
}

.card-body canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Chart card titles */
.card-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Trend indicators */
.trend-up {
    color: #198754;
}

.trend-down {
    color: #dc3545;
}

.trend-stable {
    color: #6c757d;
}