/* ==============================================================================
   Homepage Custom CSS: Admin Mode, Family View, Desktop Overhaul & Modals
   ============================================================================== */

/* Family Mode: Hide Resource Gauges & Technical Stats (Keep Clock & Weather!) */
html.mode-family .services-group.family-hidden,
html.mode-family .service.family-hidden,
html.mode-family .bookmark-group.family-hidden,
html.mode-family .family-hidden,
html.mode-family .widget-resources,
html.mode-family .widget-resource,
html.mode-family [data-widget-type="resources"],
html.mode-family .information-widget-resources,
html.mode-family .information-widget-glances {
  display: none !important;
}

/* Ensure DateTime and OpenMeteo Weather widgets remain visible at all times */
html.mode-family .widget-datetime,
html.mode-family .widget-openmeteo,
.widget-datetime,
.widget-openmeteo {
  display: block !important;
}

/* Floating Admin Pill Button - Docked cleanly at bottom right on ALL screens */
#admin-pill-toggle {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  top: auto !important;
  z-index: 9999 !important;
  background: #0284c7 !important;
  color: #ffffff !important;
  padding: 9px 20px !important;
  border-radius: 9999px !important;
  font-weight: 600 !important;
  font-size: 14px !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  user-select: none !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

#admin-pill-toggle:hover {
  background: #0369a1 !important;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45) !important;
}

/* ==============================================================================
   Desktop UI Overhaul (min-width: 768px): Substantial, Tactile, Modern Cards
   ============================================================================== */
@media (min-width: 768px) {
  /* Service Card Container */
  .service-card {
    min-height: 84px !important;
    padding: 16px 20px !important;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.75) 0%, rgba(15, 23, 42, 0.85) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 16px !important;
    backdrop-filter: blur(12px) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25) !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
                border-color 0.25s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow: visible !important;
  }

  .service-card:hover {
    transform: translateY(-3px) scale(1.01) !important;
    border-color: rgba(56, 189, 248, 0.5) !important;
    box-shadow: 0 12px 28px -4px rgba(0, 0, 0, 0.6), 0 0 16px rgba(2, 132, 199, 0.25) !important;
  }

  /* Server monitoring cards with 4 metric boxes */
  .service-card:has([class*="widget"]) {
    min-height: 125px !important;
    padding-bottom: 18px !important;
  }

  .service-card:has([class*="widget"]) .service-title {
    margin-bottom: 12px !important;
  }

  /* Metric Badges Styling */
  .service-card [class*="widget"] {
    max-width: 100% !important;
  }

  /* Prominent, crisp icons */
  .service-icon {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    margin-right: 14px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    padding: 4px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2) !important;
  }

  /* Bold, legible title */
  .service-name {
    font-size: 16px !important;
    font-weight: 700 !important;
    color: #f8fafc !important;
    letter-spacing: -0.01em !important;
    line-height: 1.25 !important;
  }

  /* Natural, comfortable description text */
  .service-description {
    font-size: 13px !important;
    font-weight: 400 !important;
    color: #94a3b8 !important;
    margin-top: 4px !important;
    line-height: 1.4 !important;
    white-space: normal !important;
    overflow: visible !important;
    opacity: 0.9 !important;
  }

  /* Group Heading Typography */
  .service-group-name {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: #cbd5e1 !important;
    letter-spacing: 0.02em !important;
    margin-bottom: 8px !important;
  }

  /* ==============================================================================
     Top Section Overhaul: Sleek Glass Navigation Bar & Cohesive Badges
     ============================================================================== */
  #information-widgets {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 18px !important;
    padding: 12px 24px !important;
    margin: 16px 0 28px 0 !important;
    backdrop-filter: blur(16px) !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35) !important;
  }

  #widgets-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 20px !important;
  }

  /* Telemetry Stats Pill (Left) */
  .information-widget-resources,
  .widget-resources,
  [data-widget-type="resources"] {
    background: rgba(15, 23, 42, 0.55) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 12px !important;
    padding: 8px 16px !important;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05) !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Remove awkward dangling text below telemetry gauges */
  .information-widget-resources div[class*="text-center"],
  .information-widget-resources div[class*="ml-6"] {
    display: none !important;
  }

  /* Right Side Widgets Group */
  #information-widgets-right {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    justify-content: flex-end !important;
  }

  /* Date & Time Pill */
  .information-widget-datetime {
    background: rgba(15, 23, 42, 0.55) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 12px !important;
    padding: 8px 18px !important;
    white-space: nowrap !important;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05) !important;
    font-weight: 600 !important;
    font-size: 15px !important;
    color: #f8fafc !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Weather (OpenMeteo) Pill */
  .information-widget-openmeteo {
    background: rgba(15, 23, 42, 0.55) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    border-radius: 12px !important;
    padding: 8px 18px !important;
    white-space: nowrap !important;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05) !important;
    display: flex !important;
    align-items: center !important;
  }

  /* Search Input Pill */
  .information-widget-search {
    display: flex !important;
    align-items: center !important;
  }

  .information-widget-search form,
  .information-widget-search .information-widget-form {
    border-radius: 12px !important;
    background: rgba(15, 23, 42, 0.55) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    padding: 4px 12px !important;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05) !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
  }

  .information-widget-search input {
    background: transparent !important;
    border: none !important;
    color: #f8fafc !important;
    outline: none !important;
    font-size: 14px !important;
    min-width: 180px !important;
  }

  .information-widget-search form:focus-within,
  .information-widget-search .information-widget-form:focus-within {
    border-color: rgba(56, 189, 248, 0.5) !important;
    box-shadow: 0 0 14px rgba(2, 132, 199, 0.25) !important;
  }
}

/* Modals */
.homelab-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.homelab-modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
  color: #f8fafc;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.65);
}

.homelab-modal-card.wide-viewer {
  max-width: 1200px;
  width: 95vw;
  height: 85vh;
  display: flex;
  flex-direction: column;
}

.homelab-modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.homelab-modal-desc {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 18px;
  line-height: 1.4;
}

.homelab-input {
  width: 100%;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
  font-size: 20px;
  color: #f8fafc;
  text-align: center;
  letter-spacing: 6px;
  margin-bottom: 20px;
  outline: none;
}

.homelab-input:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.homelab-btn-primary {
  flex: 1;
  background: #0284c7;
  color: white;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.homelab-btn-primary:hover {
  background: #0369a1;
}

.homelab-btn-secondary {
  flex: 1;
  background: #334155;
  color: #cbd5e1;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.homelab-btn-secondary:hover {
  background: #475569;
}

/* Visibility Checklist */
.vis-checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  max-height: 320px;
  overflow-y: auto;
}

.vis-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1e293b;
  border-radius: 8px;
  font-size: 14px;
}

/* Remote Viewer Tabs & Frame */
.viewer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.viewer-tab-btn {
  background: #1e293b;
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.viewer-tab-btn.active {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
}

.viewer-frame-wrap {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: #020617;
  overflow: hidden;
}

.viewer-frame {
  width: 100%;
  height: 100%;
  border: none;
}
