/* ==========================================================================
   Gestione Squadre Operative - Croce Rossa Italiana (Comitato di Carmagnola)
   Design: Flat & Crisp Operational UI - Logo Ufficiale CRI
   ========================================================================== */

:root {
  --cri-red: #dc2626;
  --cri-red-hover: #b91c1c;
  --cri-red-dark: #991b1b;
  --cri-red-light: rgba(220, 38, 38, 0.15);

  --bg-dark: #0f172a;
  --bg-card: rgba(30, 41, 59, 0.95);
  --bg-card-hover: rgba(51, 65, 85, 0.95);
  --glass-border: rgba(255, 255, 255, 0.12);

  --primary: var(--cri-red);
  --primary-hover: var(--cri-red-hover);
  --primary-light: var(--cri-red-light);
  --accent: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --sidebar-width: 380px;
  --header-height: 74px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* App Header */
.app-header {
  height: var(--header-height);
  background: rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(12px);
  border-bottom: 3px solid var(--cri-red);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Logo Ufficiale Croce Rossa Italiana Caricato dall'Utente */
.cri-logo-badge {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1px;
  box-shadow: none !important;
}

.cri-cross-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
  display: block;
}

.brand-text h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: white;
  line-height: 1.2;
}

.brand-text p {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons - Completely Flat without Box-Shadow Glow */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  box-shadow: none !important;
}

.btn-primary {
  background: var(--cri-red);
  color: white;
  border: 1px solid var(--cri-red);
  box-shadow: none !important;
}

.btn-primary:hover {
  background: var(--cri-red-hover);
  border-color: var(--cri-red-hover);
  box-shadow: none !important;
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.7);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  box-shadow: none !important;
}

.btn-secondary:hover {
  background: rgba(71, 85, 105, 0.9);
  color: white;
  box-shadow: none !important;
}

.btn-accent {
  background: var(--accent);
  color: white;
  border: 1px solid var(--accent);
  box-shadow: none !important;
}

.btn-accent:hover {
  background: #059669;
  border-color: #059669;
  box-shadow: none !important;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Layout Principale */
.app-container {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Sidebar Panel */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  z-index: 900;
  transition: transform var(--transition-normal);
  box-shadow: none !important;
}

.sidebar.collapsed {
  transform: translateX(-100%);
  position: absolute;
  height: 100%;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-count-badge {
  background: var(--cri-red-light);
  color: var(--cri-red);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.sidebar-search {
  padding: 12px 20px;
  border-bottom: 1px solid var(--glass-border);
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.85rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--cri-red);
}

.team-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Team Card Flat */
.team-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  box-shadow: none !important;
}

.team-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(220, 38, 38, 0.5);
  box-shadow: none !important;
}

.team-card.active-selected {
  border-color: var(--cri-red);
  background: rgba(220, 38, 38, 0.15);
  box-shadow: none !important;
}

.team-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.team-name-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: none !important;
}

.team-title {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.team-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.status-active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-waiting {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-inactive {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.status-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.team-members-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.member-item {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.member-item i {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.team-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.metric-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 6px;
  border-radius: var(--radius-sm);
}

.metric-val {
  font-weight: 700;
  color: white;
  font-size: 0.85rem;
}

.team-card-actions {
  margin-top: 12px;
  display: flex;
  gap: 6px;
}

/* Map Content View */
.map-view {
  flex: 1;
  position: relative;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background: #090d16;
}

/* Map Floating Controls */
.map-controls-floating {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 800;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-control-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: none !important;
}

.map-layer-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.map-layer-btn:hover, .map-layer-btn.active {
  background: var(--cri-red-light);
  color: var(--cri-red);
}

/* Sidebar Toggle Floating Button */
.sidebar-toggle-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 850;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none !important;
}

/* Replay Bar Control (Bottom Floating) */
.replay-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(850px, 90vw);
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  z-index: 850;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: none !important;
}

.replay-bar.hidden {
  display: none;
}

.replay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.replay-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--cri-red);
  display: flex;
  align-items: center;
  gap: 8px;
}

.replay-timeline-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.timeline-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.2);
  outline: none;
  cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cri-red);
  cursor: pointer;
  box-shadow: none !important;
}

.replay-time-display {
  font-family: monospace;
  font-size: 0.85rem;
  color: white;
  min-width: 140px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.speed-selector {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

/* Modals System */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-dark);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  width: min(560px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: none !important;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control {
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.9rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--cri-red);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.member-inputs-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member-row-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-picker-grid {
  display: flex;
  gap: 10px;
}

.color-option {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition-fast);
  box-shadow: none !important;
}

.color-option:hover {
  transform: scale(1.1);
}

.color-option.selected {
  border-color: white;
}

/* Custom Marker Nitidi */
.custom-team-marker {
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-inner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--marker-color, var(--cri-red));
  border: 3px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
  position: relative;
  box-shadow: none !important;
}

.marker-pulse {
  display: none !important;
}

/* Leaflet Popup customization */
.leaflet-popup-content-wrapper {
  background: var(--bg-dark) !important;
  color: white !important;
  border: 1px solid var(--glass-border) !important;
  border-radius: var(--radius-md) !important;
  padding: 4px;
  box-shadow: none !important;
}

.leaflet-popup-tip {
  background: var(--bg-dark) !important;
}

.popup-team-content h4 {
  font-size: 1rem;
  margin-bottom: 6px;
  color: var(--cri-red);
}

.popup-team-content p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.share-box {
  background: rgba(15, 23, 42, 0.8);
  border: 1px dashed var(--glass-border);
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qr-code-img {
  width: 160px;
  height: 160px;
  background: white;
  padding: 10px;
  border-radius: var(--radius-md);
}

.share-link-input-group {
  display: flex;
  width: 100%;
  gap: 6px;
}

.direct-email-banner {
  display: none;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  font-size: 0.88rem;
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .app-header {
    padding: 0 12px;
  }
  .brand-text p {
    display: none;
  }
  .sidebar {
    position: absolute;
    height: 100%;
    transform: translateX(-100%);
  }
  .sidebar.active-mobile {
    transform: translateX(0);
  }
  .replay-bar {
    width: 95vw;
    padding: 12px;
  }
}
