/**
 * ========================================
 * OVERLAY COMPONENTS - CENTRALIZED STYLES
 * ========================================
 *
 * This file contains all overlay/panel styles used across the app:
 * - Review Panel (Write Review Overlay)
 * - Inbox Panel (Notifications)
 * - Quantity Selector (Product Page)
 *
 * Date: February 25, 2026
 */

/* ========================================
   BASE OVERLAY STYLES (Bottom Sheet Pattern)
   ======================================== */

/* Full-screen container — hidden by default */
.overlay-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
  pointer-events: none;
}

.overlay-container.active {
  display: block;
  pointer-events: all;
}

/* Backdrop and sheet animations driven by container state */
.overlay-container.active .overlay-backdrop  { animation: customFadeIn 0.3s ease forwards; }
.overlay-container.closing .overlay-backdrop { animation: fadeOut 0.3s ease forwards; }

.overlay-container.active .overlay-sheet  { animation: slideInBottom 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards; }
.overlay-container.closing .overlay-sheet { animation: slideOutBottom 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards; }

/* Blurred dark backdrop */
.overlay-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
}

/* Bottom sheet panel */
.overlay-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: 500px;
  background: var(--color-surface, #232a3a);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
}

/* Drag handle */
.overlay-handle {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 0 8px 0;
  cursor: grab;
  touch-action: none;
}

.overlay-handle:active { cursor: grabbing; }

.overlay-handle .handle-bar {
  width: 40px;
  height: 4px;
  background: rgba(var(--color-border-base), 0.3);
  border-radius: 2px;
  transition: all 0.2s ease;
}

.overlay-handle:hover .handle-bar {
  background: rgba(var(--color-border-base), 0.5);
  width: 50px;
}

/* Header row */
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px 20px;
  border-bottom: 1px solid rgba(var(--color-border-base), 0.1);
  background: var(--color-surface, #232a3a);
}

.overlay-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text, #fff);
  display: flex;
  align-items: center;
  gap: 8px;
}

.overlay-header h3 i { color: var(--color-accent, #2196f3); }

/* Scrollable content area */
.overlay-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

/* ========================================
   REVIEW PANEL SPECIFIC
   ======================================== */

/* Review panel is slightly shorter than quantity overlay */
.review-panel .overlay-sheet { max-height: 70vh; }

/* Review panel content has slightly more padding */
.review-panel-content { padding: 20px; }

@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* ========================================
   INBOX PANEL (Side Panel)
   ======================================== */

.inbox-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100vh;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.inbox-panel.active {
  pointer-events: all;
  opacity: 1;
}

.inbox-panel-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.inbox-panel.active .inbox-panel-overlay {
  opacity: 1;
}

.inbox-panel-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 80%;
  height: 100vh;
  background: var(--color-bg);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border-left: 1px solid rgba(var(--color-border-base), 0.05);
  z-index: 1;
}

.inbox-panel.active .inbox-panel-content {
  transform: translateX(0);
}

/* Inbox Header */
.inbox-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(var(--color-border-base), 0.05);
  background: var(--color-surface, #2c3447);
}

.inbox-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--color-text);
  font-size: 1.15rem;
  font-weight: 600;
}

.inbox-header h3 i {
  color: var(--color-accent);
  font-size: 1.1rem;
}

/* Inbox Filters */
.inbox-filters {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--color-bg);
  border-bottom: 1px solid rgba(var(--color-border-base), 0.07);
  overflow-x: auto;
  scrollbar-width: none;
}

.inbox-filters::-webkit-scrollbar {
  display: none;
}

.inbox-filter-btn {
  background: var(--color-surface, rgba(255, 255, 255, 0.05));
  color: var(--color-text-secondary);
  border: 1px solid rgba(var(--color-border-base), 0.2);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.inbox-filter-btn:hover {
  background: var(--color-surface-hover, rgba(var(--color-border-base), 0.08));
}

.inbox-filter-btn.active {
  background: linear-gradient(135deg, var(--color-accent, #2196f3), var(--color-accent-hover, #1976d2));
  color: var(--color-text, #fff);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.inbox-filter-btn i {
  font-size: 0.8rem;
}

/* Inbox Body */
.inbox-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.inbox-body::-webkit-scrollbar {
  width: 8px;
}

.inbox-body::-webkit-scrollbar-track {
  background: transparent;
}

.inbox-body::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--color-text) 20%, transparent);
  border-radius: 4px;
}

.inbox-body::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--color-text) 30%, transparent);
}

/* Empty State */
.inbox-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.inbox-empty-state i {
  font-size: 4rem;
  color: var(--color-text-secondary);
  opacity: 0.3;
  margin-bottom: 20px;
}

.inbox-empty-state h4 {
  color: var(--color-text);
  font-size: 1.2rem;
  margin: 0 0 8px 0;
}

.inbox-empty-state p {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin: 0;
}

/* Messages List */
.inbox-messages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Individual Message */
.inbox-message {
  display: flex;
  flex-direction: row-reverse;
  padding: 16px;
  background: var(--color-surface, #2c3447);
  border-radius: 16px;
  border: none;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.inbox-message:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.inbox-message.unread {
  background: var(--color-surface, #2c3447);
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.15), 0 0 0 2px rgba(33, 150, 243, 0.2);
}

/* Message Icon */
.message-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.message-icon.order-approved {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(124, 58, 237, 0.15));
  color: #8b5cf6;
}

.message-icon.order-delivered {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.15));
  color: #10b981;
}

.message-icon.order-cancelled {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.15));
  color: #ef4444;
}

.message-icon.points-earned {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 152, 0, 0.15));
  color: #ffc107;
}

.message-icon.order-shipped {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(37, 99, 235, 0.15));
  color: #3b82f6;
}

.message-icon.reward {
  background: linear-gradient(135deg, rgba(156, 39, 176, 0.15), rgba(123, 31, 162, 0.15));
  color: #9c27b0;
}

.message-icon.promo {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.15), rgba(211, 47, 47, 0.15));
  color: #f44336;
}

.message-icon.new-product {
  background: linear-gradient(135deg, rgba(0, 188, 212, 0.15), rgba(0, 151, 167, 0.15));
  color: #00bcd4;
}

/* Message Content */
.message-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  line-height: 1.3;
}

.message-time {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.message-body {
  flex: 1;
}

.message-text {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin: 0;
}

.message-text strong {
  color: var(--color-text);
  font-weight: 600;
}

.message-text .clickable-link {
  color: var(--color-accent);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  transition: all 0.2s ease;
}

.message-text .clickable-link:hover {
  color: color-mix(in srgb, var(--color-accent) 80%, white);
  text-decoration-style: solid;
}

.message-text code {
  background: color-mix(in srgb, var(--color-accent) 20%, transparent);
  color: var(--color-accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Inbox Pagination */
.inbox-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  margin-top: auto;
  border-top: 1px solid rgba(var(--color-border-base), 0.07);
  background: var(--color-bg);
}

.inbox-pagination .pagination-btn {
  background: rgba(var(--color-border-base), 0.05);
  color: var(--color-text);
  border: 1px solid rgba(var(--color-border-base), 0.12);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inbox-pagination .pagination-btn:hover:not(:disabled) {
  background: rgba(var(--color-border-base), 0.07);
  transform: translateY(-1px);
}

.inbox-pagination .pagination-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.inbox-pagination .pagination-info {
  color: var(--color-text-secondary);
  font-size: 0.85rem;
}

.inbox-pagination .pagination-info span {
  color: var(--color-text);
  font-weight: 600;
}

/* Inbox Footer */
.inbox-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(var(--color-border-base), 0.07);
  background: var(--color-surface, #2c3447);
}

.inbox-footer .btn-secondary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--color-accent, #2196f3), var(--color-accent-hover, #1976d2));
  color: var(--color-text, #fff);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.inbox-footer .btn-secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
  background: linear-gradient(135deg, var(--color-accent-hover, #1976d2), var(--color-accent, #2196f3));
}

.inbox-footer .btn-secondary:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(33, 150, 243, 0.3);
}

.inbox-footer .btn-secondary i {
  font-size: 1rem;
}

/* ========================================
   QUANTITY OVERLAY SPECIFIC
   ======================================== */

/* Quantity overlay sits above review panel */
.quantity-overlay { z-index: 10000; }

/* Quantity overlay is taller than the review panel */
.quantity-overlay .overlay-sheet { max-height: 85vh; }

/* Tighter top padding for the content area */
.quantity-overlay .overlay-content { padding: 12px 20px 20px; }

.overlay-title {
  margin: 0 0 16px 0;
  color: var(--color-text);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.overlay-title i {
  color: var(--color-accent);
}

.discount-info {
  margin-bottom: 12px;
}

.weight-options-container {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Scrollable weight options container */
#weight-options-container {
  -webkit-overflow-scrolling: touch;
}

/* Weight option styles */
.overlay-weight-option {
  background: rgba(var(--color-border-base), 0.04);
  /* border: 2px solid rgba(255, 255, 255, 0.1); */
  border: 2px solid rgba(var(--color-border-base), 0.05);

  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.overlay-weight-option:hover {
  background: rgba(var(--color-border-base), 0.07);
}

.overlay-weight-option.selected {
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  border-color: var(--color-accent);
}

.overlay-weight-option .weight-check {
  color: var(--color-accent);
  font-size: 1.1rem;
  margin-left: 8px;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.overlay-weight-option.selected .weight-check {
  transform: scale(1.2) rotate(360deg);
}

.overlay-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: rgba(var(--color-border-base), 0.04);
  border: 2px solid rgba(var(--color-border-base), 0.05);
  border-radius: 8px;
  margin-bottom: 16px;
}

.overlay-total-label {
  color: var(--color-text-secondary);
  font-weight: 600;
}

.overlay-total-price {
  color: var(--color-accent);
  font-weight: 700;
  font-size: 1.3rem;
}

.quantity-overlay .add-to-cart-btn {
  width: 100%;
  margin: 0;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
  .overlay-sheet {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
  }

  /* Inbox panel mobile adjustments */
  .inbox-header h3 {
    font-size: 1.1rem;
  }

  .message-icon {
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }

  .message-title {
    font-size: 0.95rem;
  }

  .message-text {
    font-size: 0.85rem;
  }
}

@media (min-width: 769px) {
  .inbox-panel-content {
    max-width: 400px;
  }
}

@media (max-width: 480px) {
  .overlay-title {
    font-size: 1.1rem;
  }

  .overlay-total-price {
    font-size: 1.2rem;
  }

  .quantity-overlay .overlay-content {
    padding: 12px 16px 16px;
  }
}

/* ========================================
   DEBUG OVERLAY
   ======================================== */

/**
 * Debug Overlay Component
 * Visual debug log for environments where console is not accessible (e.g., Telegram WebApp)
 * Only shown in development mode
 */
#debug-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.9);
  color: #0f0;
  font-family: monospace;
  font-size: 10px;
  padding: 10px;
  z-index: 999999;
  display: none;
}

#debug-overlay.visible {
  display: block;
}

#debug-overlay .debug-line {
  margin: 2px 0;
  word-break: break-word;
}
