@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Poppins:wght@300;400;500;600;700;800&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Hide un-defined web components to prevent flash of unstyled content (FOUC) */
app-header:not(:defined),
app-sidebar:not(:defined),
app-hero:not(:defined),
product-list:not(:defined),
cart-drawer:not(:defined),
notification-drawer:not(:defined),
app-mobile-nav:not(:defined) {
  opacity: 0;
  visibility: hidden;
}

/* Smooth transition fade-in when loaded */
app-header,
app-sidebar,
app-hero,
product-list,
cart-drawer,
notification-drawer,
app-mobile-nav {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
}

:root {
  /* White & Blue Theme variables mapped to NovaShop structure */
  --primary: #0052cc;
  --primary-light: #00b4d8;
  --primary-dark: #003fa3;
  --bg: #f0f4f8;
  --white: #FFFFFF;
  --text-dark: #102a43;
  --text-gray: #486581;
  --text-light: #627d98;
  --border: #d9e2ec;
  --red: #ff5630;
  --green: #36b37e;
  --orange: #ff9a3c;
  --sidebar-width: 200px;
  --sidebar-collapsed-width: 78px;
  --cart-width: 420px;
  --active-sidebar-width: var(--sidebar-width);
}

body.sidebar-collapsed {
  --active-sidebar-width: var(--sidebar-collapsed-width);
}

body {
  font-family: 'Inter', 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text-dark);
  overflow-x: hidden;
  min-height: 100vh;
}

/* ===== LAYOUT WRAPPERS ===== */
.layout {
  display: flex;
  margin-top: 60px; /* Offset for sticky top-nav */
  min-height: calc(100vh - 60px);
}

/* Custom Web Component wrappers matching structural columns */
app-sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed app-sidebar {
  width: var(--sidebar-collapsed-width);
}

.main-content {
  margin-left: var(--sidebar-width);
  margin-right: var(--cart-width);
  flex: 1;
  padding: 24px 32px;
  min-width: 0;
  transition: margin-left 0.35s cubic-bezier(0.4, 0, 0.2, 1), margin-right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.main-content.cart-closed {
  margin-right: 0;
}

cart-drawer, notification-drawer {
  width: var(--cart-width);
  position: fixed;
  top: 60px;
  right: 0;
  bottom: 0;
  background: var(--white);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 500;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  transform: translateX(0);
  opacity: 1;
}

notification-drawer {
  z-index: 501; /* Layer notifications above cart if stack opened */
}

cart-drawer.closed, notification-drawer.closed {
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
}

/* ===== FLOATING CART TOGGLE BUTTON ===== */
.cart-toggle-float {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%) translateX(100%);
  z-index: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 16px 0 0 16px;
  padding: 20px 12px;
  cursor: grab;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: -4px 0 20px rgba(0, 82, 204, 0.15);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
}

.cart-toggle-float:active {
  cursor: grabbing;
}

.cart-toggle-float.dragging {
  cursor: grabbing !important;
  background: var(--primary-dark) !important;
  box-shadow: -6px 0 25px rgba(0, 82, 204, 0.25) !important;
}

.cart-toggle-float.visible {
  transform: translateY(-50%) translateX(0);
}

.cart-toggle-float:hover {
  background: var(--primary-dark);
  padding-right: 14px;
}

.cart-toggle-float svg {
  width: 24px;
  height: 24px;
  color: white;
  fill: none;
  stroke: currentColor;
}

.cart-toggle-float .float-badge {
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 800;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.cart-toggle-float .float-label {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: white;
}

/* ===== OVERLAY for mobile ===== */
.cart-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 450;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.cart-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-dark);
  color: white;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 8px 25px rgba(0,0,0,0.25);
  white-space: nowrap;
  pointer-events: none;
}

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

/* Custom scrollbars */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in { animation: fadeInUp 0.5s ease forwards; }

/* Responsive adjustments */
@media (max-width: 968px) {
  :root, body, body.sidebar-collapsed {
    --active-sidebar-width: 0px !important;
  }
  body {
    padding-bottom: 72px;
  }
  app-sidebar {
    display: block !important;
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 72px;
    width: 270px;
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--white);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.08);
  }
  app-sidebar.open {
    transform: translateX(0) !important;
  }
  .main-content {
    margin-left: 0;
    margin-right: 0;
  }
  .cart-overlay {
    display: block;
  }
  cart-drawer, notification-drawer {
    bottom: 72px;
  }
  cart-drawer {
    width: 380px;
  }
}

@media (max-width: 600px) {
  cart-drawer {
    width: 100%;
  }
  .main-content {
    padding: 16px;
  }
}

/* Back to Top floating button */
.back-to-top-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(11, 13, 25, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  color: #00f0ff; /* brand cyan */
  box-shadow: 0 8px 24px rgba(11, 13, 25, 0.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
  z-index: 200; /* sits behind drawers (500) and overlay (450) */
}

.back-to-top-btn.visible {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

.back-to-top-btn:hover {
  transform: scale(1.08) translateY(-3px);
  background: #ff2e93; /* brand magenta */
  color: white;
  border-color: #ff2e93;
  box-shadow: 0 10px 25px rgba(255, 46, 147, 0.4);
}

/* Order Placed Dropdown Toast */
.order-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.order-toast-card {
  pointer-events: auto;
  position: relative;
  width: 380px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.02), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  display: flex;
  padding: 20px 24px 20px 20px;
  overflow: hidden;
  border: 1px solid rgba(0, 82, 204, 0.15);
  animation: slideDownIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.order-toast-card.slide-out {
  animation: slideUpOut 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

.order-toast-left-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  background: linear-gradient(to bottom, #0052cc, #5c3cf5);
}

.order-toast-icon-wrapper {
  margin-right: 16px;
  display: flex;
  align-items: flex-start;
  padding-top: 2px;
}

.order-toast-bag-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 82, 204, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(0, 82, 204, 0.05);
  transition: all 0.3s ease;
}

.order-toast-card:hover .order-toast-bag-circle {
  transform: scale(1.05);
  background: rgba(0, 82, 204, 0.15);
}

.order-toast-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-toast-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: #102a43;
}

.order-toast-header strong {
  font-weight: 800;
}

.order-toast-body {
  font-size: 12.5px;
  color: #486581;
  line-height: 1.4;
  margin: 0;
}

.order-toast-time {
  font-size: 11px;
  color: #9cb3c9;
  font-weight: 600;
  margin-top: 2px;
}

.order-toast-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #9cb3c9;
  cursor: pointer;
  padding: 0;
  margin-left: 12px;
  align-self: flex-start;
  line-height: 1;
  transition: color 0.2s;
}

.order-toast-close-btn:hover {
  color: #486581;
}

@keyframes slideDownIn {
  from {
    transform: translateY(-80px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideUpOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-80px);
    opacity: 0;
  }
}

@media (max-width: 480px) {
  .order-toast-container {
    left: 20px;
    right: 20px;
  }
  .order-toast-card {
    width: 100%;
  }
}
