/* ==========================================================================
   PRODUTOS - Catalogo por Categorias + Carrossel Capa de Revista
   Componente: js/components/produtos.js
   ========================================================================== */

/* --- Container principal --- */
.prod-container {
  padding-top: calc(var(--navbar-height) + var(--space-3));
  padding-right: calc(50px + var(--space-4));
  padding-left: var(--space-4);
  padding-bottom: var(--space-3);
  min-height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg-secondary);
  user-select: none;
  overflow: hidden;
}

/* --- Estado vazio / loading --- */
.prod-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--color-text-secondary);
}

.prod-empty i {
  font-size: 48px;
  opacity: 0.4;
}

.prod-empty span {
  font-size: var(--font-size-md);
}

/* ==========================================================================
   VIEW 1: LISTA DE CATEGORIAS
   ========================================================================== */

/* Header */
.prod-cat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  gap: var(--space-4);
  flex-wrap: wrap;
}

.prod-cat-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.prod-cat-title i {
  color: var(--color-primary);
}

/* Search */
.prod-search-wrapper {
  position: relative;
  flex: 0 1 320px;
  min-width: 200px;
}

.prod-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary);
  font-size: 14px;
  pointer-events: none;
}

.prod-search-input {
  width: 100%;
  height: 40px;
  padding: 0 36px 0 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  color: var(--color-text);
  background: var(--color-bg-primary);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.prod-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.prod-search-input::placeholder {
  color: var(--color-text-secondary);
}

.prod-search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.prod-search-clear:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

/* Category Grid */
.prod-cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.prod-cat-card {
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.25, 0.8, 0.25, 1),
              box-shadow 0.25s cubic-bezier(0.25, 0.8, 0.25, 1),
              border-color 0.25s;
  position: relative;
  overflow: hidden;
}

.prod-cat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.prod-cat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  border-color: var(--color-primary);
}

.prod-cat-card:hover::before {
  transform: scaleX(1);
}

.prod-cat-card:active {
  transform: translateY(-2px) scale(0.98);
}

.prod-cat-count {
  font-size: 32px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.prod-cat-icon {
  font-size: 28px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
  opacity: 0.6;
}

.prod-cat-name {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Search Results (products list below categories) */
.prod-search-results {
  margin-top: var(--space-4);
}

.prod-search-results-title {
  font-size: var(--font-size-md);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-3) 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.prod-search-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.prod-search-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.prod-search-item:hover {
  background: var(--color-primary-bg);
  border-color: var(--color-primary);
}

.prod-search-item-photo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.prod-search-item-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.prod-search-item-photo i {
  font-size: 16px;
  color: var(--color-border);
}

.prod-search-item-info {
  flex: 1;
  min-width: 0;
}

.prod-search-item-name {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prod-search-item-cat {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.prod-search-item-arrow {
  color: var(--color-text-secondary);
  font-size: 12px;
  flex-shrink: 0;
}

/* ==========================================================================
   VIEW 2: CARROSSEL DE PRODUTOS (Capa de Revista)
   ========================================================================== */

/* Viewer Header */
.prod-viewer-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  flex-shrink: 0;
}

.prod-back-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.prod-back-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.prod-viewer-title-area {
  flex: 1;
  min-width: 0;
}

.prod-viewer-cat {
  display: block;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.prod-viewer-counter {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  letter-spacing: 0.5px;
}

.prod-viewer-nav {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

.prod-nav-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  background: var(--color-bg-primary);
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.prod-nav-btn:hover:not(:disabled) {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  transform: scale(1.05);
}

.prod-nav-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.prod-nav-btn:disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Viewer (photo + info) */
.prod-viewer {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border);
  margin-top: var(--space-3);
  touch-action: pan-y;
}

.prod-viewer-inner {
  display: flex;
  flex-direction: row;
  height: 100%;
  overflow: hidden;
}

/* --- Transition classes --- */
.prod-viewer-inner.leaving-next .prod-photo-wrapper {
  animation: prodPhotoSlideOutLeft 0.25s ease-in forwards;
}
.prod-viewer-inner.leaving-next .prod-info-panel {
  animation: prodInfoFadeOut 0.2s ease-in forwards;
}
.prod-viewer-inner.entering-next .prod-photo-wrapper {
  animation: prodPhotoSlideInRight 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
.prod-viewer-inner.entering-next .prod-info-panel {
  animation: prodInfoFadeIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0.1s forwards;
  opacity: 0;
}

.prod-viewer-inner.leaving-prev .prod-photo-wrapper {
  animation: prodPhotoSlideOutRight 0.25s ease-in forwards;
}
.prod-viewer-inner.leaving-prev .prod-info-panel {
  animation: prodInfoFadeOut 0.2s ease-in forwards;
}
.prod-viewer-inner.entering-prev .prod-photo-wrapper {
  animation: prodPhotoSlideInLeft 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
.prod-viewer-inner.entering-prev .prod-info-panel {
  animation: prodInfoFadeIn 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) 0.1s forwards;
  opacity: 0;
}

/* Keyframes - Photo parallax (desliza menos = efeito capa de revista) */
@keyframes prodPhotoSlideOutLeft {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-15%); opacity: 0.3; }
}
@keyframes prodPhotoSlideInRight {
  from { transform: translateX(20%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes prodPhotoSlideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(15%); opacity: 0.3; }
}
@keyframes prodPhotoSlideInLeft {
  from { transform: translateX(-20%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* Keyframes - Info panel (fade + slight slide) */
@keyframes prodInfoFadeOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(8px); }
}
@keyframes prodInfoFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Photo wrapper (lado esquerdo) */
.prod-photo-wrapper {
  flex: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #F3F4F6;
  position: relative;
  min-height: 300px;
}

.prod-photo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: var(--space-4);
}

.prod-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  color: var(--color-border);
  width: 100%;
  height: 100%;
  min-height: 250px;
}

.prod-placeholder i {
  font-size: 72px;
  opacity: 0.4;
}

.prod-placeholder span {
  font-size: var(--font-size-sm);
  opacity: 0.5;
}

/* Info panel (lado direito) */
.prod-info-panel {
  flex: 0.8;
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  overflow-y: auto;
  border-left: 1px solid var(--color-border);
  background: var(--color-bg-primary);
}

.prod-info-name {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
  margin: 0 0 var(--space-5) 0;
  line-height: 1.3;
  padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--color-primary-bg);
}

.prod-info-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

.prod-detail-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  transition: background 0.2s;
}

.prod-detail-row:hover {
  background: var(--color-primary-bg);
}

.prod-detail-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.prod-detail-content {
  flex: 1;
  min-width: 0;
}

.prod-detail-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.prod-detail-value {
  display: block;
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--color-text);
  word-break: break-word;
}

.prod-obs-text {
  font-weight: 400;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
}

/* Botao Bula */
.prod-bula-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  margin-top: auto;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-primary);
  background: var(--color-primary);
  color: white;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.prod-bula-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.prod-bula-btn:active {
  transform: translateY(0);
}

/* Progress bar (dots replacement) */
.prod-dots-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  flex-shrink: 0;
}

.prod-dots-track {
  flex: 1;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.prod-dots-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.prod-dots-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
  font-weight: 500;
}

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

/* Portrait (tablet em pe) */
@media (orientation: portrait) {
  .prod-viewer-inner {
    flex-direction: column;
  }

  .prod-photo-wrapper {
    flex: 0 0 auto;
    max-height: 40vh;
    min-height: 200px;
  }

  .prod-info-panel {
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--color-border);
    min-height: 0;
  }

  .prod-info-name {
    font-size: var(--font-size-lg);
  }

  .prod-cat-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .prod-cat-header {
    flex-direction: column;
    align-items: stretch;
  }

  .prod-search-wrapper {
    flex: 1 1 auto;
  }
}

/* Telas pequenas */
@media (max-width: 768px) {
  .prod-container {
    padding-right: var(--space-4);
  }

  .prod-cat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .prod-cat-count {
    font-size: 24px;
  }

  .prod-cat-icon {
    font-size: 22px;
  }

  .prod-obs-text {
    max-height: 80px;
  }
}

/* Telas grandes landscape */
@media (min-width: 1200px) and (orientation: landscape) {
  .prod-cat-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}
