/* ═══════════════════════════════════════════════════════════
   MODULAR FRAMEWORK — Admin Theme v2.0
   CRM Autodemolizione
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables · Refined Industrial Theme ─────────── */
:root {
  --green:         #1a5566;
  --green-dark:    #133C46;
  --green-light:   #237a8a;
  --green-pale:    #d4eef5;
  --gold:          #d4a017;
  --gold-pale:     #fef9e7;
  --charcoal:      #1c1c1e;
  --charcoal-2:    #2c2c2e;

  --bg-root:       #f4f1ec;
  --bg-body:       #f8f6f2;
  --bg-sidebar:    #133C46;
  --bg-card:       #ffffff;
  --bg-card-hover: #f5f3ee;
  --bg-input:      #ffffff;
  --bg-overlay:    rgba(28,28,30,0.55);

  --border:        #e5e7eb;
  --border-light:  #f0f0f0;
  --border-hover:  #d1d5db;
  --border-focus:  rgba(19,60,70,0.5);

  --text-primary:   #1c1c1e;
  --text-secondary: #4b5563;
  --text-tertiary:  #9ca3af;
  --text-inverse:   #ffffff;

  --accent:         #1a5566;
  --accent-hover:   #237a8a;
  --accent-muted:   rgba(19,60,70,0.10);
  --accent-glow:    rgba(19,60,70,0.20);

  --success:       #16a34a;
  --success-muted: rgba(22,163,74,0.10);
  --warning:       #d4a017;
  --warning-muted: rgba(212,160,23,0.10);
  --danger:        #dc2626;
  --danger-muted:  rgba(220,38,38,0.08);
  --info:          #2563eb;
  --info-muted:    rgba(37,99,235,0.08);

  --sidebar-w:      260px;
  --sidebar-collapsed-w: 72px;
  --header-h:       64px;
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.12);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --font-body:  'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Syne', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration:   0.25s;
}


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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  overflow: hidden;
  height: 100vh;
}

::selection { background: var(--accent); color: #fff; }

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

h1, h2, h3, .syne { font-family: var(--font-heading, 'Syne'), sans-serif; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.22); }


/* ══════════════════════════════════════════════════════════
   ADMIN SHELL LAYOUT
   ══════════════════════════════════════════════════════════ */

.admin {
  display: flex;
  height: 100vh;
  overflow: hidden;
}


/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: none;
  display: flex;
  flex-direction: column;
  transition: width var(--duration) var(--ease-out);
  flex-shrink: 0;
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-w); }

/* Brand */
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  min-height: 64px;
}

.sidebar__logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar__brand-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--duration);
}

.sidebar.collapsed .sidebar__brand-text { opacity: 0; width: 0; }

.sidebar__brand-name {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.05rem;
  color: #ffffff;
  white-space: nowrap;
}

.sidebar__brand-sub {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.45);
  font-weight: 500;
  white-space: nowrap;
}

.sidebar__collapse-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--duration);
  flex-shrink: 0;
}

.sidebar__collapse-btn:hover { background: rgba(255,255,255,0.08); color: #ffffff; }

.sidebar.collapsed .sidebar__collapse-btn {
  transform: rotate(180deg);
  margin-left: 0;
}

/* Nav */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar__section { margin-bottom: 16px; }

.sidebar__section-title {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 8px 12px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--duration);
}

.sidebar.collapsed .sidebar__section-title { opacity: 0; height: 0; padding: 0; margin: 0; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.60);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all var(--duration) var(--ease-out);
  white-space: nowrap;
  cursor: pointer;
}

.sidebar__link:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.sidebar__link--active {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  font-weight: 600;
}

.sidebar__link-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.sidebar__link-text {
  overflow: hidden;
  transition: opacity var(--duration);
}

.sidebar.collapsed .sidebar__link-text { opacity: 0; width: 0; }
.sidebar.collapsed .sidebar__link { justify-content: center; padding: 10px; }

/* Footer */
.sidebar__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
  min-height: 60px;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  overflow: hidden;
}

.sidebar__avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  font-weight: 700;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar__user-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--duration);
}

.sidebar.collapsed .sidebar__user-info { opacity: 0; width: 0; }

.sidebar__user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
}

.sidebar__user-role {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.sidebar__logout {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: all var(--duration);
  flex-shrink: 0;
}

.sidebar__logout:hover { background: rgba(220,38,38,0.15); color: #f87171; }

.sidebar.collapsed .sidebar__logout { display: none; }


/* ── Main Area ────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Header */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-card);
}

.header__menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
}

.header__breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.header__breadcrumb-item { color: var(--text-tertiary); }
.header__breadcrumb-sep  { color: var(--text-tertiary); font-size: 0.75rem; }
.header__breadcrumb-current { color: var(--text-primary); font-weight: 600; }

.header__spacer { flex: 1; }

.header__search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  max-width: 260px;
  transition: border-color var(--duration);
}

.header__search:focus-within { border-color: var(--accent); }

.header__search-icon { color: var(--text-tertiary); display: flex; }

.header__search-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
  width: 100%;
}

.header__search-input::placeholder { color: var(--text-tertiary); }

.header__search-kbd {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-tertiary);
  background: var(--bg-card);
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  white-space: nowrap;
}

.header__actions { display: flex; gap: 6px; }

.header__icon-btn {
  position: relative;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--duration);
  display: flex;
  align-items: center;
  justify-content: center;
}

.header__icon-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-body);
}


/* Content Area */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.content__page {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.content__page.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}


/* ── Page Header ──────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header__title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-header__subtitle {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.page-header__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .page-header { flex-direction: column; }
}


/* ══════════════════════════════════════════════════════════
   COMPONENTS
   ══════════════════════════════════════════════════════════ */

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn--primary {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn--secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn--sm { padding: 7px 12px; font-size: 0.78rem; }


/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge--accent  { background: var(--accent-muted); color: var(--accent); }
.badge--success { background: var(--success-muted); color: var(--success); }
.badge--warning { background: var(--warning-muted); color: var(--warning); }
.badge--danger  { background: var(--danger-muted); color: var(--danger); }
.badge--info    { background: var(--info-muted); color: var(--info); }
.badge--neutral { background: rgba(0,0,0,0.05); color: var(--text-secondary); }


/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}


/* ── Toast ────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s var(--ease-spring);
  min-width: 220px;
  max-width: 400px;
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--info    { border-left: 3px solid var(--info); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}


/* ── Dot indicators ───────────────────────────────────── */
.dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dot--online { background: var(--success); box-shadow: 0 0 6px rgba(52,211,153,0.5); }
.dot--away   { background: var(--warning); }
.dot--offline { background: var(--text-tertiary); }


/* ══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════════════════ */

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s;
}

.mobile-overlay.show { opacity: 1; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    z-index: 100;
    width: var(--sidebar-w) !important;
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .mobile-overlay { display: block; pointer-events: none; }
  .mobile-overlay.show { pointer-events: all; }

  .header__menu-btn { display: flex; }

  .header__search { display: none; }

  .content { padding: 16px; }
}
