/*
 * zamolxis.uk — Homelab Dashboard
 * Copyright (C) 2026 Adrian Birnaz <ad.birnaz@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */

/* ----------------------------
   1. Design Tokens
   ---------------------------- */
:root {
  /* Palette */
  --color-bg:             #0c0e14;
  --color-surface:        #151821;
  --color-surface-hover:  #1c2030;
  --color-border:         #232836;
  --color-border-hover:   #3a4060;
  --color-text:           #e4e7ed;
  --color-text-secondary: #8890a4;
  --color-text-muted:     #5a6178;
  --color-accent:         #FC6713;
  --color-accent-soft:    rgba(91, 140, 255, 0.08);
  --color-accent-glow:    rgba(91, 140, 255, 0.15);

  /* Category indicators */
  --cat-media:  #e06c75;
  --cat-prod:   #61afef;
  --cat-infra:  #98c379;
  --cat-ai:     #c678dd;
  --cat-utm:    #e5c07b;

  /* Typography */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Radii */
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-card:       0 1px 3px rgba(0, 0, 0, 0.24);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.32);

  /* Transitions */
  --ease-out:   cubic-bezier(0.33, 1, 0.68, 1);
  --duration:   180ms;

  /* Spacing */
  --space-xs:  4px;
  --space-sm:  8px;
  --space-md:  16px;
  --space-lg:  24px;
  --space-xl:  32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
}


/* ----------------------------
   2. Reset & Base
   ---------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}


/* ----------------------------
   3. Dashboard Layout
   ---------------------------- */
.dashboard {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
}


/* ----------------------------
   4. Header
   ---------------------------- */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.header__tld {
  color: var(--color-accent);
  font-weight: 600;
}

.header__subtitle {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
}


/* ----------------------------
   5. Mode Switch
   ---------------------------- */
.mode-switch {
  display: flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
  flex-shrink: 0;
}

.mode-switch__btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  transition:
    background var(--duration) var(--ease-out),
    color var(--duration) var(--ease-out);
}

.mode-switch__btn:hover {
  color: var(--color-text-secondary);
}

.mode-switch__btn.active {
  background: var(--color-accent);
  color: #fff;
}

.mode-switch__btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.mode-switch__icon {
  flex-shrink: 0;
}


/* ----------------------------
   6. Search (discreet — appears on focus)
   ---------------------------- */
.search {
  position: relative;
  margin-bottom: var(--space-lg);
  max-width: 260px;
}

.search__icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  opacity: 0.4;
  transition: opacity var(--duration) var(--ease-out);
}

.search__input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-text);
  outline: none;
  transition:
    background var(--duration) var(--ease-out),
    border-color var(--duration) var(--ease-out);
}

.search__input::placeholder {
  color: var(--color-text-muted);
  opacity: 0.5;
}

.search:hover .search__icon,
.search__input:focus ~ .search__icon,
.search__input:not(:placeholder-shown) ~ .search__icon {
  opacity: 0.7;
}

.search__input:hover {
  background: var(--color-surface);
}

.search__input:focus,
.search__input:not(:placeholder-shown) {
  background: var(--color-surface);
  border-color: var(--color-border);
}


/* ----------------------------
   7. Category Section
   ---------------------------- */
.category {
  margin-bottom: var(--space-xl);
}

.category:last-child {
  margin-bottom: 0;
}

.category__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-left: var(--space-xs);
}

.category__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.category__name {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
}

.category--hidden {
  display: none;
}


/* ----------------------------
   8. Service Cards Grid
   ---------------------------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-md);
}

.card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md) 18px;
  transition:
    border-color var(--duration) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    transform var(--duration) var(--ease-out),
    background var(--duration) var(--ease-out);
}

.card:hover {
  border-color: var(--color-border-hover);
  background: var(--color-surface-hover);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.card--hidden {
  display: none;
}

.card--disabled {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}


/* ----------------------------
   9. Card Logo
   ---------------------------- */
.card__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.04);
}

.card__logo-fallback {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  user-select: none;
}


/* ----------------------------
   10. Card Content
   ---------------------------- */
.card__info {
  min-width: 0;
  flex: 1;
}

.card__name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}

.card__url {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card__url--badge {
  font-family: var(--font-sans);
  font-style: italic;
}

.card__status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--duration) var(--ease-out);
}

.card:hover .card__status {
  opacity: 1;
}


/* ----------------------------
   11. Empty State
   ---------------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-muted);
}

.empty-state__icon {
  margin-bottom: var(--space-md);
  opacity: 0.4;
}

.empty-state__text {
  font-size: 0.95rem;
}


/* ----------------------------
   12. Footer
   ---------------------------- */
.footer {
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
  font-size: 0.78rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.footer__dot {
  opacity: 0.5;
}


/* ----------------------------
   13. Responsive
   ---------------------------- */
@media (max-width: 640px) {
  .dashboard {
    padding: var(--space-lg) var(--space-md);
  }

  .header {
    flex-direction: column;
    gap: var(--space-md);
  }

  .mode-switch {
    align-self: stretch;
  }

  .mode-switch__btn {
    flex: 1;
    justify-content: center;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .card {
    padding: 14px var(--space-md);
  }

  .search {
    max-width: 100%;
  }
}

@media (min-width: 641px) and (max-width: 860px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
