:root{
  --text:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --brand:#0284c7;
  --brand2:#0891b2;
  --bg:#f8fafc;
  --card:#ffffff;
  --soft:#f1f5f9;
}

*{box-sizing:border-box}
html{scroll-behavior:auto}
body{
  margin:0;
  min-height:100vh;
  font-family:Inter,ui-sans-serif,system-ui,"Segoe UI",sans-serif;
  color:var(--text);
  background:linear-gradient(135deg,#f8fafc,#e0f2fe);
  overflow-x:hidden;
}
a{color:inherit;text-decoration:none}

.bg-orb{display:none!important}

.app-shell{
  width:min(1180px,calc(100% - 40px));
  margin:0 auto;
  padding:34px 0;
}

.hero{
  min-height:74vh;
  display:grid;
  place-items:center;
  text-align:center;
}

.brand-pill{
  display:inline-block;
  background:#fff;
  padding:18px 34px;
  border-radius:999px;
  border:1px solid var(--line);
  letter-spacing:.22em;
  font-weight:900;
}

.hero h1,.page-title{
  font-size:clamp(38px,6vw,76px);
  line-height:1;
  margin:42px 0 18px;
  font-weight:950;
  letter-spacing:.12em;
  text-transform:uppercase;
}

.subtitle{
  font-size:clamp(16px,2vw,24px);
  font-weight:800;
  color:var(--muted);
  letter-spacing:.14em;
  text-transform:uppercase;
  margin:0 0 30px;
}

.btn{
  border:0;
  border-radius:22px;
  background:linear-gradient(135deg,var(--brand),var(--brand2));
  color:#fff;
  padding:16px 30px;
  display:inline-flex;
  align-items:center;
  gap:10px;
  font-weight:900;
  font-size:16px;
  letter-spacing:.06em;
  text-transform:uppercase;
  cursor:pointer;
}

.btn-soft{
  background:#fff;
  color:#334155;
  border:1px solid var(--line);
}

.btn-small{
  border-radius:14px;
  padding:10px 14px;
  font-size:13px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  gap:14px;
  align-items:center;
  margin-bottom:26px;
}

.back{
  font-weight:900;
  color:var(--muted);
  letter-spacing:.08em;
  text-transform:uppercase;
}

.sso-chip{
  padding:10px 14px;
  border:1px solid var(--line);
  border-radius:999px;
  background:#fff;
  color:var(--muted);
  font-weight:800;
  font-size:13px;
}

.center{text-align:center}

.grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:26px;
  margin-top:46px;
}

.choice-card{
  min-height:200px;
  background:#fff;
  border:1px solid var(--line);
  border-radius:28px;
  display:grid;
  place-items:center;
  text-align:center;
  padding:26px;
  box-shadow:0 8px 20px rgba(15,23,42,.06);
}

.choice-card:hover{
  border-color:var(--accent,#0284c7);
}

.choice-icon{
  font-size:58px;
  margin-bottom:18px;
}

.choice-title{
  font-size:clamp(24px,3vw,38px);
  font-weight:950;
  color:var(--accent,#0284c7);
  text-transform:uppercase;
}

.panel{
  background:#fff;
  border:1px solid var(--line);
  border-radius:26px;
  box-shadow:0 8px 22px rgba(15,23,42,.06);
  padding:22px;
}

.toolbar{
  display:flex;
  align-items:end;
  justify-content:space-between;
  gap:16px;
  margin:22px 0;
}

.date-form{
  display:flex;
  align-items:end;
  gap:12px;
  flex-wrap:wrap;
}

.field label{
  display:block;
  font-weight:900;
  font-size:12px;
  letter-spacing:.08em;
  color:var(--muted);
  text-transform:uppercase;
  margin-bottom:8px;
}

.input,select{
  width:100%;
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  background:#fff;
  font:inherit;
}

.table-wrap{
  overflow:auto;
  border-radius:22px;
  border:1px solid var(--line);
}

.schedule{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  background:#fff;
  min-width:850px;
}

.schedule th,.schedule td{
  border-bottom:1px solid var(--line);
  border-right:1px solid var(--line);
  padding:13px;
  text-align:center;
}

.schedule th:last-child,.schedule td:last-child{border-right:0}
.schedule tr:last-child td{border-bottom:0}

.schedule thead th{
  background:#f8fafc;
  color:#334155;
  font-size:13px;
  text-transform:uppercase;
}

.resource-name{
  text-align:left!important;
  font-weight:950;
  min-width:210px;
}

.badge{
  display:inline-flex;
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  font-weight:900;
  text-transform:uppercase;
}

.badge-special{background:#ffedd5;color:#c2410c}

.available{
  border:0;
  border-radius:999px;
  background:#dcfce7;
  color:#166534;
  padding:9px 13px;
  font-weight:950;
  cursor:pointer;
}

.booked{
  display:inline-flex;
  border-radius:999px;
  background:#fee2e2;
  color:#991b1b;
  padding:9px 13px;
  font-weight:950;
}

.closed{
  display:inline-flex;
  border-radius:999px;
  background:#e5e7eb;
  color:#6b7280;
  padding:9px 13px;
  font-weight:950;
}

.alert{
  border-radius:18px;
  padding:15px 18px;
  margin-bottom:18px;
  font-weight:800;
}

.alert-success{background:#dcfce7;color:#166534}
.alert-error{background:#fee2e2;color:#991b1b}

dialog{
  width:min(620px,calc(100% - 28px));
  border:0;
  border-radius:26px;
  padding:0;
  box-shadow:0 20px 50px rgba(15,23,42,.22);
}

dialog::backdrop{
  background:rgba(15,23,42,.45);
}

.modal-head{
  padding:22px 24px;
  border-bottom:1px solid var(--line);
  display:flex;
  justify-content:space-between;
}

.modal-title{
  margin:0;
  font-size:24px;
}

.modal-body{
  padding:22px 24px;
}

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

.form-grid .full{grid-column:1/-1}

.xbtn{
  border:0;
  background:#f1f5f9;
  border-radius:14px;
  padding:8px 12px;
  font-size:20px;
}

.note{
  color:var(--muted);
  line-height:1.5;
}

.summary-card{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:14px;
  margin:20px 0;
}

.stat{
  background:#fff;
  border:1px solid var(--line);
  border-radius:20px;
  padding:18px;
}

.stat b{
  display:block;
  font-size:30px;
}

.stat span{
  color:var(--muted);
  font-weight:800;
  font-size:12px;
  text-transform:uppercase;
}

.site-footer{
  text-align:center;
  color:#94a3b8;
  font-size:13px;
  padding:16px 0 26px;
}

.admin-box{
  max-width:760px;
  margin:40px auto;
}

.code{
  font-family:monospace;
  background:#0f172a;
  color:#e2e8f0;
  border-radius:16px;
  padding:14px;
  overflow:auto;
}

@media(max-width:900px){
  .grid{grid-template-columns:1fr}
  .brand-pill{letter-spacing:.12em;padding:16px 22px}
  .topbar,.toolbar{align-items:flex-start;flex-direction:column}
  .form-grid{grid-template-columns:1fr}
  .summary-card{grid-template-columns:1fr 1fr}
  .app-shell{width:min(100% - 24px,1180px)}
}

/* Hover animation ringan */
.btn,
.choice-card,
.available {
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
  will-change: transform;
}

.btn:hover,
.available:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 24px rgba(2,132,199,.18);
}

.choice-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: 0 16px 34px rgba(15,23,42,.12);
  border-color: var(--accent,#0284c7);
}

.btn:active,
.available:active,
.choice-card:active {
  transform: translateY(0) scale(.99);
}

/* Hover animation v5 - lebih ringan */
.btn,
.choice-card,
.available {
  transition: transform .12s ease-out, box-shadow .12s ease-out, border-color .12s ease-out !important;
  will-change: auto !important;
}

.btn:hover,
.available:hover {
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 16px rgba(2,132,199,.14) !important;
}

.choice-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: 0 10px 22px rgba(15,23,42,.10) !important;
  border-color: var(--accent,#0284c7) !important;
}

.btn:active,
.available:active,
.choice-card:active {
  transform: translateY(0) !important;
}

.booked-detail {
  display:inline-flex;
  flex-direction:column;
  gap:3px;
  line-height:1.25;
  white-space:normal;
  max-width:180px;
}

.booked-detail small {
  font-size:11px;
  font-weight:800;
}

/* Bilik Karel bulk booking */
.booking-uppercase {
  text-transform: uppercase;
}

.bulk-slot-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.bulk-slot-choice {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 11px 12px;
  font-weight: 850;
  cursor: pointer;
}

.bulk-slot-choice input {
  margin-right: 6px;
}

/* Paparan slot ditempah */
.booked-detail {
  display: inline-flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  line-height: 1.18 !important;
  white-space: normal !important;
  max-width: 190px !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  padding: 8px 10px !important;
}

.booked-detail .booked-label {
  font-size: 9px !important;
  font-weight: 500 !important;
  letter-spacing: .04em !important;
  opacity: .75 !important;
}

.booked-detail .booked-name {
  font-size: 12px !important;
  font-weight: 800 !important;
}

.booked-detail small {
  font-size: 10px !important;
  font-weight: 500 !important;
}

/* Language switcher */
.language-switcher {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 9999;
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.96);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(15,23,42,.08);
}

.language-switcher a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  color: #475569;
}

.language-switcher a.active {
  background: #0f172a;
  color: #fff;
}

.language-switcher .flag {
  font-size: 15px;
  line-height: 1;
}

/* Cancel booking */
.booking-cell-booked {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.cancel-booking-btn {
  border: 1px solid #fecaca;
  background: #fff;
  color: #b91c1c;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 9px;
  font-weight: 800;
  cursor: pointer;
}

.cancel-booking-btn:hover {
  background: #fee2e2;
}

.btn-danger {
  background: linear-gradient(135deg,#dc2626,#b91c1c) !important;
}

.booked-detail {
  font-size: 11px !important;
  font-weight: 500 !important;
}

.booked-detail .booked-label {
  font-size: 9px !important;
  font-weight: 500 !important;
}

.booked-detail .booked-name {
  font-size: 12px !important;
  font-weight: 800 !important;
}

.booked-detail small {
  font-size: 10px !important;
  font-weight: 500 !important;
}

/* Flag icon replacement */
.language-switcher .flag {
  width: 18px;
  height: 12px;
  display: inline-block;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(15,23,42,.18);
}

.flag-my {
  background:
    linear-gradient(90deg,#012169 0 32%,transparent 32%),
    repeating-linear-gradient(to bottom,#cc0001 0 8%,#fff 8% 16%);
}

.flag-uk {
  background:
    linear-gradient(90deg,transparent 0 42%,#fff 42% 58%,transparent 58%),
    linear-gradient(0deg,transparent 0 38%,#fff 38% 62%,transparent 62%),
    linear-gradient(90deg,transparent 0 46%,#c8102e 46% 54%,transparent 54%),
    linear-gradient(0deg,transparent 0 43%,#c8102e 43% 57%,transparent 57%),
    #012169;
}

/* Clean flag icon */
.language-switcher .flag-emoji {
  font-size: 16px;
  line-height: 1;
  display: inline-block;
}

/* Pindah button tukar bahasa ke bawah kiri */
.language-switcher {
  top: auto !important;
  bottom: 16px !important;
  left: 16px !important;
  right: auto !important;
  z-index: 9999 !important;
}

/* Fungsi bahasa dimatikan */
.language-switcher {
  display: none !important;
}

/* Pembatalan tempahan: klik pada slot ditempah */
.cancel-booking-btn {
  display: none !important;
}

.booking-cell-booked,
.booked-detail {
  cursor: pointer !important;
}

.booking-cell-booked:hover .booked-detail {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(153,27,27,.12);
  outline: 1px solid #fecaca;
}

.booking-cell-booked:focus-within .booked-detail {
  outline: 2px solid #fca5a5;
}

/* Popup tempahan berjaya */
.success-booking-dialog {
  border: 0;
  border-radius: 28px;
  width: min(560px, calc(100% - 30px));
  padding: 0;
  box-shadow: 0 24px 70px rgba(15,23,42,.25);
}

.success-booking-dialog::backdrop {
  background: rgba(15,23,42,.45);
}

.success-booking-box {
  background: #fff;
  padding: 34px 30px;
  text-align: center;
  border-radius: 28px;
}

.success-booking-icon {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  font-size: 34px;
  font-weight: 950;
}

.success-booking-box h2 {
  margin: 0 0 14px;
  font-size: 28px;
  font-weight: 950;
  letter-spacing: .08em;
  color: #166534;
}

.success-booking-box p {
  margin: 0 0 24px;
  line-height: 1.55;
  font-weight: 850;
  color: #0f172a;
  text-transform: uppercase;
}

/* Popup tempahan berjaya */
.success-booking-dialog {
  border: 0;
  border-radius: 28px;
  width: min(560px, calc(100% - 30px));
  padding: 0;
  box-shadow: 0 24px 70px rgba(15,23,42,.25);
}

.success-booking-dialog::backdrop {
  background: rgba(15,23,42,.45);
}

.success-booking-box {
  background: #fff;
  padding: 34px 30px;
  text-align: center;
  border-radius: 28px;
}

.success-booking-icon {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  font-size: 34px;
  font-weight: 950;
}

.success-booking-box h2 {
  margin: 0 0 14px;
  font-size: 28px;
  font-weight: 950;
  letter-spacing: .08em;
  color: #166534;
}

.success-booking-box p {
  margin: 0 0 24px;
  line-height: 1.55;
  font-weight: 850;
  color: #0f172a;
  text-transform: uppercase;
}

/* Tajuk utama baharu */
.hero-main-title {
  max-width: 1100px;
  margin-left: auto !important;
  margin-right: auto !important;
  font-size: clamp(34px, 5vw, 72px) !important;
  line-height: 1.08 !important;
  letter-spacing: .10em !important;
}

.brand-pill {
  max-width: 760px;
}

/* Logo UMK */
.front-logo {
  display: block;
  width: min(170px, 38vw);
  height: auto;
  margin: 0 auto 24px;
  object-fit: contain;
}

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

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.topbar-brand img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

@media(max-width:700px) {
  .topbar-brand {
    font-size: 11px;
    border-radius: 18px;
    max-width: 100%;
  }

  .topbar-brand img {
    width: 30px;
    height: 30px;
  }
}

/* Logo layout update */
.topbar-left {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 10px !important;
}

.topbar-brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #0f172a !important;
  text-transform: uppercase !important;
}

.topbar-brand img {
  width: 52px !important;
  height: 52px !important;
  object-fit: contain !important;
}

.library-name-3line {
  display: flex !important;
  flex-direction: column !important;
  line-height: 1.08 !important;
  font-size: 14px !important;
  font-weight: 950 !important;
  letter-spacing: .06em !important;
}

.front-logo {
  margin-bottom: 18px !important;
}

@media(max-width:700px) {
  .topbar-brand img {
    width: 44px !important;
    height: 44px !important;
  }

  .library-name-3line {
    font-size: 12px !important;
  }
}

/* Topbar logo + nama library 1 line, button kembali di bawah */
.topbar-left {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 8px !important;
}

.topbar-brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.topbar-brand img {
  width: 52px !important;
  height: 52px !important;
  object-fit: contain !important;
}

.library-name-1line {
  display: inline-block !important;
  white-space: nowrap !important;
  font-size: 14px !important;
  font-weight: 950 !important;
  letter-spacing: .06em !important;
  line-height: 1.1 !important;
  text-transform: uppercase !important;
  color: #0f172a !important;
}

.topbar-left .back {
  display: inline-flex !important;
  margin-top: 2px !important;
}

@media(max-width:700px) {
  .topbar-brand img {
    width: 42px !important;
    height: 42px !important;
  }

  .library-name-1line {
    font-size: 10.5px !important;
    letter-spacing: .03em !important;
  }
}

/* Page rujukan jadual - readonly */
.readonly-schedule .available,
.readonly-available {
  cursor: default !important;
  pointer-events: none !important;
  display: inline-flex;
}

.readonly-schedule .booked-detail,
.readonly-booked {
  cursor: default !important;
  pointer-events: none !important;
}

.readonly-schedule .booking-cell-booked {
  cursor: default !important;
  pointer-events: none !important;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* Sticky header jadual tempahan */
.table-wrap {
  max-height: calc(100vh - 260px);
  overflow: auto !important;
  position: relative;
}

.schedule thead th {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #f8fafc !important;
  box-shadow: 0 2px 0 rgba(15, 23, 42, .08);
}

/* Pastikan column pertama juga kemas bila scroll */
.schedule thead th:first-child {
  left: 0;
  z-index: 40;
}

/* Fix nama universiti bawah nama library di page booking */
.topbar-brand {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.topbar-brand .brand-text-stack {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  justify-content: center !important;
  gap: 2px !important;
  line-height: 1.1 !important;
}

.topbar-brand .library-name-1line {
  display: block !important;
  white-space: nowrap !important;
  line-height: 1.08 !important;
}

.topbar-brand .university-name-small {
  display: block !important;
  width: 100% !important;
  margin-top: 3px !important;
  font-size: 11px !important;
  font-weight: 850 !important;
  letter-spacing: .10em !important;
  color: #64748b !important;
  text-transform: uppercase !important;
  white-space: nowrap !important;
  line-height: 1.08 !important;
}

@media(max-width:700px) {
  .topbar-brand .library-name-1line {
    font-size: 10.5px !important;
  }

  .topbar-brand .university-name-small {
    font-size: 8.8px !important;
    letter-spacing: .05em !important;
  }
}

/* Disable pembatalan di page booking */
.cancel-booking-btn,
#cancelDialog,
#cancelBookingDialog,
.cancel-dialog,
.cancel-booking-dialog {
  display: none !important;
}

.booking-cell-booked {
  cursor: default !important;
}

/* Countdown redirect selepas tempahan berjaya */
.booking-success-countdown {
  margin: 16px 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #e0f2fe;
  color: #075985;
  font-size: 14px;
  font-weight: 850;
  text-align: center;
  border: 1px solid #bae6fd;
}

.booking-success-countdown strong {
  font-size: 20px;
  font-weight: 950;
  color: #0c4a6e;
}
