/* ============================================================
   Premium UI Enhancements & Responsive Layout Fixes
   ============================================================ */

/* ---- 1. Glassmorphism & Depth ---- */
.sidebar {
  background: rgba(20, 56, 33, 0.98);
  backdrop-filter: blur(12px);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.topbar {
  background: rgba(246, 247, 249, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: 20px;
  margin-top: -20px;
  border-bottom: 1px solid rgba(217, 224, 232, 0.6);
}

/* Softer, more modern shadows for cards */
.card, .dashboard-metric-card, .product-summary-card, .report-stat-card, .audit-stat-card, .product-manage-card {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(231, 222, 201, 0.4);
}

/* ---- 2. Text Overflow Fixes (Responsive / Tablet) ---- */
/* Prevent text from spilling out by using flex min-width and line-clamp */

/* Product Tiles */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  grid-auto-rows: minmax(210px, auto);
  gap: 12px;
  align-content: start;
}

.product-tile {
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  min-height: 210px !important;
  height: 100% !important;
  padding: 10px 12px !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

.product-tile-image {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  height: 100px !important;
  min-height: 100px !important;
  max-height: 100px !important;
  width: 100% !important;
  border-radius: 8px !important;
  background: #f8faf6 !important;
  margin-bottom: 6px !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
  border: 1px solid #edf2eb !important;
}

.product-tile img {
  width: 100% !important;
  height: 100% !important;
  max-height: 100px !important;
  object-fit: contain !important;
}

.product-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 34px;
  margin-bottom: 4px;
  word-break: break-word;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  flex-shrink: 0;
}

.product-tile strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 800;
  color: var(--matcha-dark);
  margin-top: auto;
  display: block;
  line-height: 1.25;
  flex-shrink: 0;
}

.product-tile small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-top: 2px;
  display: block;
  line-height: 1.2;
  flex-shrink: 0;
}

/* Metric Cards */
.dashboard-metric-copy strong {
  word-break: break-word;
  font-size: clamp(18px, 2vw, 24px); /* Scale text down on smaller screens */
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cart Items */
.cart-item-info strong {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.cart-item-total {
  font-size: clamp(14px, 1.5vw, 16px);
}

/* Dashboard Bottom Grid Fix */
.dashboard-bottom-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Top Products / Stock Alerts Text Fix */
.top-product-name, .stock-alert-copy strong, .payment-method-name strong {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.stock-alert {
  align-items: flex-start;
}
.stock-alert b {
  margin-top: 4px;
}

/* ---- 3. Micro-Animations & Interactivity ---- */

/* Cool glowing border on input focus */
input:focus, select:focus {
  border-color: var(--matcha) !important;
  box-shadow: 0 0 0 4px rgba(47, 111, 69, 0.12), inset 0 1px 2px rgba(0,0,0,0.02) !important;
}

/* Fancy button ripple is already in animations.css, let's add a subtle lift to buttons */
.btn {
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(47, 111, 69, 0.2);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

/* Make checkout button look more premium */
.checkout-btn {
  background: linear-gradient(135deg, #2f6f45 0%, #205030 100%);
  box-shadow: 0 6px 16px rgba(47, 111, 69, 0.25);
  transition: all 0.2s ease;
  overflow: hidden;
}
.checkout-btn:hover {
  box-shadow: 0 8px 24px rgba(47, 111, 69, 0.35);
  transform: translateY(-2px);
}
.checkout-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%; width: 50%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shine 3s infinite;
}
@keyframes shine {
  0% { left: -100%; }
  20% { left: 200%; }
  100% { left: 200%; }
}

/* Cashier Category active state */
.cashier-category.active {
  box-shadow: 0 4px 12px rgba(47, 111, 69, 0.2);
  transform: translateY(-1px);
}

/* Product Tile responsive flex layout handled above */

/* Dashboard chart responsive fix */
.dashboard-main-grid {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

/* Ensure empty states look centered and nice */
.dashboard-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
}

/* Adjust layout for tablet mode (900px to 1100px range) */
@media screen and (max-width: 1100px) and (min-width: 901px) {
  .dashboard-metrics {
    grid-template-columns: repeat(2, 1fr);
  }
  .cashier-layout {
    grid-template-columns: minmax(0, 1fr) 420px; /* Narrower cart on tablet */
  }
  .cart-item {
    grid-template-columns: 50px minmax(0, 1fr) auto auto; /* Wrap actions if needed */
  }
  .cart-item-image {
    width: 50px; height: 50px;
  }
}

/* Fix mobile nav overlay */
@media screen and (max-width: 900px) {
  .topbar {
    padding-top: 14px;
    margin-top: 0;
  }
  .sidebar {
    background: rgba(20, 56, 33, 0.98);
    backdrop-filter: blur(16px);
  }
}
