/* ===================================================
   GESTIONALE PMU - FRESHA STYLE THEME & DESIGN SYSTEM
   =================================================== */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg-app: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #1e293b;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --primary-border: #c7d2fe;

  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  height: 100vh;
}

/* APP SHELL LAYOUT */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 250px;
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid #1e293b;
  transition: width 0.2s ease;
  z-index: 40;
}

.sidebar-header {
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #1e293b;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.35);
}

.brand-logo-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}

.brand-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-logo-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}

.login-logo-img {
  max-height: 85px;
  max-width: 240px;
  object-fit: contain;
  margin-bottom: 10px;
}

.brand-info h1 {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-info span {
  font-size: 11px;
  color: #a855f7;
  font-weight: 600;
}
  color: #94a3b8;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}

.nav-item.active {
  background-color: var(--sidebar-active-bg);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.08);
  font-weight: 600;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #1e293b;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.db-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 6px 10px;
  background-color: #1e293b;
  border-radius: var(--radius-full);
  cursor: pointer;
  color: #cbd5e1;
  transition: background 0.15s;
}

.db-pill:hover {
  background-color: #334155;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.green { background-color: #10b981; box-shadow: 0 0 8px #10b981; }
.status-dot.yellow { background-color: #f59e0b; box-shadow: 0 0 8px #f59e0b; }
.status-dot.red { background-color: #ef4444; box-shadow: 0 0 8px #ef4444; }

/* MAIN CONTENT AREA */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
}

/* TOP NAVBAR */
.topbar {
  height: 64px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

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

.date-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-app);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.date-nav-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
}

.date-nav-btn:hover {
  background: #ffffff;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.current-date-label {
  font-size: 13px;
  font-weight: 600;
  padding: 0 8px;
  color: var(--text-main);
}

.btn-today {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: white;
  cursor: pointer;
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: var(--bg-app);
  border-color: var(--border-hover);
}

.btn-pos {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}
.btn-pos:hover {
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

/* CONTENT VIEWPORT */
.content-area {
  flex: 1;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* CALENDAR VIEW (FRESHA STYLE) */
.calendar-view-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
}

.calendar-staff-header {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  background-color: #ffffff;
  position: sticky;
  top: 0;
  z-index: 20;
}

.time-header-spacer {
  width: 70px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-light);
  font-weight: 600;
}

.staff-headers-scroll-wrap {
  display: flex;
  flex: 1;
  overflow-x: hidden; /* Sync con lo scroll della griglia */
  scrollbar-width: none; /* Firefox */
}
.staff-headers-scroll-wrap::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.staff-column-header {
  flex: 1;
  min-width: 220px;
  flex-shrink: 0;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-right: 1px solid var(--border-color);
  background-color: #ffffff;
  transition: min-width 0.15s ease, width 0.15s ease;
}

/* Stili compatti quando lo zoom è ridotto o in modalità "Adatta" */
.staff-column-header.compact-zoom {
  padding: 6px 8px;
  gap: 6px;
}

.staff-column-header.compact-zoom .staff-avatar {
  width: 26px;
  height: 26px;
}

.staff-column-header.compact-zoom .staff-meta h3 {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.staff-column-header.compact-zoom .staff-meta span {
  font-size: 9px;
  display: none; /* Nascondi ruolo per non sovraffollare */
}

.staff-day-column.compact-zoom .appointment-card {
  left: 2px;
  right: 2px;
  padding: 4px 6px;
  font-size: 11px;
}

.staff-avatar-wrapper {
  position: relative;
}

.staff-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid white;
  box-shadow: var(--shadow-sm);
}

.staff-color-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
}

.staff-meta h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

.staff-meta span {
  font-size: 11px;
  color: var(--text-muted);
}

/* CALENDAR BODY GRID */
.calendar-grid-body {
  flex: 1;
  display: flex;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
  background-color: #ffffff;
}

.time-column {
  width: 70px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  background-color: #fbfcfe;
}

.time-slot-label {
  height: 70px; /* 1 hour slot */
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  border-bottom: 1px solid #f1f5f9;
}

.staff-grid-columns {
  display: flex;
  flex: 1;
  position: relative;
}

.staff-day-column {
  flex: 1;
  min-width: 220px;
  flex-shrink: 0;
  position: relative;
  border-right: 1px solid var(--border-color);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 34px,
    #f8fafc 35px,
    transparent 36px,
    transparent 69px,
    #f1f5f9 70px
  );
  min-height: 840px; /* 12 hours from 08:00 to 20:00 (12 * 70px) */
}

/* APPOINTMENT CARD */
.appointment-card {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  cursor: grab;
  user-select: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
  border-left: 4px solid var(--primary);
  background-color: #ffffff;
  border-top: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
  overflow: hidden;
  z-index: 10;
}

.appointment-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  z-index: 15;
}

.appointment-card:active {
  cursor: grabbing;
}

.appointment-card.dragging {
  opacity: 0.35;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
  border: 2px dashed var(--primary);
  z-index: 25;
}

.staff-day-column.drag-over {
  background-color: rgba(240, 253, 244, 0.75) !important;
}

/* GHOST ANTEPRIMA ORARIO DRAG & DROP */
.drag-time-preview-ghost {
  position: absolute;
  left: 6px;
  right: 6px;
  background: rgba(99, 102, 241, 0.15);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-md);
  pointer-events: none;
  z-index: 30;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 6px 10px;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.25);
  animation: pulseGhost 1.2s infinite ease-in-out;
}

.drag-time-preview-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
  width: fit-content;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.drag-time-preview-client {
  font-size: 11px;
  font-weight: 700;
  color: #312e81;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@keyframes pulseGhost {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.65; }
}

/* BLOCCO AGENDA OCCUPATO / NON DISPONIBILE */
.staff-time-block-card {
  position: absolute;
  left: 6px;
  right: 6px;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  background: repeating-linear-gradient(
    -45deg,
    #f8fafc,
    #f8fafc 8px,
    #f1f5f9 8px,
    #f1f5f9 16px
  );
  border: 1px dashed #94a3b8;
  border-left: 4px solid #64748b;
  cursor: pointer;
  z-index: 12;
  overflow: hidden;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.staff-time-block-card:hover {
  border-color: #64748b;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.staff-time-block-card.all-day {
  background: repeating-linear-gradient(
    -45deg,
    #fee2e2,
    #fee2e2 8px,
    #fecaca 8px,
    #fecaca 16px
  );
  border: 1px dashed #ef4444;
  border-left: 5px solid #dc2626;
}

.apt-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.apt-client {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.apt-service {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apt-footer {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.apt-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.status-scheduled { background: #e0f2fe; color: #0369a1; }
.status-confirmed { background: #f3e8ff; color: #7e22ce; }
.status-arrived { background: #fef3c7; color: #b45309; }
.status-inprogress { background: #dcfce7; color: #15803d; }
.status-completed { background: #f1f5f9; color: #475569; }
.status-cancelled { background: #fee2e2; color: #b91c1c; }

/* MODALS & DRAWERS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.15s ease-out;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 95%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  background-color: var(--bg-app);
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background-color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* FORMS */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  color: var(--text-main);
  background-color: #ffffff;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* TABLES & DATA GRIDS */
.view-container {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background-color: #f8fafc;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: #fafbfc;
}

/* POS CHECKOUT LAYOUT */
.pos-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: 100%;
  overflow: hidden;
}

.pos-catalog {
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pos-categories-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pos-cat-btn {
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.pos-cat-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pos-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.pos-item-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 110px;
}

.pos-item-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.pos-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.pos-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 8px;
}

/* POS CART */
.pos-cart {
  background: white;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.pos-cart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.pos-cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pos-cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.pos-cart-summary {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.summary-total {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

/* ANIMATIONS */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: #1e293b;
  color: white;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.2s ease-out;
}

.toast.success { background-color: #065f46; border-left: 4px solid #10b981; }
.toast.error { background-color: #7f1d1d; border-left: 4px solid #ef4444; }
.toast.info { background-color: #1e293b; border-left: 4px solid var(--primary); }

/* WHATSAPP BUTTON */
.btn-whatsapp {
  background-color: #25d366;
  color: #ffffff;
  border: none;
}
.btn-whatsapp:hover {
  background-color: #1ebd5b;
  box-shadow: 0 4px 10px rgba(37, 211, 102, 0.35);
}

/* MONTH & YEAR CALENDAR GRID */
.month-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.month-day-cell {
  background: #ffffff;
  min-height: 105px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.month-day-cell:hover {
  background: #f8fafc;
}

.month-day-cell.other-month {
  background: #fafbfc;
  color: var(--text-light);
}

.month-day-cell.today {
  background: #f5f3ff;
}

.month-day-number {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.month-apt-pill {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #eef2ff;
  color: #4338ca;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  border-left: 3px solid var(--primary);
}

.year-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 20px;
}

.year-month-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.year-month-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

/* LOGIN OVERLAY */
.login-screen-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.login-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 420px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===================================================
   SMARTPHONE / MOBILE OPTIMIZATION SYSTEM
   =================================================== */

.mobile-bottom-nav {
  display: none;
}

.mobile-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
}

.mobile-toggle-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* When Mobile Mode is ACTIVE (via .mobile-mode class on body OR on small screens) */
body.mobile-mode,
@media (max-width: 768px) {
  body.mobile-mode, body {
    overflow: auto !important;
    height: auto !important;
    min-height: 100vh;
  }
}

body.mobile-mode .app-container {
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

body.mobile-mode .sidebar {
  display: none !important;
}

body.mobile-mode .main-wrapper {
  height: 100%;
  padding-bottom: 64px; /* Space for bottom nav */
  position: relative;
}

/* Responsive Topbar per Smartphone */
body.mobile-mode .topbar {
  height: auto;
  min-height: 54px;
  padding: 8px 10px;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

body.mobile-mode .topbar-left {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Riga 1 su mobile: Date controls + Tasto Disconnetti/Cambia operatore in evidenza */
body.mobile-mode .topbar-row-1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

/* Riga 2 su mobile: Selettore Vista (Giorno/Mese/Anno) + Zoom sotto ad esso */
body.mobile-mode .topbar-row-2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

body.mobile-mode #agenda-mode-selector {
  flex: 1;
  display: flex;
  justify-content: space-around;
}

body.mobile-mode #agenda-zoom-controls {
  display: flex !important;
  justify-content: center;
}

body.mobile-mode .topbar-right {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}

body.mobile-mode .topbar-right #btn-logout {
  display: none; /* Spostato in cima nella riga principale per essere subito visibile */
}

body.mobile-mode #btn-mobile-top-logout {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 34px;
  padding: 0 10px;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #e11d48;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

#btn-mobile-top-logout {
  display: none; /* Nascosto su desktop */
}

body.mobile-mode .date-controls {
  flex: 1;
  justify-content: space-between;
  padding: 2px 4px;
}

body.mobile-mode .current-date-label {
  font-size: 12px;
  padding: 0 4px;
}

body.mobile-mode .btn {
  padding: 6px 10px;
  font-size: 11px;
  white-space: nowrap;
}

body.mobile-mode .mobile-toggle-btn {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
  font-weight: 700;
}

body.mobile-mode .mobile-bottom-nav {
  display: flex !important;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

body.mobile-mode .mob-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #64748b;
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  height: 100%;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

body.mobile-mode .mob-nav-item svg {
  width: 18px;
  height: 18px;
}

body.mobile-mode .mob-nav-item.active {
  color: var(--primary);
  background: #f8fafc;
  border-top: 2px solid var(--primary);
}

/* Mobile adjustments for Content & Modals */
body.mobile-mode .content-area {
  padding: 0 !important; /* Nessun padding su mobile per far estendere l'agenda a tutta larghezza */
  overflow-y: auto !important;
}

body.mobile-mode .calendar-view-container {
  width: 100%;
}

body.mobile-mode .staff-column-header,
body.mobile-mode .staff-day-column {
  min-width: 160px; /* Larghezza più compatta ed equilibrata per schermi smartphone */
}

body.mobile-mode .modal-content {
  width: 96% !important;
  max-width: 96% !important;
  padding: 16px !important;
  max-height: 90vh !important;
  margin: 10px auto !important;
}

body.mobile-mode .form-row {
  flex-direction: column !important;
  gap: 10px !important;
}

body.mobile-mode .pos-container {
  flex-direction: column !important;
  height: auto !important;
}

body.mobile-mode .pos-cart {
  width: 100% !important;
  border-left: none !important;
  border-top: 2px solid var(--border-color);
  margin-top: 16px;
}

body.mobile-mode .agenda-calendar-container {
  overflow-x: auto !important;
}

body.mobile-mode .calendar-grid {
  min-width: 450px !important;
}

body.mobile-mode .table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Mobile Navigation Drawer Overlay */
.mobile-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1050;
  display: flex;
  justify-content: flex-end;
}

.mobile-drawer-content {
  width: 80%;
  max-width: 300px;
  height: 100%;
  background: var(--bg-sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 16px;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
}

