/* ═══════════════════════════════════════════════════════
   Bokningssystemet – App styles
   ═══════════════════════════════════════════════════════ */

:root {
  --bs-primary:        #2563EB;
  --bs-primary-rgb:    37,99,235;
  --brand-bg:          #F1F5FB;
  --brand-surface:     #ffffff;
  --brand-border:      #E2E8F0;
  --brand-text-muted:  #64748B;
  --brand-radius:      12px;
  --brand-shadow:      0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
  --brand-shadow-sm:   0 1px 2px rgba(0,0,0,.05);
  --nav-height:        64px;
}

/* ─── Reset / Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--brand-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1E293B;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }

/* ─── Navbar ────────────────────────────────────────────── */
.app-nav {
  height: var(--nav-height);
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-border);
  box-shadow: var(--brand-shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.app-nav .navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--bs-primary) !important;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.app-nav .navbar-brand .brand-icon {
  width: 32px;
  height: 32px;
  background: var(--bs-primary);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.app-nav .nav-link {
  color: var(--brand-text-muted) !important;
  font-size: .9rem;
  font-weight: 500;
  padding: .4rem .75rem !important;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.app-nav .nav-link:hover { background: var(--brand-bg); color: #1E293B !important; }
.app-nav .nav-link.active { background: #EEF4FF; color: var(--bs-primary) !important; }
.app-nav .nav-cta {
  background: var(--bs-primary);
  color: #fff !important;
  border-radius: 8px;
  padding: .4rem .9rem !important;
  font-weight: 600;
}
.app-nav .nav-cta:hover { background: #1D4ED8; }
.app-nav .user-chip {
  background: var(--brand-bg);
  border: 1px solid var(--brand-border);
  border-radius: 20px;
  padding: .3rem .75rem;
  font-size: .85rem;
  font-weight: 500;
  color: #1E293B;
  display: flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
}
.app-nav .user-chip:hover { border-color: #93C5FD; }

/* ─── Page shell ────────────────────────────────────────── */
.page-wrap { padding: 2rem 0 4rem; }
@media (max-width: 576px) { .page-wrap { padding: 1.25rem 0 3rem; } }

/* ─── Section heading ───────────────────────────────────── */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0F172A;
  margin-bottom: .25rem;
}
.page-subtitle { color: var(--brand-text-muted); font-size: .95rem; }

/* ─── Card ──────────────────────────────────────────────── */
.app-card {
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  box-shadow: var(--brand-shadow);
}
.app-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--brand-border);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ─── Kalender ──────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-radius: var(--brand-radius);
  overflow: hidden;
  border: 1px solid var(--brand-border);
  box-shadow: var(--brand-shadow);
}
.cal-head {
  background: #0F172A;
  color: rgba(255,255,255,.8);
  padding: .6rem 0;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.cal-head:first-child { border-radius: var(--brand-radius) 0 0 0; }
.cal-head:last-child  { border-radius: 0 var(--brand-radius) 0 0; }

.cal-cell {
  background: var(--brand-surface);
  border-right: 1px solid var(--brand-border);
  border-bottom: 1px solid var(--brand-border);
  min-height: 100px;
  padding: .5rem .4rem;
  position: relative;
  transition: background .12s;
}
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.empty { background: #F8FAFC; }
.cal-cell.weekend { background: #FAFAFA; }
.cal-cell.past { opacity: .55; }
.cal-cell.today {
  background: #EEF4FF !important;
  box-shadow: inset 0 0 0 2px var(--bs-primary);
}
.cal-cell.full { background: #FEF2F2; }
.cal-cell.partial { background: #FFFBEB; }
.cal-cell.free-day { background: #F0FDF4; }

.cal-dag-nr {
  font-size: .82rem;
  font-weight: 700;
  color: #334155;
  margin-bottom: .3rem;
  line-height: 1;
}
.cal-cell.today .cal-dag-nr { color: var(--bs-primary); }
.today-dot {
  display: inline-block;
  width: 20px;
  height: 20px;
  background: var(--bs-primary);
  color: #fff;
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
  line-height: 20px;
}

/* Bokningspill */
.cal-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: .68rem;
  font-weight: 600;
  border-radius: 5px;
  padding: 2px 5px;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-pill.fm      { background: #DBEAFE; color: #1D4ED8; }
.cal-pill.em      { background: #FEF9C3; color: #92400E; }
.cal-pill.heldag  { background: #FEE2E2; color: #B91C1C; }
.cal-pill.custom  { background: #F3E8FF; color: #6D28D9; }

.cal-boka-btn {
  display: block;
  margin-top: 4px;
  width: 100%;
  padding: 2px 0;
  font-size: .68rem;
  font-weight: 600;
  text-align: center;
  background: #D1FAE5;
  color: #065F46;
  border-radius: 5px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background .12s;
}
.cal-boka-btn:hover { background: #A7F3D0; color: #065F46; }

/* ─── Legend ────────────────────────────────────────────── */
.legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: .8rem;
  color: var(--brand-text-muted);
  align-items: center;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ─── Month nav ─────────────────────────────────────────── */
.month-nav {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.month-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--brand-border);
  background: var(--brand-surface);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #334155;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}
.month-btn:hover { border-color: var(--bs-primary); background: #EEF4FF; color: var(--bs-primary); }
.month-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #0F172A;
  min-width: 200px;
  text-align: center;
}

/* ─── Tidslott-kort (boka.php) ──────────────────────────── */
.slot-card {
  border: 2px solid var(--brand-border);
  border-radius: var(--brand-radius);
  padding: 1rem .75rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
  background: var(--brand-surface);
  user-select: none;
}
.slot-card:hover:not(.slot-disabled) {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.slot-card.selected {
  border-color: var(--bs-primary);
  background: #EEF4FF;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.slot-card.slot-disabled {
  opacity: .45;
  cursor: not-allowed;
  background: #F8FAFC;
}
.slot-card .slot-icon { font-size: 1.6rem; margin-bottom: .3rem; }
.slot-card .slot-name { font-weight: 700; font-size: .9rem; color: #0F172A; }
.slot-card .slot-time { font-size: .75rem; color: var(--brand-text-muted); margin-top: 1px; }
.slot-card .slot-booked-badge {
  display: inline-block;
  margin-top: .35rem;
  font-size: .65rem;
  font-weight: 700;
  background: #FEE2E2;
  color: #B91C1C;
  border-radius: 20px;
  padding: 1px 8px;
}

/* FM/EM/HELDAG färgscheman */
.slot-fm.selected,   .slot-fm:hover:not(.slot-disabled)   { border-color:#2563EB; background:#EEF4FF; }
.slot-em.selected,   .slot-em:hover:not(.slot-disabled)   { border-color:#D97706; background:#FFFBEB; }
.slot-hel.selected,  .slot-hel:hover:not(.slot-disabled)  { border-color:#DC2626; background:#FEF2F2; }
.slot-anp.selected,  .slot-anp:hover:not(.slot-disabled)  { border-color:#7C3AED; background:#F5F3FF; }

/* ─── Bokningskort (mina-bokningar) ─────────────────────── */
.booking-card {
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--brand-radius);
  box-shadow: var(--brand-shadow-sm);
  overflow: hidden;
  transition: box-shadow .15s;
}
.booking-card:hover { box-shadow: var(--brand-shadow); }
.booking-card .bc-left {
  width: 4px;
  flex-shrink: 0;
}
.bc-left.aktiv   { background: var(--bs-primary); }
.bc-left.avbokad { background: #94A3B8; }

/* ─── Status-badges ─────────────────────────────────────── */
.badge-fm      { background:#DBEAFE; color:#1D4ED8; }
.badge-em      { background:#FEF9C3; color:#92400E; }
.badge-heldag  { background:#FEE2E2; color:#B91C1C; }
.badge-custom  { background:#F3E8FF; color:#6D28D9; }
.badge-aktiv   { background:#DBEAFE; color:#1D4ED8; }
.badge-avbokad { background:#F1F5F9; color:#64748B; }

/* ─── Login ──────────────────────────────────────────────── */
.login-wrap {
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.1);
  padding: 2.5rem 2rem;
}
.login-logo {
  width: 48px;
  height: 48px;
  background: var(--bs-primary);
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.4rem;
  margin: 0 auto 1.25rem;
}

/* ─── Form inputs ───────────────────────────────────────── */
.form-control, .form-select {
  border-color: var(--brand-border);
  border-radius: 8px;
  padding: .55rem .85rem;
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-label { font-weight: 600; font-size: .85rem; color: #374151; margin-bottom: .35rem; }

/* ─── Knappar ───────────────────────────────────────────── */
.btn { border-radius: 8px; font-weight: 600; font-size: .9rem; }
.btn-primary { background: var(--bs-primary); border-color: var(--bs-primary); }
.btn-primary:hover { background: #1D4ED8; border-color: #1D4ED8; }
.btn-lg { padding: .65rem 1.5rem; font-size: 1rem; }

/* ─── Empty state ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--brand-text-muted);
}
.empty-state i { font-size: 2.5rem; opacity: .4; margin-bottom: .75rem; }

/* ─── Flash alert ───────────────────────────────────────── */
.flash-bar {
  border-radius: 10px;
  border: none;
  font-weight: 500;
  font-size: .9rem;
}

/* ─── Footer ────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--brand-border);
  padding: 1.25rem 0;
  text-align: center;
  font-size: .8rem;
  color: var(--brand-text-muted);
  background: var(--brand-surface);
  margin-top: auto;
}

/* ─── Mobile bottom nav ─────────────────────────────────── */
:root { --mbn-height: 62px; }

.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mbn-height);
  background: var(--brand-surface);
  border-top: 1px solid var(--brand-border);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  display: flex;
  align-items: stretch;
  z-index: 1100;
}

.mbn-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: .65rem;
  font-weight: 600;
  color: var(--brand-text-muted);
  text-decoration: none;
  padding: .4rem .2rem;
  transition: color .15s, background .15s;
  position: relative;
}
.mbn-item i { font-size: 1.25rem; line-height: 1; }
.mbn-item:hover { background: var(--brand-bg); }
.mbn-item.active { color: var(--bs-primary); }
.mbn-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--bs-primary);
  border-radius: 0 0 3px 3px;
}

.mbn-item.mbn-cta {
  color: #fff;
  background: var(--bs-primary);
  border-radius: 14px;
  margin: 8px 6px;
  flex: none;
  width: 52px;
  height: 46px;
  padding: 0;
}
.mbn-item.mbn-cta i { font-size: 1.5rem; }
.mbn-item.mbn-cta span { display: none; }
.mbn-item.mbn-cta:hover { background: #1D4ED8; }
.mbn-item.mbn-cta::before { display: none; }

/* Give the page body room so content isn't hidden behind the nav */
@media (max-width: 767px) {
  body { padding-bottom: var(--mbn-height); }
}

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Calendar */
  .cal-cell { min-height: 60px; padding: .3rem .25rem; }
  .cal-pill { font-size: .58rem; padding: 1px 3px; }
  .cal-dag-nr { font-size: .75rem; }
  .month-title { font-size: 1.05rem; min-width: 140px; }
  .cal-boka-btn { font-size: .6rem; }

  /* Month nav */
  .month-btn { width: 30px; height: 30px; }

  /* Legend – wrap tightly */
  .legend { gap: .5rem; font-size: .72rem; }

  /* Slot cards – 2 per row on phones */
  .slot-card { padding: .75rem .5rem; }
  .slot-card .slot-icon { font-size: 1.3rem; }
  .slot-card .slot-name { font-size: .82rem; }

  /* Booking cards */
  .booking-card .p-3 { padding: .75rem !important; }

  /* Page heading */
  .page-title { font-size: 1.25rem; }

  /* Login */
  .login-card { padding: 1.75rem 1.25rem; }
}

@media (max-width: 400px) {
  /* Very small phones – hide pill text on calendar */
  .cal-pill { font-size: 0; padding: 4px 3px; border-radius: 50%; width: 8px; height: 8px; margin: 1px auto; }
  .cal-pill i, .cal-pill span { display: none; }
  .cal-boka-btn { display: none; }
}
