/* =====================================================
   DEVICELIST.CSS — deviceList.html component
   Danh sách màn hình: section header, search, grid card
   ===================================================== */

/* ===================== SECTION HEADER ===================== */
.adv-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.adv-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
}

.adv-section-sub {
  color: var(--adv-text-muted);
  font-size: 0.82rem;
  margin: 0 0 0.35rem;
}

/* Stats row */
.adv-stats-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.3rem;
  flex-wrap: wrap;
}

.adv-stat-chip {
  font-size: 0.75rem;
  color: var(--adv-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.adv-stat-chip strong {
  color: var(--adv-text);
  font-weight: 700;
}

.adv-stat-chip--active {
  color: #10b981;
}

.adv-stat-chip--active strong {
  color: #10b981;
}

.adv-stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  animation: pulse-active 2s ease-in-out infinite;
}

.adv-stat-sep {
  font-size: 0.72rem;
  color: var(--adv-border);
}

.adv-device-count-badge {
  background: var(--adv-surface2);
  border: 1px solid var(--adv-border);
  border-radius: 20px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  color: var(--adv-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ===================== EXPIRY BANNER ===================== */
.adv-expiry-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--adv-radius-sm);
  margin-bottom: 0.65rem;
  cursor: pointer;
  transition: filter 0.15s;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.4;
}

.adv-expiry-banner:hover {
  filter: brightness(1.1);
}

.adv-expiry-banner > i:first-child {
  font-size: 1rem;
  flex-shrink: 0;
}

.adv-expiry-banner > div {
  flex: 1;
  min-width: 0;
}

.adv-expiry-banner--danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

.adv-expiry-banner--warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}

.adv-expiry-names {
  display: block;
  font-size: 0.72rem;
  opacity: 0.75;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  margin-top: 0.1rem;
}

.adv-expiry-arrow {
  font-size: 0.7rem;
  flex-shrink: 0;
  opacity: 0.6;
}

/* ===================== FILTER BAR ===================== */
.adv-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.adv-search-box--grow {
  flex: 1;
  min-width: 0;
}

/* Custom checkbox filter */
.adv-filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  background: var(--adv-surface);
  border: 1px solid var(--adv-border);
  border-radius: var(--adv-radius-sm);
  padding: 0.5rem 0.85rem;
  transition: all 0.18s;
  user-select: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.adv-filter-checkbox:hover {
  border-color: rgba(16, 185, 129, 0.4);
  background: var(--adv-surface2);
}

.adv-filter-checkbox.is-active {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.08);
}

.adv-filter-checkbox input[type="checkbox"] {
  display: none;
}

.adv-filter-checkbox-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--adv-border);
  background: var(--adv-surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 0.7rem;
  color: transparent;
}

.adv-filter-checkbox.is-active .adv-filter-checkbox-box {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}

.adv-filter-checkbox-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--adv-text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}

.adv-filter-checkbox.is-active .adv-filter-checkbox-label {
  color: #10b981;
}

@media (max-width: 576px) {
  .adv-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .adv-filter-checkbox {
    justify-content: center;
  }
}

/* ===================== SEARCH ===================== */
.adv-search-box {
  position: relative;
}

.adv-search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--adv-text-muted);
  pointer-events: none;
}

.adv-search-input {
  background: var(--adv-surface);
  border: 1px solid var(--adv-border);
  border-radius: var(--adv-radius-sm);
  color: var(--adv-text);
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  width: 100%;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s;
}

.adv-search-input:focus {
  border-color: var(--adv-primary-light);
}

.adv-search-input::placeholder {
  color: var(--adv-text-muted);
}

/* ===================== DEVICE GRID ===================== */
.adv-device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

/* ===================== DEVICE CARD ===================== */
.adv-device-card {
  background: var(--adv-surface);
  border: 1px solid var(--adv-border);
  border-radius: var(--adv-radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s;
  animation: fadeInUp 0.3s ease both;
}

.adv-device-card:hover {
  border-color: var(--adv-primary-light);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.2);
}

/* Thumbnail */
.adv-device-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--adv-surface2);
  position: relative;
  overflow: hidden;
}

.adv-device-thumb img,
.adv-device-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.adv-device-thumb-empty {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--adv-text-muted);
  font-size: 1.5rem;
}

.adv-device-thumb-empty span {
  font-size: 0.7rem;
}

/* Type badge (Ảnh / Video) */
.adv-device-type-badge {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border-radius: 6px;
  padding: 0.15rem 0.4rem;
  font-size: 0.65rem;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Card body */
.adv-device-body {
  padding: 0.75rem;
}

.adv-device-name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

/* Active dot */
.adv-device-active-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  animation: pulse-active 2s ease-in-out infinite;
}

@keyframes pulse-active {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
}

.adv-device-name {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adv-device-id {
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  color: var(--adv-text-muted);
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 576px) {
  .adv-device-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
}

/* ===================== PAGINATION ===================== */
.adv-pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.adv-pagination-info {
  font-size: 0.78rem;
  color: var(--adv-text-muted);
  white-space: nowrap;
}

.adv-pagination-info strong {
  color: var(--adv-text);
}

.adv-pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.adv-page-btn {
  background: var(--adv-surface);
  border: 1px solid var(--adv-border);
  color: var(--adv-text-muted);
  border-radius: var(--adv-radius-sm);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: "Plus Jakarta Sans", sans-serif;
  font-weight: 600;
  transition: all 0.18s;
  line-height: 1;
  flex-shrink: 0;
}

.adv-page-btn:hover:not(:disabled):not(.active) {
  background: var(--adv-surface2);
  border-color: var(--adv-primary-light);
  color: var(--adv-text);
}

.adv-page-btn.active {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
  cursor: default;
}

.adv-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.adv-page-btn.nav {
  font-size: 0.9rem;
}

.adv-page-ellipsis {
  color: var(--adv-text-muted);
  font-size: 0.82rem;
  padding: 0 0.15rem;
  line-height: 34px;
}

.adv-page-size-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.adv-page-size-label {
  font-size: 0.75rem;
  color: var(--adv-text-muted);
  white-space: nowrap;
}

.adv-page-size-select {
  background: var(--adv-surface);
  border: 1px solid var(--adv-border);
  border-radius: var(--adv-radius-sm);
  color: var(--adv-text);
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-family: "Plus Jakarta Sans", sans-serif;
  cursor: pointer;
  outline: none;
  transition: border-color 0.18s;
  color-scheme: dark;
}

.adv-page-size-select:focus {
  border-color: var(--adv-primary-light);
}

@media (max-width: 576px) {
  .adv-pagination-wrap {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .adv-pagination-controls {
    width: 100%;
    justify-content: center;
  }
}

/* ===================== TIME SLOT BADGE ON CARD ===================== */
.adv-device-timeslot-badge {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  background: rgba(139, 92, 246, 0.85);
  color: #fff;
  border-radius: 6px;
  padding: 0.15rem 0.45rem;
  font-size: 0.6rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 0.2rem;
  letter-spacing: 0.2px;
}