/**
 * ============================================================
 * Domotica Feroby v2.0 — BMS Core
 * ============================================================
 * @file        public/css/design-system.css
 * @version     1.0.0
 * @date        2026-09-08
 * @author      Feroby
 * @copyright   Copyright (c) 2026 Feroby. All rights reserved.
 * ------------------------------------------------------------
 * DESCRIZIONE:
 *   Sistema di design centralizzato. Definisce tutti i token CSS
 *   (variabili custom), il tema dark/light automatico, la tipografia
 *   Inter, le utility class di base e le animazioni globali.
 * ------------------------------------------------------------
 * CONTENUTO:
 *   - Token CSS (colori, spazi, raggi, ombre, transizioni)
 *   - Tema dark (default) e light (prefers-color-scheme)
 *   - Reset e normalize base
 *   - Tipografia Inter
 *   - Utility classes (flex, grid, gap, etc.)
 *   - Animazioni globali (fade, slide, pulse, glow)
 *   - Scrollbar custom (dark theme)
 * ------------------------------------------------------------
 * SCOPO:
 *   Single source of truth per il sistema visivo del BMS Feroby.
 *   Tutti i componenti devono usare i token definiti qui.
 * ------------------------------------------------------------
 * CHANGELOG:
 *   1.0.0 — 2026-09-08 — Creazione iniziale
 * ============================================================
 */

/* ── Google Fonts: Inter ───────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ── Token CSS — Dark Mode (Default) ──────────────────────────────────────── */
:root {
  /* Colori di background */
  --bg-primary: #0d1117;
  --bg-secondary: #0a0e14;
  --bg-card: #161b22;
  --bg-card-hover: #1c2230;
  --bg-elevated: #1e2432;
  --bg-overlay: rgba(13, 17, 23, 0.85);

  /* Bordi */
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --border-focus: rgba(79, 142, 247, 0.6);

  /* Accent Colors */
  --accent-blue: #4f8ef7;
  --accent-blue-light: #7aadfa;
  --accent-blue-dark: #2d6fd4;
  --accent-green: #22c55e;
  --accent-green-dark: #16a34a;
  --accent-amber: #f59e0b;
  --accent-amber-dark: #d97706;
  --accent-red: #ef4444;
  --accent-red-dark: #dc2626;
  --accent-purple: #a855f7;
  --accent-cyan: #06b6d4;
  --accent-sky: #38bdf8;

  /* Testo */
  --text-primary: #e6edf3;
  --text-secondary: #7d8590;
  --text-muted: #484f58;
  --text-inverse: #0d1117;
  --text-link: #4f8ef7;

  /* Tipografia */
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  /* Dimensioni font */
  --text-xs: 0.75rem;
  /* 12px */
  --text-sm: 0.875rem;
  /* 14px */
  --text-base: 1rem;
  /* 16px */
  --text-lg: 1.125rem;
  /* 18px */
  --text-xl: 1.25rem;
  /* 20px */
  --text-2xl: 1.5rem;
  /* 24px */
  --text-3xl: 1.875rem;
  /* 30px */
  --text-4xl: 2.25rem;
  /* 36px */

  /* Spaziatura */
  --space-1: 0.25rem;
  /* 4px */
  --space-2: 0.5rem;
  /* 8px */
  --space-3: 0.75rem;
  /* 12px */
  --space-4: 1rem;
  /* 16px */
  --space-5: 1.25rem;
  /* 20px */
  --space-6: 1.5rem;
  /* 24px */
  --space-8: 2rem;
  /* 32px */
  --space-10: 2.5rem;
  /* 40px */
  --space-12: 3rem;
  /* 48px */
  --space-16: 4rem;
  /* 64px */

  /* Border Radius */
  --radius-sm: 0.25rem;
  /* 4px */
  --radius-md: 0.5rem;
  /* 8px */
  --radius-lg: 0.75rem;
  /* 12px */
  --radius-xl: 1rem;
  /* 16px */
  --radius-2xl: 1.5rem;
  /* 24px */
  --radius-full: 9999px;

  /* Ombre */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);
  --shadow-glow-blue: 0 0 20px rgba(79, 142, 247, 0.35);
  --shadow-glow-green: 0 0 20px rgba(34, 197, 94, 0.35);
  --shadow-glow-amber: 0 0 20px rgba(245, 158, 11, 0.35);
  --shadow-glow-red: 0 0 20px rgba(239, 68, 68, 0.35);

  /* Transizioni */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
  --transition-spring: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --bottom-nav-height: 72px;
  --content-max-width: 1400px;

  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal: 300;
  --z-toast: 400;
  --z-tooltip: 500;
}

/* ── Light Mode Override ─────────────────────────────────────────────────────
   Attivato automaticamente quando il dispositivo usa tema chiaro.
   I componenti usano le variabili — si adattano automaticamente.
*/
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-overlay: rgba(248, 250, 252, 0.9);

    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.16);
    --border-focus: rgba(79, 142, 247, 0.5);

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-inverse: #f8fafc;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.2);
  }
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Tipografia ───────────────────────────────────────────────────────────── */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 {
  font-size: var(--text-4xl);
}

h2 {
  font-size: var(--text-3xl);
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-xl);
}

h5 {
  font-size: var(--text-lg);
}

h6 {
  font-size: var(--text-base);
}

p {
  color: var(--text-secondary);
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--accent-blue-light);
}

strong {
  font-weight: 700;
}

small {
  font-size: var(--text-sm);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
}

/* ── Scrollbar Custom ─────────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Layout Shell ─────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-sticky);
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.app-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
}

/* Mobile: nasconde sidebar, mostra bottom nav */
@media (max-width: 768px) {
  .app-sidebar {
    display: none;
  }

  .app-main {
    margin-left: 0;
    padding-bottom: var(--bottom-nav-height);
  }

  .app-content {
    padding: var(--space-4);
  }
}

/* ── Glassmorphism Card Base ──────────────────────────────────────────────── */
.glass {
  background: rgba(22, 27, 34, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

@media (prefers-color-scheme: light) {
  .glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
  }
}

/* ── Utility Classes ──────────────────────────────────────────────────────── */

/* Flexbox */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.items-end {
  align-items: flex-end;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.flex-1 {
  flex: 1;
}

.flex-none {
  flex: none;
}

.gap-1 {
  gap: var(--space-1);
}

.gap-2 {
  gap: var(--space-2);
}

.gap-3 {
  gap: var(--space-3);
}

.gap-4 {
  gap: var(--space-4);
}

.gap-6 {
  gap: var(--space-6);
}

.gap-8 {
  gap: var(--space-8);
}

/* Grid */
.grid {
  display: grid;
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.grid-auto-sm {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* Testo */
.text-xs {
  font-size: var(--text-xs);
}

.text-sm {
  font-size: var(--text-sm);
}

.text-lg {
  font-size: var(--text-lg);
}

.text-xl {
  font-size: var(--text-xl);
}

.text-2xl {
  font-size: var(--text-2xl);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.font-black {
  font-weight: 900;
}

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

.text-muted {
  color: var(--text-muted);
}

.text-blue {
  color: var(--accent-blue);
}

.text-green {
  color: var(--accent-green);
}

.text-amber {
  color: var(--accent-amber);
}

.text-red {
  color: var(--accent-red);
}

.uppercase {
  text-transform: uppercase;
}

.tracking-wide {
  letter-spacing: 0.05em;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Spaziatura */
.p-1 {
  padding: var(--space-1);
}

.p-2 {
  padding: var(--space-2);
}

.p-3 {
  padding: var(--space-3);
}

.p-4 {
  padding: var(--space-4);
}

.p-6 {
  padding: var(--space-6);
}

.px-3 {
  padding-left: var(--space-3);
  padding-right: var(--space-3);
}

.px-4 {
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

.py-2 {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

.py-3 {
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

.mt-1 {
  margin-top: var(--space-1);
}

.mt-2 {
  margin-top: var(--space-2);
}

.mt-4 {
  margin-top: var(--space-4);
}

.mb-2 {
  margin-bottom: var(--space-2);
}

.mb-4 {
  margin-bottom: var(--space-4);
}

.ml-auto {
  margin-left: auto;
}

.mr-auto {
  margin-right: auto;
}

/* Overflow */
.overflow-hidden {
  overflow: hidden;
}

.overflow-auto {
  overflow: auto;
}

/* Visibilità */
.hidden {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

/* Cursor */
.cursor-pointer {
  cursor: pointer;
}

.cursor-not-allowed {
  cursor: not-allowed;
}

/* Opacità */
.opacity-50 {
  opacity: 0.5;
}

.opacity-75 {
  opacity: 0.75;
}

/* Width/Height */
.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.min-h-screen {
  min-height: 100vh;
}

/* ── Animazioni Globali ───────────────────────────────────────────────────── */

/* Fade in */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

/* Slide in from left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide in from top */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

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

/* Scale in */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Pulse glow */
@keyframes pulseGlow {

  0%,
  100% {
    box-shadow: 0 0 8px rgba(79, 142, 247, 0.3);
  }

  50% {
    box-shadow: 0 0 20px rgba(79, 142, 247, 0.6);
  }
}

/* Pulse glow green */
@keyframes pulseGlowGreen {

  0%,
  100% {
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
  }

  50% {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.6);
  }
}

/* Pulse glow amber */
@keyframes pulseGlowAmber {

  0%,
  100% {
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
  }

  50% {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.7);
  }
}

/* Spinner rotation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Breathe (scale oscillante) */
@keyframes breathe {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

/* Shimmer (loading skeleton) */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

/* Utility animation classes */
.animate-fadeIn {
  animation: fadeIn 0.35s ease forwards;
}

.animate-scaleIn {
  animation: scaleIn 0.25s ease forwards;
}

.animate-slideLeft {
  animation: slideInLeft 0.3s ease forwards;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-pulse {
  animation: breathe 2s ease-in-out infinite;
}

.animate-glow-blue {
  animation: pulseGlow 2s ease-in-out infinite;
}

.animate-glow-green {
  animation: pulseGlowGreen 2s ease-in-out infinite;
}

.animate-glow-amber {
  animation: pulseGlowAmber 2s ease-in-out infinite;
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg,
      var(--bg-card) 25%,
      var(--bg-elevated) 50%,
      var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

/* ── Status indicator dots ───────────────────────────────────────────────── */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
}

.status-dot.warning {
  background: var(--accent-amber);
  box-shadow: 0 0 6px var(--accent-amber);
}

.status-dot.error {
  background: var(--accent-red);
  box-shadow: 0 0 6px var(--accent-red);
}

.status-dot.offline {
  background: var(--text-muted);
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
}

/* ── Responsive Breakpoints ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: var(--text-3xl);
  }

  h2 {
    font-size: var(--text-2xl);
  }

  .hide-mobile {
    display: none;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none;
  }
}