/* ========== Global ==========\ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #0b0f19;
  color: #e5e7eb;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.app {
  max-width: 1200px;
  margin: 18px auto;
  padding: 8px 16px;
}

h1 {
  text-align: center;
  margin-bottom: 8px;
}

.topbar {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar input {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: transparent;
  color: inherit;
}

.logout-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #dc2626;
  color: #f9fafb;
  font-size: 0.85rem;
  transition: background-color 150ms ease;
}

.logout-btn:hover {
  background: #b91c1c;
}

.logout-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ========== Main layout (left = floorplan, right = panel) ==========\ */

.main-layout {
  display: flex;
  gap: 24px;
}

/* ========== Floorplan (left) ==========\ */

.floorplan {
  width: 260px;
  height: 520px;
}

/* Outer white outline */
.floor-border {
  width: 100%;
  height: 100%;
  border: 2px solid #ffffff;
  display: flex;
  flex-direction: column; /* stack rooms vertically */
}

/* Base room styles */
.floor-room,
.floor-room-disabled {
  width: 100%;
  border-bottom: 2px solid #ffffff; /* horizontal divider between rooms */
  background: #0b0f19;
  display: flex;
  align-items: center;
  padding-left: 12px;
}

.floor-border {
  width: 100%;
  height: 100%;
  border: 2px solid #ffffff;
  display: flex;
  flex-direction: column; /* stack vertically: D, 4, 3, 2, 1 */
}

/* Base room styles */
.floor-room,
.floor-room-disabled {
  border-bottom: 2px solid #ffffff; /* divider line */
  background: #0b0f19;
  display: flex;
  align-items: center;
  padding-left: 12px;
  box-sizing: border-box;
}

/* Disabled room (D) – full width */
.floor-room-disabled {
  flex: 2;          /* height */
  width: 100%;      /* full width of the outline */
}

/* Normal rooms (4,3,2,1) – narrower */
.floor-room {
  flex: 0.7;        /* shorter than D */
  width: 70%;       /* <-- smaller than D */
}


/* Disabled room is taller */
.floor-room-disabled {
  flex: 1.6; /* tweak this to make it bigger/smaller */
}

/* Ensure relative positioning for door placement on both big and small rooms */
.floor-room-disabled,
.floor-room {
  position: relative;
}

/* Brand logo placed inside corridor on the right side */
.brand-logo {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 120px; /* larger logo */
  height: auto;
  opacity: 0.98;
  filter: saturate(1) contrast(1);
  z-index: 6;
  pointer-events: none;
}

/* Slightly smaller on narrow screens */
@media (max-width: 720px) {
  .brand-logo { width: 90px; right: 8px; top: 10px; }
}

/* Decorative door for Room 5 */

.room-door {
  position: absolute;
  right: 6px;
  top: 18%;
  width: 12px;
  height: 64%;
  background: rgba(255,255,255,0.06);
  border-left: 1px solid rgba(255,255,255,0.12);
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
  transition: background-color 150ms ease, transform 150ms ease;
}

/* Slightly smaller door for compact rooms (1–4) */
.floor-room .room-door {
  right: 6px;
  top: 20%;
  width: 10px;
  height: 60%;
}

/* Bottom-right door variant for the large Room 5 */
.room-door-bottom {
  top: auto;
  bottom: 6px;
  right: 8px;
  width: 10px;
  height: 22px;
  border-left: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
  z-index: 3;
}

/* Slight adjustment when the big room is active */
.floor-room-disabled.room-active .room-door.room-door-bottom {
  background: rgba(59,130,246,0.09);
}

/* Slightly brighter when room active */
.floor-room-disabled.room-active .room-door {
  background: rgba(59,130,246,0.08);
}

/* Red-tinted door when room closed */
.room-door.door-closed {
  background: rgba(220,38,38,0.12);
  border-left-color: rgba(220,38,38,0.25);
}

/* Label text inside the room boxes */
.floor-room-label {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
}

/* (Optional) subtle hover on active rooms */
.floor-room:hover,
.floor-room-disabled:hover {
  background: #111827; /* or whatever colour you used */
}


/* ========== Right-hand panel ==========\ */

.panel {
  flex: 1;
  background: rgba(15, 23, 42, 0.95);
  border-radius: 10px;
  border: 1px solid rgba(31, 41, 55, 0.8);
  padding: 16px;
  min-height: 520px;
}

.scanner {
  margin: 10px 0;
}

.scanner input {
  padding: 8px 10px;
  margin-right: 6px;
  width: 260px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.8);
  background: transparent;
  color: inherit;
}

.scanner button {
  padding: 8px 10px;
  margin-right: 6px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #4b5563;
  color: #e5e7eb;
}

.scanner button:hover {
  background: #6b7280;
}

.mode-tag {
  font-size: 0.8rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.3);
}

/* Scan history + current items */

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.items-table th,
.items-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(55, 65, 81, 0.8);
  text-align: left;
}

.end-btn {
  background: #ef4444;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.end-btn:hover {
  background: #f97373;
}

.muted {
  opacity: 0.7;
  font-size: 0.9rem;
}

.current-list {
  list-style: none;
  padding-left: 0;
  margin: 0 0 8px 0;
}

.current-list li {
  margin-bottom: 4px;
}

.pill {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(55, 65, 81, 0.9);
  font-size: 0.75rem;
}

.mode-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0;
}

.mode-option {
  text-align: left;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
}

.mode-option-active {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.8);
}

.visits-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.visit-card {
  border-radius: 8px;
  border: 1px solid rgba(55, 65, 81, 0.9);
  padding: 8px 10px;
  background: rgba(15, 23, 42, 0.9);
}

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

.visit-title {
  font-weight: 600;
}

.visit-status {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.visit-status-closed {
  background: rgba(148, 163, 184, 0.25);
  color: #e5e7eb;
}

.visit-meta {
  font-size: 0.75rem;
  opacity: 0.8;
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
}


.end-day-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: #b91c1c;
  color: #f9fafb;
  font-size: 0.85rem;
}
.end-day-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Stock tab button in topbar */
.stock-btn {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.85rem;
}
.stock-btn.active {
  background: rgba(59,130,246,0.15);
  border-color: rgba(59,130,246,0.8);
}

/* Highlight rooms that have an active visit */
.room-active {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.6);
}

/* Subtle translucent background for active rooms */
.floor-room.room-active {
  background: rgba(59, 130, 246, 0.06);
}
.floor-room-disabled.room-active {
  background: rgba(59, 130, 246, 0.06);
}

/* Small pill for room counts (slightly smaller than other pills) */
.pill {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(55, 65, 81, 0.9);
  font-size: 0.75rem;
}

/* Closed room styling */
.floor-room.closed,
.floor-room-disabled.closed {
  background: rgba(148, 163, 184, 0.06);
  color: rgba(226, 232, 240, 0.9);
  opacity: 0.95;
}
.floor-room.closed .floor-room-label,
.floor-room-disabled.closed .floor-room-label {
  color: rgba(148, 163, 184, 0.95);
}

.room-closed-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.12);
  color: #fca5a5;
  font-size: 0.7rem;
}

/* ========== LOGIN PAGE ==========\ */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0b0f19;
  padding: 20px;
}

.login-box {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(31, 41, 55, 0.8);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.login-logo {
  width: 100%;
  max-width: 160px;
  height: auto;
  margin: 0 auto 24px;
  display: block;
}

.login-box h1 {
  text-align: center;
  margin: 0 0 24px 0;
  font-size: 1.75rem;
  color: #e5e7eb;
}

.login-field {
  margin-bottom: 16px;
}

.login-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #cbd5e1;
}

.login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.8);
  color: #e5e7eb;
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.login-field input:focus {
  outline: none;
  border-color: rgba(59, 130, 246, 0.8);
  background: rgba(30, 41, 59, 1);
}

.login-field input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-button {
  width: 100%;
  padding: 12px;
  margin-top: 24px;
  border: none;
  border-radius: 6px;
  background: #3b82f6;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.login-button:hover:not(:disabled) {
  background: #2563eb;
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: #fca5a5;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

/* ========== STOCK LIST ==========\ */
.stock-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.stock-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(55, 65, 81, 0.6);
  border-radius: 6px;
  padding: 12px;
}

.stock-item-barcode {
  flex: 1;
  font-weight: 600;
  font-family: monospace;
  color: #e5e7eb;
}

.stock-item-qty {
  font-size: 0.9rem;
  color: #cbd5e1;
  min-width: 60px;
  text-align: right;
}

.stock-item-clear {
  padding: 4px 8px;
  background: #dc2626;
  color: #f9fafb;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: background-color 150ms ease;
}

.stock-item-clear:hover {
  background: #b91c1c;
}
