/* ============================================
   GALERIA DE IMAGENS - PRODUTOSHOW
   Tema: #ff6b35 (laranja vibrante)
   ============================================ */

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

body {
    font-family: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: var(--ps-bg);
    min-height: 100vh;
    overflow-x: clip; /* Previne scroll horizontal sem quebrar position: sticky dos filhos */
}

/* Header fixo da barra de tarefas (padrão GP5) */
header.header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1030 !important;
    background-color: #ffffff !important;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Cabeçalho da Galeria e Informações */
.galeria-header {
    margin-bottom: 1rem;
}

.galeria-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.galeria-header p {
    font-size: 0.9rem;
}

/* Abas Principais (Minha Galeria, Comandos, Explorar) */
.ps-main-tabs-wrapper {
    position: sticky;
    top: var(--ps-header-height, 76px);
    z-index: 1020;
    background-color: var(--ps-bg, #f8f9fa);
    padding-top: 10px;
    border-bottom: 2px solid var(--ps-border, #e9ecef);
    margin-bottom: 1.5rem;
}

.ps-main-tabs {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ps-main-tabs::-webkit-scrollbar {
    display: none;
}

.ps-main-tab-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.75rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    color: #6c757d;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    transition: all 0.2s ease-in-out;
}

.ps-main-tab-btn .material-icons {
    font-size: 1.3rem;
    transition: transform 0.2s ease;
}

.ps-main-tab-btn:hover {
    color: var(--ps-primary, #ff6b35);
}

.ps-main-tab-btn:hover .material-icons {
    transform: translateY(-1px);
}

.ps-main-tab-btn.active {
    color: var(--ps-primary, #ff6b35);
    border-bottom-color: var(--ps-primary, #ff6b35);
}

.ps-tab-pane {
    display: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ps-tab-pane.active {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    animation: psFadeInTab 0.2s ease-out;
}

@keyframes psFadeInTab {
    from {
        opacity: 0;
        transform: translateY(3px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ps-tab-empty {
    padding: 3rem 1.5rem;
    background: var(--ps-surface, #ffffff);
    border: 1px dashed var(--ps-border, #dee2e6);
    border-radius: 12px;
}

/* ─── GRID E CARDS DE COMANDOS ───────────────────────── */
.ps-comandos-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    margin: 0 auto 2.5rem;
    width: 100%;
    max-width: 1100px;
    box-sizing: border-box;
}

.ps-comando-card {
    background: var(--ps-surface, #ffffff);
    border: 2px solid var(--ps-border, #e5e7eb);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.ps-comando-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    border-color: rgba(255, 107, 53, 0.4);
}

.ps-comando-card.selected {
    border-color: var(--ps-primary, #ff6b35) !important;
    outline: 2px solid var(--ps-primary, #ff6b35);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.18), 0 10px 25px rgba(255, 107, 53, 0.12);
    background: #fffbf9;
    transform: translateY(-3px);
}

.ps-comando-check {
    display: none;
    color: var(--ps-primary, #ff6b35);
    font-size: 1.25rem;
    line-height: 1;
}

.ps-comando-card.selected .ps-comando-check {
    display: inline-flex;
    align-items: center;
}

.ps-comando-zoom-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    border: none;
    color: #ffffff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    z-index: 3;
}

.ps-comando-zoom-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: var(--ps-primary, #ff6b35);
}

.ps-comando-zoom-btn .material-icons {
    font-size: 1.25rem;
}

.ps-comando-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    min-width: 0;
}

.ps-comando-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--ps-text, #1f2937);
    margin: 0;
    line-height: 1.3;
    word-break: break-word;
}

.ps-comando-badge {
    display: none !important;
}

.ps-comando-desc {
    font-size: 0.9rem;
    color: var(--ps-muted, #6b7280);
    line-height: 1.45;
    margin-bottom: 1rem;
    flex-grow: 1;
    word-break: break-word;
}

.ps-comando-img-wrapper {
    position: relative;
    width: 100%;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.ps-comando-img {
    width: 100%;
    max-width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

.ps-comando-img-wrapper:hover .ps-comando-img {
    transform: scale(1.03);
}

.ps-comando-img-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.ps-comando-img-wrapper:hover .ps-comando-img-overlay {
    opacity: 1;
}

.ps-comando-img-overlay .material-icons {
    color: #ffffff;
    font-size: 2.2rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Busca */
.busca-container {
    max-width: 500px;
    margin: 0 auto 1.5rem;
}

.campo-busca {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid var(--ps-border);
    border-radius: 50px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--ps-surface);
    color: var(--ps-text);
}

.campo-busca:focus {
    border-color: var(--ps-primary);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.15);
}

.campo-busca::placeholder {
    color: var(--ps-muted);
}

/* Grid Responsivo - 3 colunas desktop, fluxo horizontal estrito por data/hora */
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    align-items: start;
}

/* Card da Imagem */
.grid-item {
    background: var(--ps-surface, #ffffff);
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--ps-border, #e5e7eb);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    box-sizing: border-box;
    overflow: hidden;
}

.grid-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transform: translateY(-3px);
    border-color: rgba(255, 107, 53, 0.4);
}

/* Cabeçalho do Card (Título na parte superior) */
.grid-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    min-width: 0;
    min-height: 2.2rem;
}

.grid-item-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ps-text, #1f2937);
    margin: 0;
    line-height: 1.35;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Moldura interna da imagem - nada encosta nas bordas do card */
.grid-thumb-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.grid-thumb-wrapper img,
.grid-item img {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    display: block;
    background: #f8f9fa;
    transition: transform 0.3s ease;
}

.grid-item:hover .grid-thumb-wrapper img {
    transform: scale(1.02);
}

.grid-thumb-wrapper video.ps-video-hover-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #f8f9fa;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1;
}

.grid-item.is-video:hover video.ps-video-hover-preview {
    opacity: 1;
}

.ps-video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
    z-index: 2;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ps-video-play-btn i {
    font-size: 32px;
    margin-left: 2px;
    color: #ffffff;
}

.grid-item.is-video:hover .ps-video-play-btn {
    transform: translate(-50%, -50%) scale(1.15);
    background: #ff6b35;
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.5);
}

/* Botão de Zoom para Imagens */
.ps-grid-zoom-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.65);
    border: none;
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
    z-index: 2;
}

.ps-grid-zoom-btn:hover {
    opacity: 1;
    transform: scale(1.1);
    background: var(--ps-primary, #ff6b35);
}

.ps-grid-zoom-btn .material-icons {
    font-size: 1.15rem;
}

.ps-video-duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    pointer-events: none;
    z-index: 2;
}

.ps-video-type-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #ff6b35;
    color: #ffffff;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 2px 6px rgba(255, 107, 53, 0.4);
    z-index: 2;
}

/* Área inferior com Tags e Métricas */
.grid-item .info {
    padding: 0;
    border-top: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
}

.grid-item .tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
}

.grid-item .tag {
    font-size: 0.72rem;
    color: var(--ps-primary);
    background: rgba(255, 107, 53, 0.1);
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 500;
    white-space: nowrap;
}

.grid-item .metrics {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--ps-muted);
}

.grid-item .metrics i {
    font-size: 13px;
    vertical-align: middle;
    margin-right: 2px;
}

.grid-item .tamanho {
    font-size: 0.65rem;
    color: var(--ps-muted);
}

/* Seleção */
.grid-item.selected {
    border-color: var(--ps-primary, #ff6b35) !important;
    outline: 2px solid var(--ps-primary, #ff6b35);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.18), 0 10px 25px rgba(255, 107, 53, 0.12);
    background: #fffbf9;
    transform: translateY(-3px);
}

/* Estados */
.loading, .empty, .error {
    text-align: center;
    padding: 60px 20px;
    color: var(--ps-muted);
    font-size: 1rem;
    grid-column: 1 / -1;
}

.loading::before {
    content: '';
    display: block;
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 3px solid var(--ps-border);
    border-top-color: var(--ps-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error {
    color: #dc3545;
}

.empty::before {
    content: '';
    display: block;
    width: 60px;
    height: 60px;
    margin: 0 auto 15px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23ccc' viewBox='0 0 24 24'%3E%3Cpath d='M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
}

/* Modal de Visualização */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-content,
#modalVisualizacao .modal-content {
    max-width: 92vw;
    max-height: 90vh;
    width: auto;
    background: transparent;
    border: none;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.modal-content img,
#modalVisualizacao .modal-content img {
    max-width: 100%;
    max-height: 75vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
    display: block;
}

.modal-close {
    position: absolute;
    top: -45px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    transform: scale(1.15);
    color: var(--ps-primary);
}

.modal-info {
    text-align: center;
    margin-top: 15px;
    color: #ddd;
    font-size: 0.9rem;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
}

/* Media Queries para Grid Responsivo */
@media screen and (max-width: 900px) {
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    .galeria-header h1 {
        font-size: 1.35rem;
    }
}

@media screen and (max-width: 600px) {
    .grid-container {
        grid-template-columns: 1fr;
        width: 100%;
        gap: 0.75rem;
    }
    body {
        padding: 10px;
    }
    .galeria-header h1 {
        font-size: 1.2rem;
    }
    .campo-busca {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    /* Indicador visual de abas adicionais (Peek Effect & Fade de Overflow) */
    .ps-main-tabs-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 2px;
        width: 38px;
        background: linear-gradient(to right, transparent, var(--ps-bg, #f7f7f9));
        pointer-events: none;
        z-index: 2;
    }

    .ps-main-tabs {
        gap: 0.35rem;
        padding-right: 2rem;
    }

    .ps-main-tab-btn {
        padding: 0.6rem 0.8rem;
        font-size: 0.88rem;
        gap: 0.35rem;
    }

    .ps-main-tab-btn .material-icons {
        font-size: 1.15rem;
    }

    .ps-comandos-grid {
        grid-template-columns: 100%;
        width: 100%;
        max-width: 100%;
        gap: 1rem;
    }

    .ps-comando-card {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 1rem;
        box-sizing: border-box;
    }

    .ps-comando-img-wrapper {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    .ps-comando-img {
        width: 100%;
        max-width: 100%;
        height: auto;
        object-fit: contain;
    }

    #modalVisualizacao {
        padding: 10px;
    }

    #modalVisualizacao .modal-content {
        max-width: 95vw;
        width: 100%;
    }

    #modalVisualizacao .modal-content img {
        max-width: 100%;
        max-height: 70vh;
        width: auto;
        height: auto;
    }
}