/* ===============================
   GLOBAL RESET
================================ */
* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont;
}

html, body {
  height: 100%;
  margin: 0;
  background: #f5f5f5;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ===============================
   HEADER
================================ */
header {
  height: 64px;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  z-index: 30;
}

.menu-btn,
.account-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
}

.logo img {
  height: 32px;
}

/* ===============================
   MAIN + MAP (FULLSCREEN)
================================ */
main {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Map fills ALL available space */
.map-card {
  position: absolute;
  inset: 0;
  background: #e5e5e5;
  pointer-events: auto;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

/* Leaflet container */
#map {
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* Ensure Leaflet controls are visible */
.leaflet-control-container {
  z-index: 25;
}

/* ===============================
   MAP CONTROLS (CUSTOM)
================================ */
.map-controls {
  position: absolute;
  right: 16px;
  top: 40%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 26;
}

.map-controls button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: white;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  cursor: pointer;
}

/* ===============================
   STATUS BAR
================================ */
.status-text,
.status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 6;
  pointer-events: none;
}

/* ===============================
   FOOTER
================================ */
footer {
  padding: 16px;
  background: white;
  box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
  z-index: 30;
}

.rent-btn {
  width: 100%;
  padding: 18px;
  font-size: 18px;
  font-weight: bold;
  background: #00ffff;
  border: none;
  border-radius: 30px;
  cursor: pointer;
}

/* ===============================
   INVENTORY
================================ */
.slot-card {
  background: white;
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 6px;
}

/* ===============================
   SCREENS / OVERLAYS
================================ */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(245, 245, 245, 0.98);
  z-index: 40;
  pointer-events: auto;
}

/* When screen is hidden, it must not block the map */
.screen[style*="display: none"] {
  pointer-events: none;
}

#scan-screen {
  pointer-events: auto;
}

/* ===============================
   TOASTY
================================ */
.toast {
  position: fixed;
  bottom: 96px; /* above Rent button */
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===============================
   QR SCANNER
================================ */
.scan-button {
  margin: 12px;
}

#qr-reader {
  display: none;
  position: fixed;
  inset: 0;
  background: black;
  z-index: 999;
  width: 100%;
}

/* ===============================
  ACCOUNT DRAWER
================================ */
.account-drawer {
  position: fixed;
  top: 0;
  right: -320px;          /* hidden offscreen */
  width: 320px;
  height: 100%;
  background: white;
  box-shadow: -4px 0 12px rgba(0,0,0,0.15);
  transition: right 0.25s ease;
  z-index: 999;
}

.account-drawer.open {
  right: 0;
}

.drawer-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.drawer-user {
  display: flex;
  gap: 10px;
  align-items: center;
}

.avatar {
  font-size: 24px;
}

.drawer-menu {
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
}

.drawer-menu button {
  border: none;
  background: #f5f5f5;
  padding: 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
}

#rent-history-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: #f7f7f7;
  padding: 10px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
}

/* HELP PANEL */
.help-card {
  width: 100%;
  max-width: 420px;
  background: white;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  animation: popIn 0.18s ease;
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.help-title {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 16px;
}

.help-icon {
  font-size: 18px;
}

.help-body {
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

.help-body a {
  color: #00bcd4;
  text-decoration: none;
  font-weight: 500;
}

.help-body a:hover {
  text-decoration: underline;
}

@keyframes popIn {
  from {
    transform: scale(0.96);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===============================
   AUTH MODAL (FLOATING CARD)
================================ */

.auth-card {
  width: 92%;
  max-width: 380px;
  background: white;
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
  padding: 18px;
  animation: modalPop 0.18s ease-out;
}

.auth-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 16px;
}

.auth-header button {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
}

.auth-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
}

.auth-body input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  font-size: 15px;
  font-family: 'Familjen Grotesk', sans-serif;
  outline: none;
  box-sizing: border-box;
}

.auth-body input:focus {
  border-color: #00e5c8;
}

.auth-body #loginSubmitBtn,
.auth-body #registerSubmitBtn {
  width: 100%;
  padding: 14px;
  background: #00e5c8;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Familjen Grotesk', sans-serif;
}

.auth-body #registerSubmitBtn:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: not-allowed;
}

.auth-divider {
  text-align: center;
  font-size: 13px;
  color: #6b7280;
}

.auth-link {
  background: none;
  border: none;
  color: #00c4ab;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  font-family: 'Familjen Grotesk', sans-serif;
}

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

.otp-row input {
  flex: 1;
}

.otp-row #sendOtpBtn {
  padding: 12px 14px;
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Familjen Grotesk', sans-serif;
  white-space: nowrap;
}

.otp-row #sendOtpBtn:hover {
  border-color: #00e5c8;
}

/* subtle animation */
@keyframes modalPop {
  from { transform: scale(0.96); opacity: 0.6; }
  to   { transform: scale(1); opacity: 1; }
}

.auth-switch {
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
  color: #666;
}

.auth-switch span {
  color: #00bcd4;
  cursor: pointer;
  font-weight: 600;
}

/* RENTAL LIVE PANEL */
.rental-live {
  text-align: center;
  padding: 6px 0;
}

.rental-title {
  font-size: 14px;
  color: #666;
  margin-bottom: 4px;
}

.rental-timer {
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0;
}

.rental-sub {
  font-size: 12px;
  color: #888;
}

/* DISPENSING PANEL */
.dispensing-live {
  text-align: center;
  padding: 10px 0;
}

.dispensing-title {
  font-size: 15px;
  font-weight: 600;
  margin-top: 6px;
}

.dispensing-sub {
  font-size: 12px;
  color: #888;
}

/* Spinner */
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid #eee;
  border-top: 3px solid #00ffff;
  margin: auto;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* PAYMENT CONFIRMED */
.payment-confirmed {
  text-align: center;
}

.checkmark {
  font-size: 22px;
  margin-bottom: 4px;
}

.confirmed-title {
  font-weight: 600;
  font-size: 15px;
}

.confirmed-sub {
  font-size: 12px;
  color: #888;
}

.success-card {
  background: white;
  border-radius: 22px;
  padding: 24px;
  text-align: center;
}

.success-powerbank {
  font-size: 64px;
  margin: 10px 0;
}

.success-stats {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.label {
  font-size: 13px;
  color: #777;
}

.search-btn {
  margin-top: 16px;
  border: none;
  background: #f2f2f2;
  padding: 14px;
  border-radius: 999px;
  width: 100%;
}

#rental-mini-bar {
  background: white;
  cursor: pointer;
  transition: background 0.15s;
}

#rental-mini-bar[style*="none"] {
  border-top: none;
}
