/* =====================================================
   app-theme.css — CalendarioGare UI Theme v2.0
   Design system: variabili, animazioni, componenti
   ===================================================== */

/* ── CSS Variables ── */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #2563eb;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.10), 0 4px 12px rgba(0,0,0,0.06);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Keyframes ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes countUp {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes slideIndicator {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

/* ── Page transition ── */
.page-enter {
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

/* ── Buttons ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.6rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(37,99,235,0.35); transform: translateY(-1px); color: #fff; text-decoration: none; }
.btn-primary:active::after { opacity: 1; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn-secondary:hover { background: #e2e8f0; }

/* ── Badge / Pill ── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-blue    { background: #dbeafe; color: #1d4ed8; }
.badge-green   { background: #d1fae5; color: #065f46; }
.badge-yellow  { background: #fef3c7; color: #92400e; }
.badge-red     { background: #fee2e2; color: #991b1b; }
.badge-purple  { background: #ede9fe; color: #6d28d9; }
.badge-pink    { background: #fce7f3; color: #9d174d; }
.badge-orange  { background: #ffedd5; color: #9a3412; }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-regionale  { background: #dbeafe; color: #1d4ed8; }
.badge-provinciale { background: #f1f5f9; color: #64748b; }

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #374151;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  padding: 0.8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}
.table tbody tr {
  transition: background var(--transition);
  position: relative;
}
.table tbody tr td:first-child {
  font-weight: 600;
  color: var(--text-primary);
}
.table tbody tr:hover td {
  background: var(--accent-light);
}
.table tbody tr:hover td:first-child::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
  animation: slideIndicator 0.15s ease;
}
.table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }

/* ── Input ── */
.input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.55rem 0.875rem;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}
.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.input::placeholder { color: var(--text-muted); }

/* ── Tag ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--text-secondary);
}

/* ── Spinner ── */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
  text-align: center;
  gap: 1rem;
}
.empty-state svg { opacity: 0.35; }
.empty-state-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }
.empty-state-text  { font-size: 0.85rem; color: var(--text-muted); }

/* ── Stat card ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.4s ease both;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  animation: countUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.stat-card-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Skeleton shimmer ── */
.skeleton {
  background: linear-gradient(
    90deg,
    #f1f5f9 25%,
    #e2e8f0 37%,
    #f1f5f9 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text   { height: 0.875rem; margin: 0.2rem 0; }
.skeleton-title  { height: 1.25rem; width: 60%; margin-bottom: 0.5rem; }
.skeleton-circle { border-radius: 50%; }
.skeleton-row    { height: 48px; margin-bottom: 1px; border-radius: 0; }

/* ── Progress bar ── */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7c3aed);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Sidebar enhancements ── */
.sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%) !important;
}
.sidebar-logo-text {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-item {
  position: relative;
  overflow: hidden;
}
.nav-item-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 65%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  animation: slideIndicator 0.2s ease;
}
.nav-item:not(.nav-item-active)::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--surface-hover);
  opacity: 0;
  transition: opacity var(--transition);
  border-radius: 9px;
  z-index: -1;
}
.nav-item:not(.nav-item-active):hover::after { opacity: 1; }

/* ── Topbar glass effect (mobile) ── */
@media (max-width: 768px) {
  .topbar {
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    background: rgba(255,255,255,0.85) !important;
  }
}

/* ── Animated tab underline ── */
.tabs-container {
  position: relative;
  display: flex;
  gap: 0;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 10px;
  width: fit-content;
}
.tab-btn-animated {
  background: transparent;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition);
  position: relative;
  z-index: 1;
}
.tab-btn-animated.active {
  color: var(--accent);
  font-weight: 700;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.tab-btn-animated:hover:not(.active) { color: var(--text-primary); }

/* ── Medal ranks ── */
.medal-1 { font-size: 1.25rem; }
.medal-2 { font-size: 1.25rem; }
.medal-3 { font-size: 1.25rem; }
.top3-row td { background: linear-gradient(90deg, rgba(37,99,235,0.03) 0%, transparent 50%) !important; }
.top1-row td { background: linear-gradient(90deg, rgba(253,186,3,0.08) 0%, transparent 50%) !important; }

/* ── Login enhancements ── */
.login-wrapper {
  background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 40%, #e0e7ff 100%);
  position: relative;
  overflow: hidden;
}
.login-wrapper::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(37,99,235,0.06) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  pointer-events: none;
}
.login-wrapper::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(124,58,237,0.05) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  pointer-events: none;
}

/* ── Utility ── */
.animate-delay-100 { animation-delay: 0.1s; }
.animate-delay-200 { animation-delay: 0.2s; }
.animate-delay-300 { animation-delay: 0.3s; }
.animate-delay-400 { animation-delay: 0.4s; }

/* ── Slide / Scale keyframes ── */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.slide-in-right { animation: slideInRight 0.3s cubic-bezier(0.4,0,0.2,1) both; }
.slide-in-up    { animation: slideInUp    0.3s cubic-bezier(0.4,0,0.2,1) both; }
.scale-in       { animation: scaleIn      0.25s cubic-bezier(0.4,0,0.2,1) both; }

/* Stagger delay helpers */
.delay-1 { animation-delay: 0.05s; }
.delay-2 { animation-delay: 0.10s; }
.delay-3 { animation-delay: 0.15s; }
.delay-4 { animation-delay: 0.20s; }
.delay-5 { animation-delay: 0.25s; }

/* Hover lift */
.hover-lift { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.hover-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* Inline modal overlay */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(3px);
  z-index: 500;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}
.modal-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  padding: 1.75rem;
  width: 100%;
  max-width: 440px;
  animation: scaleIn 0.2s cubic-bezier(0.4,0,0.2,1) both;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: #1e293b; margin: 0; }
.modal-close {
  background: none; border: none; color: #94a3b8;
  cursor: pointer; padding: 4px; border-radius: 6px;
  display: flex; align-items: center;
  transition: color 0.15s, background 0.15s;
}
.modal-close:hover { color: #1e293b; background: #f1f5f9; }
.modal-field { margin-bottom: 1.1rem; }
.modal-label { display: block; font-size: 0.82rem; font-weight: 600; color: #374151; margin-bottom: 0.4rem; }
.modal-input {
  width: 100%; background: #fff; border: 1.5px solid #cbd5e1;
  border-radius: 8px; color: #1e293b; padding: 0.55rem 0.85rem;
  font-size: 0.9rem; transition: border-color 0.2s, box-shadow 0.2s; box-sizing: border-box;
}
.modal-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.5rem; }
.modal-error { color: #dc2626; font-size: 0.83rem; margin-top: -0.5rem; margin-bottom: 0.75rem; }

/* Sortable table headers */
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { background: #e8f0fe !important; color: #1d4ed8; }
.sort-icon { display: inline-block; margin-left: 4px; opacity: 0.4; font-size: 0.8em; }
.sort-icon.active { opacity: 1; color: #2563eb; }

/* -- Filters Grid (GareList, ProvvedimentiList) -- */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  align-items: end;
}
.filters-grid > div { min-width: 0; }
@media (max-width: 480px) {
  .filters-grid { grid-template-columns: 1fr; }
}
