/* Modern Homepage Dashboard Styling */

/* Base theme variables */
:root {
  --primary-color: #4361ee;
  --secondary-color: #3a0ca3;
  --accent-color: #f72585;
  --background-color: #121212;
  --card-background: rgba(30, 30, 40, 0.8);
  --text-color: #f8f9fa;
  --text-secondary: #adb5bd;
  --border-radius: 12px;
  --box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  --transition-speed: 0.3s ease;
}

/* Global styles */
body {
  background: var(--background-color);
  color: var(--text-color);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Card styling */
.service-card {
  background: var(--card-background);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  transition: all var(--transition-speed);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.service-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  border-color: rgba(67, 97, 238, 0.3);
}

/* Favorites container - two columns side by side for top-level favorites only */
#favorites,
[id="favorites"] {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 20px !important;
}

/* Emby and Bookshelf favorite cards - targeted directly via the `id` set in services.yaml */
#emby-large,
#bookshelf-large {
  min-height: 160px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  align-items: stretch !important;
  text-align: center !important;
  font-weight: 700 !important;
  font-size: 1.1rem !important;
  border-radius: var(--border-radius) !important;
  padding: 20px !important;
  transition: transform var(--transition-speed) !important;
  position: relative !important;
  overflow: hidden !important;
  background-color: rgba(15, 15, 25, 0.9) !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
}

#emby-large {
  background-image: url('https://cdn2.steamgriddb.com/thumb/7f725e63957d88b0acf21054fa3cfaac.jpg') !important;
}

#bookshelf-large {
  background-image: url('https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQhWMG3-c5E_EfegD_wld8u1W4-bUsAY4Nv-vSC28_mBA&s=10') !important;
}

#emby-large:hover,
#bookshelf-large:hover {
  transform: scale(1.05) !important;
}

/* Hide the default small favicon image so the large background favicon is the only icon shown */
#emby-large img,
#bookshelf-large img {
  display: none !important;
}

/* Hide the icon so the large background image is the only visual */
#emby-large .service-icon,
#bookshelf-large .service-icon {
  display: none !important;
}

/* Keep the link filling the whole card (so the whole button stays clickable) and drop the blur/tint so the image shows clean */
#emby-large .service-card,
#bookshelf-large .service-card {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  background: transparent !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
  border: none !important;
}

#emby-large .service-title,
#bookshelf-large .service-title {
  flex: 1 1 auto !important;
  width: 100% !important;
  height: 100% !important;
  align-items: stretch !important;
  justify-content: flex-start !important;
  pointer-events: auto !important;
}

#emby-large .service-title-text,
#bookshelf-large .service-title-text {
  flex: 1 1 auto !important;
  width: 100% !important;
  height: 100% !important;
  pointer-events: auto !important;
}

/* Hide the name and description entirely - the card is now just the clickable image */
#emby-large .service-name,
#bookshelf-large .service-name {
  font-size: 0 !important;
  padding: 0 !important;
}

#emby-large .service-description,
#bookshelf-large .service-description {
  font-size: 0 !important;
}

/* Ensure link elements fill the entire card for full clickability */
#emby-large a,
#bookshelf-large a {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  text-decoration: none !important;
  cursor: pointer !important;
  pointer-events: auto !important;
}

#emby-large,
#bookshelf-large {
  cursor: pointer !important;
  pointer-events: auto !important;
}

/* Force white text on Emby/Bookshelf cards and their descendants */
#emby-large,
#bookshelf-large,
#emby-large *,
#bookshelf-large * {
  opacity: 1 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background-color: transparent !important;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 1) !important;
  pointer-events: auto !important;
}

/* Widget styling */
.widgets-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.widget-card {
  background: var(--card-background);
  border-radius: var(--border-radius);
  padding: 15px;
  text-align: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-speed);
}

.widget-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--box-shadow);
}

/* Search widget */
.search-widget {
  background: linear-gradient(135deg, rgba(67, 97, 238, 0.3), rgba(58, 12, 163, 0.3));
  border-radius: var(--border-radius);
  padding: 20px;
  text-align: center;
  margin-bottom: 30px;
}

.search-widget input {
  width: 100%;
  max-width: 500px;
  padding: 12px 20px;
  border-radius: 50px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 1rem;
  backdrop-filter: blur(5px);
  transition: all var(--transition-speed);
}

.search-widget input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 20px rgba(67, 97, 238, 0.3);
}

/* Category headers */
.category-header {
  display: flex;
  align-items: center;
  margin: 30px 0 15px;
  padding: 0 10px;
}

.category-header h2 {
  margin: 0;
  font-weight: 600;
  background: linear-gradient(to right, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Service icons - force square container so all icons align consistently */
.service-icon {
  width: 48px !important;
  height: 48px !important;
  min-height: 48px !important;
  margin-bottom: 10px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform var(--transition-speed);
}

.service-icon img {
  width: 32px !important;
  height: 32px !important;
  object-fit: contain !important;
  max-width: none !important;
  max-height: none !important;
  margin: auto !important;
}

.service-card:hover .service-icon {
  transform: scale(1.1);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #emby-large,
  #bookshelf-large {
    min-height: 120px !important;
    padding: 15px !important;
  }

  .widgets-container {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }
}

/* Loading state */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Footer styling */
footer {
  text-align: center;
  padding: 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 30px;
}

/* Animation for service cards */
.service-card {
  animation: fadeInUp 0.6s ease forwards;
  opacity: 0;
  transform: translateY(20px);
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Sequential animation for cards */
.service-card:nth-child(1) { animation-delay: 0.1s; }
.service-card:nth-child(2) { animation-delay: 0.2s; }
.service-card:nth-child(3) { animation-delay: 0.3s; }
.service-card:nth-child(4) { animation-delay: 0.4s; }
.service-card:nth-child(5) { animation-delay: 0.5s; }
.service-card:nth-child(6) { animation-delay: 0.6s; }