/* =========================
   BodyFactory UI — Brand
   Palette: #017B8A / #00525B / #8CBABF / #D8E8EA
   ========================= */

:root{
  --bg: #F6FAFB;
  --panel: #FFFFFF;
  --card: #FFFFFF;

  --text: #0B1F24;
  --muted: #54757B;
  --line: rgba(0,82,91,.14);

  --primary: #017B8A;
  --primary-2: #00525B;
  --soft: #D8E8EA;
  --soft-2: rgba(1,123,138,.10);

  --ok: #1B9E4B;
  --danger: #E23B4E;
  --warn: #D19A00;

  --shadow: 0 14px 34px rgba(0,0,0,.08);
  --shadow2: 0 8px 18px rgba(0,0,0,.06);

  --radius: 18px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--text);
  background:
    radial-gradient(1000px 700px at 15% 10%, rgba(1,123,138,.10), transparent 55%),
    radial-gradient(900px 600px at 85% 8%, rgba(140,186,191,.18), transparent 55%),
    var(--bg);
  line-height:1.35;
}

a{ color: inherit; text-decoration:none; }
a:hover{ opacity:.95; }

.container{
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 18px 44px;
}

/* Topbar */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;

  padding:14px 16px;
  background: rgba(255,255,255,.72);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  min-width: 220px;
}
.brand img{
  height:38px;
  width:auto;
  display:block;
}
.brand .title{
  font-weight: 900;
  letter-spacing:.2px;
  color: var(--primary-2);
}

/* Nav */
.nav{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.nav a{
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid transparent;
  color: var(--muted);
  font-weight: 750;
}
.nav a:hover{
  border-color: var(--line);
  background: rgba(1,123,138,.06);
  color: var(--primary-2);
}
.nav a.active{
  color: #fff;
  border-color: rgba(1,123,138,.26);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 22px rgba(1,123,138,.22);
}

/* Typography */
h1,h2,h3{
  margin: 18px 0 10px;
  letter-spacing: .2px;
}
h1{ font-size: 28px; color: var(--primary-2); }
h2{ font-size: 20px; color: var(--primary-2); }
h3{ font-size: 16px; color: var(--text); opacity:.95; }
.muted{ color: var(--muted); }

/* Cards */
.card{
  background: rgba(255,255,255,.82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
  padding: 14px 16px;
}

/* Flash */
.flash{
  border-radius: var(--radius);
  border:1px solid var(--line);
  padding: 12px 14px;
  margin: 14px 0;
  background: rgba(255,255,255,.82);
  box-shadow: var(--shadow2);
}
.flash.success{ border-color: rgba(27,158,75,.25); background: rgba(27,158,75,.08); }
.flash.error{ border-color: rgba(226,59,78,.25); background: rgba(226,59,78,.08); }
.flash.warning{ border-color: rgba(209,154,0,.25); background: rgba(209,154,0,.08); }
.flash.info{ border-color: rgba(1,123,138,.25); background: rgba(1,123,138,.08); }

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.90);
  color: var(--primary-2);
  cursor:pointer;
  font-weight: 850;
  letter-spacing:.1px;
  box-shadow: 0 6px 14px rgba(0,0,0,.05);
}
.btn:hover{ background: rgba(1,123,138,.06); }
.btn:active{ transform: translateY(1px); }

.btn.ok{
  border-color: rgba(1,123,138,.26);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color:#fff;
  box-shadow: 0 10px 22px rgba(1,123,138,.22);
}
.btn.danger{
  border-color: rgba(226,59,78,.26);
  background: rgba(226,59,78,.10);
  color: #7A0F1A;
}
.btn.disabled, .btn:disabled{
  opacity:.55;
  pointer-events:none;
  box-shadow:none;
}

/* Inputs */
input, select{
  background: rgba(255,255,255,.92);
  border:1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 14px;
  outline:none;
  box-shadow: 0 6px 14px rgba(0,0,0,.04);
}
input:focus, select:focus{
  border-color: rgba(1,123,138,.35);
  box-shadow: 0 0 0 6px rgba(1,123,138,.12);
}
label{ color: var(--muted); font-size: 13px; }
label input, label select{ margin-top:6px; }

/* Tables */
.table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow:hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow2);
}
.table thead th{
  text-align:left;
  font-size: 12px;
  color: var(--muted);
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(1,123,138,.06);
}
.table tbody td{
  padding: 12px 12px;
  border-bottom: 1px solid rgba(0,82,91,.08);
}
.table tbody tr:hover{ background: rgba(1,123,138,.05); }
.table tbody tr:last-child td{ border-bottom:none; }

/* Badges / Status */
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(1,123,138,.26);
  background: rgba(1,123,138,.10);
  color: var(--primary-2);
  font-weight: 900;
  font-size: 12px;
}

.status{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,82,91,.12);
  font-weight: 950;
  font-size: 12px;
  text-transform: capitalize;
}
.status.pending_approval{ border-color: rgba(209,154,0,.25); background: rgba(209,154,0,.10); color:#6A4C00; }
.status.active{ border-color: rgba(27,158,75,.25); background: rgba(27,158,75,.10); color:#0D5A2B; }
.status.blocked{ border-color: rgba(226,59,78,.25); background: rgba(226,59,78,.10); color:#7A0F1A; }

/* Users page cards */
.user-list{ display:flex; flex-direction:column; gap:10px; }
.user-card{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 14px 16px;
  background: rgba(255,255,255,.86);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow2);
}
.user-info strong{ display:block; color: var(--primary-2); }
.user-info small{ color: var(--muted); }

/* Calendar */
.week-nav{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin: 12px 0 14px;
}
.calendar-day{
  margin-bottom: 12px;
  padding: 14px 16px;
  border:1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.86);
  box-shadow: var(--shadow2);
}
.day-title{
  margin:0 0 10px;
  font-size: 14px;
  color: var(--muted);
  border-bottom: 1px solid rgba(0,82,91,.10);
  padding-bottom: 8px;
}

.calendar-day.today{
  border-color: rgba(1,123,138,.30);
  box-shadow: 0 0 0 6px rgba(1,123,138,.10), var(--shadow2);
}
.calendar-day.tomorrow{
  border-color: rgba(140,186,191,.45);
  box-shadow: 0 0 0 6px rgba(140,186,191,.18), var(--shadow2);
}

.calendar{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.slot{
  width:100%;
  text-align:left;
  padding: 12px;
  border-radius: 16px;
  border:1px solid rgba(0,82,91,.12);
  background: rgba(255,255,255,.95);
  box-shadow: 0 6px 14px rgba(0,0,0,.04);
}
.slot:hover{ background: rgba(1,123,138,.06); }
.slot.free{ border-color: rgba(27,158,75,.25); }
.slot.medium{ border-color: rgba(209,154,0,.25); }
.slot.full{ border-color: rgba(226,59,78,.25); opacity:.9; }

/* Mobile */
@media (max-width: 720px){
  .topbar{ flex-direction:column; align-items:flex-start; }
  .brand{ min-width: 0; }
  .user-card{ flex-direction:column; align-items:flex-start; }
}


/* =========================
   BODYFACTORY UI SYSTEM
   ========================= */

:root{
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #667085;

  --primary: #017B8A;
  --primary-2: #015f69;

  --danger: #E04343;
  --warning: #F4B400;

  --border: rgba(15, 23, 42, .10);
  --shadow: 0 10px 26px rgba(15, 23, 42, .08);

  --radius: 16px;
  --radius-sm: 12px;
  --h: 44px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.35;
}

.container{ max-width: 1100px; margin:0 auto; padding: 14px; }
main{ padding: 14px 0 80px; } /* spazio sotto per bottone install */

h1,h2,h3{ margin: 10px 0; letter-spacing:-.2px; }
h1{ font-size: 22px; }
h2{ font-size: 18px; }
h3{ font-size: 16px; }

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

/* ===== cards ===== */
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

/* ===== buttons (ONE SIZE) ===== */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  height: var(--h);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #eef2f6;
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  text-decoration:none;
  transition: transform .12s, filter .12s, box-shadow .12s;
  user-select:none;
  white-space:nowrap;
}

.btn.ok{
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

.btn.danger{
  background: var(--danger);
  border-color: transparent;
  color:#fff;
}

.btn:disabled,
.btn.disabled{
  opacity: .45;
  cursor:not-allowed;
  transform:none !important;
}

.btn:hover{ filter: brightness(1.03); }
.btn:active{ transform: scale(.98); }

/* ===== forms (ONE HEIGHT) ===== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select{
  height: var(--h);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 0 12px;
  background:#fff;
  font-weight:700;
  font-size:14px;
  outline:none;
  min-width: 220px;
}

select{ cursor:pointer; }

label{ font-weight:800; color: var(--muted); font-size: 12px; }
label .muted{ font-weight:800; }

/* ===== nav ===== */
.topbar{
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
  padding: 10px 14px;
}

.brand img{ height: 34px; display:block; }

.nav{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  align-items:center;
}

.nav a{
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  display:inline-flex;
  align-items:center;
  font-weight: 900;
  text-decoration:none;
  color: var(--text);
  border: 1px solid transparent;
}

.nav a:hover{ background:#f1f5f9; }
.nav a.active{
  background: var(--primary);
  color: #fff;
}

/* ===== flash ===== */
.flash{
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:#fff;
  box-shadow: var(--shadow);
  font-weight: 800;
}
.flash.success{ border-color: rgba(1,123,138,.35); }
.flash.error{ border-color: rgba(224,67,67,.35); }
.flash.warning{ border-color: rgba(244,180,0,.35); }
.flash.info{ border-color: rgba(102,112,133,.35); }

/* ===== badges / status ===== */
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef2f6;
  border: 1px solid var(--border);
  font-weight: 900;
  font-size: 13px;
}

.status{
  display:inline-flex;
  align-items:center;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 12px;
  border: 1px solid var(--border);
  background:#eef2f6;
}
.status.active{ background: rgba(1,123,138,.12); border-color: rgba(1,123,138,.25); color: var(--primary-2); }
.status.pending_approval{ background: rgba(244,180,0,.12); border-color: rgba(244,180,0,.25); color: #8a6b00; }
.status.blocked{ background: rgba(224,67,67,.12); border-color: rgba(224,67,67,.25); color: #a40000; }

/* ===== week nav ===== */
.week-nav{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }

/* ===== calendar grid ===== */
.calendar{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.calendar-day{
  margin: 14px 0;
}

.calendar-day.today{
  border-left: 6px solid var(--primary);
  padding-left: 10px;
}

.calendar-day.tomorrow{
  border-left: 6px solid var(--warning);
  padding-left: 10px;
}

/* slot card */
.slot{
  display:block;
  text-decoration:none;
  background:#fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 8px 20px rgba(15,23,42,.06);
  transition: transform .12s, box-shadow .12s, filter .12s;
}

.slot:hover{ transform: translateY(-1px); box-shadow: 0 12px 26px rgba(15,23,42,.10); }

.slot.free{ background: rgba(1,123,138,.08); }
.slot.medium{ background: rgba(244,180,0,.10); }
.slot.full{ background: rgba(224,67,67,.10); }

/* ===== tables ===== */
.table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow:hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:#fff;
  box-shadow: var(--shadow);
}

.table th, .table td{
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  text-align:left;
  vertical-align: middle;
}

.table th{
  background:#f8fafc;
  font-weight: 900;
  font-size: 13px;
  color: var(--muted);
}

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

/* ===== install button fixed ===== */
#installUniversal, #installApp{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  border-radius: 999px;
  height: 52px;
  padding: 0 18px;
  box-shadow: 0 16px 34px rgba(15,23,42,.22);
}

.ico{ display:inline-block; vertical-align:middle; }
.nav a .ico{ margin-right:8px; opacity:.95; }
.btn .ico{ margin-right:8px; }


/* HEADER: logo | nav (sempre dentro, no wrap) */
@media (min-width: 1024px) {

  header.topbar{
    display:flex;
    align-items:center;
    gap:16px;
    flex-wrap:nowrap;
  }

  header.topbar .brand{
    flex:0 0 auto;
  }

  header.topbar .nav{
    flex:1 1 auto;      /* il nav prende lo spazio disponibile */
    min-width:0;        /* fondamentale per NON farlo uscire */
    display:flex;
    flex-wrap:nowrap;
    gap:10px;
    white-space:nowrap;

    overflow-x:auto;     /* se non basta spazio, scrolla invece di uscire */
    overflow-y:hidden;
    -webkit-overflow-scrolling:touch;
  }

  header.topbar .nav a{
    flex:0 0 auto;       /* ogni link non si restringe/va a capo */
    white-space:nowrap;
  }

  /* opzionale: nasconde scrollbar su alcuni browser */
  header.topbar .nav::-webkit-scrollbar{ height:6px; }
}




/* Bottone prenotati: visibile SEMPRE (override) */
.bf-attendees-icon{
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;

  width:44px !important;
  min-width:44px !important;
  height:44px !important;

  border-radius:12px !important;
  border:1px solid rgba(0,0,0,.18) !important;
  background: #fff !important;

  cursor:pointer !important;
  padding:0 !important;
  margin:0 !important;

  opacity:1 !important;
  visibility:visible !important;
}

.bf-attendees-icon svg{
  width:22px !important;
  height:22px !important;
  fill: rgba(0,0,0,.75) !important;
  display:block !important;
}

/* FIX: bottone prenotati fuori dallo slot (non absolute) */
.bf-slot-row{
  display:flex;
  align-items:stretch;
  gap:10px;
}

/* lo slot si prende lo spazio */
.bf-slot-row form{ flex:1; margin:0; }
.bf-slot-row form .slot{ width:100%; height:100%; }

/* il bottone NON deve essere absolute (se no vola in alto a destra) */
.bf-attendees-icon{
  position: static !important;
  top: auto !important;
  right: auto !important;

  width:44px !important;
  min-width:44px !important;
  height:44px !important;

  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
}

/* ===== BodyFactory: overlay "Attendere..." ===== */
#bfOverlay{
  position: fixed;
  inset: 0;
  z-index: 99999;
}
.bf-overlay-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
}
.bf-overlay-card{
  position:absolute;
  left:50%;
  top:50%;
  transform: translate(-50%,-50%);
  width:min(420px, 92vw);
  background:#fff;
  border-radius:18px;
  padding:18px 18px 16px;
  text-align:center;
  box-shadow: 0 18px 40px rgba(0,0,0,.20);
}
.bf-spinner{
  width:44px;
  height:44px;
  border-radius:999px;
  border:4px solid rgba(0,0,0,.10);
  border-top-color: rgba(0,0,0,.55);
  margin: 4px auto 10px;
  animation: bfspin .9s linear infinite;
}
@keyframes bfspin{ to{ transform: rotate(360deg); } }
.bf-overlay-title{
  font-weight: 950;
  font-size: 18px;
  margin: 0 0 4px;
}
.bf-overlay-sub{
  font-weight: 800;
  font-size: 13px;
  opacity:.7;
}

/* ===== Flash gigante (sovraimpressione) ===== */
.bf-flash-modal{
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.bf-flash-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
}
.bf-flash-card{
  position:relative;
  width:min(520px, 94vw);
  background:#fff;
  border-radius:20px;
  padding: 18px 18px 16px;
  text-align:center;
  box-shadow: 0 22px 50px rgba(0,0,0,.25);
  border: 2px solid rgba(0,0,0,.08);
}
.bf-flash-icon{
  font-size: 34px;
  margin-bottom: 10px;
}
.bf-flash-msg{
  font-size: 18px;
  font-weight: 950;
  line-height: 1.25;
  margin-bottom: 14px;
}
.bf-flash-modal[data-type="success"] .bf-flash-card{ border-color: rgba(27,158,75,.35); }
.bf-flash-modal[data-type="error"] .bf-flash-card{ border-color: rgba(224,67,67,.35); }
.bf-flash-modal[data-type="warning"] .bf-flash-card{ border-color: rgba(244,180,0,.45); }


