/**
 * COMPONENTS.CSS - Botões, Cards, Modais
 */

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-4);
    border: none;
    border-radius: var(--radius);
    font-size: var(--font-base);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    max-height: 30px;
    user-select: none;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-900);
}

.btn-error {
    background: var(--error);
    color: white;
}

.btn-warning {
    background: var(--accent);
    color: white;
}

.btn-large {
    padding: var(--space-4) var(--space-6);
    font-size: var(--font-lg);
    min-height: 52px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--gray-700);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:active {
    background: var(--gray-100);
}

.btn-action {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:active {
    background: var(--gray-50);
}

/* ===== IMAGE COMPARATOR CARD ===== */
.card-wrapper {
    position: relative;
    width: 100%;
    margin-top: var(--space-8);
}

.slider-handle {
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 44px;
    background: white;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    cursor: grab;
    touch-action: none;
    /* REMOVIDO: transition */
}

/* Classe para a nova linha do card de antes e depois */
.slider-line {
    position: absolute;
    top: 0;
    bottom: 0; /* Isso garante que ela tenha a altura EXATA da imagem */
    width: 2px;
    background: white;
    transform: translateX(-50%);
    pointer-events: none;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
    z-index: 25; /* Fica acima das imagens e etiquetas */
}

/* Garante que a camada do "Antes" cubra a etiqueta do "Depois" */
.image-before {
    z-index: 20; /* Camada superior */
    /* background: white;  <- opcional, caso a imagem demore a carregar */
}

/* Ajuste nos labels para ficarem na camada certa */
.ba-label {
    z-index: 10; /* Camada média */
}

.slider-handle:active {
    cursor: grabbing;
    transform: translateX(-50%) scale(1.05);
}

.slider-handle::before {
    content: '⟷';
    font-size: 1.25rem;
    color: var(--gray-700);
    font-weight: bold;
}

.image-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    background: var(--gray-200);
    width: 100%;
}

.image-layer {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* REMOVIDO: transition */
}

/* Performance - GPU Acceleration */
.slider-handle {
    will-change: left;
}

.image-before {
    will-change: clip-path;
}

.image-layer {
    will-change: auto;
}

/* --- */

.ba-label {
    position: absolute;
    top: var(--space-2);
    padding: var(--space-1) var(--space-2);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: var(--font-xs);
    font-weight: 700;
    border-radius: var(--radius-sm);
    z-index: 10;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ba-label-before {
    left: var(--space-2);
}

.ba-label-after {
    right: var(--space-2);
}

/* ===== CARD OVERLAY ===== */
.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(0, 0, 0, 0.7) 50%, transparent 100%);
    padding: var(--space-4) var(--space-3);
    opacity: 1;
    transform: translateY(0px);
    transition: var(--transition);
    z-index: 36;
    pointer-events: all;
}

.card-overlay.is-dragging {
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.overlay-header h3 {
    color: white;
    font-size: var(--font-base);
    flex: 1;
    line-height: 1.3;
}

.price-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-1);
    flex-shrink: 0;
}

.price-current {
    color: var(--gray-900);
}

.price-old {
    font-size: var(--font-xs);
    text-decoration: line-through;
    color: var(--gray-600);
    line-height: 1;
}

.price-discount {
    font-size: var(--font-xs);
    padding: 2px var(--space-1);
    background: var(--error);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 700;
    line-height: 1;
}

.overlay-description {
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--font-sm);
    margin-bottom: var(--space-2);
    line-height: 1.4;
}

/* ===== SEARCH BAR ===== */
.search-wrapper {
    position: relative;
    margin-top: var(--space-2);
    z-index: 100;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-full);
    padding: var(--space-2) var(--space-3);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 101;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: var(--font-base);
    background: transparent;
}

.search-bar .material-symbols-outlined {
    font-size: 1.25rem;
    color: var(--gray-500);
}

.search-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    left: 0;
    right: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 150;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-bottom: 1px solid var(--gray-100);
}

.search-result-item:active {
    background: var(--gray-50);
}

.result-thumb {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
}

/* ===== CATEGORY FILTER ===== */
.category-filter {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 var(--space-4);
    /* Padding base para mobile */
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    padding-left: 52px;
    /* (36px do botão + 2x var(--space-2)) */
    padding-right: 52px;
}

/* ADICIONE ISTO: Para o snap funcionar melhor */
.category-filter .chip {
    scroll-snap-align: start;
}

/* Novo Wrapper para os botões e filtro */
.category-filter-wrapper {
    position: relative;
    width: 100%;
    margin: var(--space-2) 0;
    /* A margem que estava no .category-filter */
    display: flex;
    flex-direction: row;
    justify-content: center;
}

/* Estilo dos botões de scroll */
.category-scroll-btn {
    background: white;
    box-shadow: var(--shadow-md);
    width: 36px;
    /* Um pouco menor para não ser intrusivo */
    height: 36px;
    display: flex;
}

.category-scroll-btn:active {
    background: var(--gray-100);
}

.category-scroll-btn .material-symbols-outlined {
    font-size: 1.25rem;
}

.category-filter::-webkit-scrollbar {
    display: none;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: white;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-full);
    font-size: var(--font-sm);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.chip:active {
    transform: scale(0.95);
}

.chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== UPLOAD ZONE ===== */

.upload-section {
    margin-top: var(--space-8);
}

.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-4);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-zone.drag-active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon {
    font-size: 3rem !important;
    color: var(--primary);
}

.preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-lg);
}

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    animation: fadeIn var(--transition);
}

@media (min-width: 640px) {
    .modal-overlay {
        align-items: center;
        padding: var(--space-4);
    }
}

.modal {
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp var(--transition);
}

@media (min-width: 640px) {
    .modal {
        border-radius: var(--radius-xl);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--gray-200);
}

.modal-body {
    padding: var(--space-4);
}

/* ===== RATING STARS ===== */
.rating-stars {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin: var(--space-4) 0;
}

.rating {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--gray-700);
    font-size: var(--font-sm);
}

/* ===== ALERTS ===== */
.alert {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    border-radius: var(--radius);
    margin: var(--space-3) 0;
    font-size: var(--font-sm);
}

.alert-info {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-dark);
}

.alert-error {
    background: #FEE2E2;
    color: var(--error);
}

/* ===== DROPDOWN MENU - MELHORADO ===== */
.dropdown-menu {
    position: absolute;
    top: calc(100% + var(--space-1));
    right: 0;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 150;
    animation: slideDown 0.2s ease-out;
    overflow: hidden;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--gray-700);
    font-size: var(--font-sm);
    border: none;
    background: white;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease;
}

.dropdown-item:not(:last-child) {
    border-bottom: 1px solid var(--gray-100);
}

.dropdown-item:hover {
    background: var(--gray-50);
}

.dropdown-item:active {
    background: var(--gray-100);
}

.dropdown-item .material-symbols-outlined {
    font-size: 1.25rem;
    color: var(--gray-500);
}

/* ===== FAVORITE BUTTON ANIMATION - CORRIGIDO ===== */
.nav-item.active .material-symbols-outlined[style*="FILL"] {
    animation: heartBeat 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.nav-item .material-symbols-outlined {
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes heartBeat {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.3);
    }

    50% {
        transform: scale(0.9);
    }

    75% {
        transform: scale(1.2);
    }
}

/* ===== STAR RATING ANIMATION ===== */

.star-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.75rem;
    color: var(--gray-300);
    transition: all 0.2s ease;
    padding: 0;
}

.star-button:active {
    transform: scale(1.2);
}

.star-button:hover {
    transform: scale(1.15);
}

.star-button.active {
    color: var(--accent);
    animation: starPop 0.3s ease;
}

@keyframes starPop {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.25);
    }
}

.star-button .material-symbols-outlined {
    transition: font-variation-settings 0.2s ease;
}

.star-button.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ===== MODAL CLOSE BUTTON ===== */
.modal-close-btn {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--error);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.modal-close-btn:hover {
    background: #dc2626;
    transform: scale(1.05);
}

.modal-close-btn:active {
    transform: scale(0.95);
}

.modal-close-btn .material-symbols-outlined {
    font-size: 1.25rem;
}

/* Toasts são definidos em toast.css */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}
