/**
 * Gallery V2 - Styles
 * 
 * Masonry gallery with hover overlay metadata.
 * Works on white/light backgrounds (set in Elementor).
 * 
 * @package CoaMaker
 * @since 2.0.0
 */

/* ============================================
   CSS Variables
   ============================================ */
.coa-gallery-v2 {
    --coa-red: #BB212C;
    --coa-red-darker: #961B24;
    --coa-green: #1D5E23;
    --coa-green-darker: #174A1B;
    --coa-text: #1c2127;
    --coa-text-muted: rgba(28, 33, 39, 0.5);
    --coa-text-secondary: rgba(28, 33, 39, 0.7);
    --coa-card-bg: #fff;
    --coa-card-border: rgba(0, 0, 0, 0.1);
    --coa-input-bg: #f5f5f5;
    --coa-gap: 16px;
}

/* ============================================
   Container
   ============================================ */
.coa-gallery-v2 {
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    color: var(--coa-text);
}

/* ============================================
   Controls Row (Search + Tabs)
   ============================================ */
.coa-gallery-v2__controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* ============================================
   Search
   ============================================ */
.coa-gallery-v2__search {
    flex-shrink: 0;
}

.coa-gallery-v2__search-inner {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
}

.coa-gallery-v2__search-input {
    height: 40px !important;
    padding: 0 16px 0 44px !important;
    background: var(--coa-input-bg) !important;
    border: 1px solid var(--coa-card-border) !important;
    border-radius: 8px !important;
    color: var(--coa-text) !important;
    font-size: 14px !important;
    outline: none !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, width 0.2s ease;
    box-sizing: border-box !important;
    text-indent: 0 !important;
    /* Width set by JavaScript to match first column */
}

.coa-gallery-v2__search-input::placeholder {
    color: #888 !important;
    opacity: 1 !important;
}

.coa-gallery-v2__search-input:focus {
    border-color: var(--coa-red) !important;
    box-shadow: 0 0 0 3px rgba(187, 33, 44, 0.15) !important;
}

.coa-gallery-v2__search-icon {
    position: absolute !important;
    left: 14px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 16px !important;
    height: 16px !important;
    color: var(--coa-text-muted) !important;
    pointer-events: none !important;
    z-index: 2 !important;
}

/* ============================================
   Tabs
   ============================================ */
.coa-gallery-v2__tabs {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 45px;
    background: var(--coa-input-bg);
    padding: 0 4px;
    border-radius: 8px;
    box-sizing: border-box;
}

.coa-gallery-v2__tab {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 24px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--coa-text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.coa-gallery-v2__tab:focus {
    outline: none;
}

.coa-gallery-v2__tab:hover:not(.is-active) {
    color: var(--coa-text);
    background: rgba(0, 0, 0, 0.05);
}

.coa-gallery-v2__tab.is-active {
    background: var(--coa-red);
    color: white;
}

/* ============================================
   Content Sections
   ============================================ */
.coa-gallery-v2__content {
    min-height: 60vh;
}

.coa-gallery-v2__section {
    display: none !important;
}

.coa-gallery-v2__section.is-active {
    display: block !important;
    min-height: 50vh;
}

/* ============================================
   Grid - JS Masonry Layout
   ============================================ */
.coa-gallery-v2__grid {
    position: relative;
    width: 100%;
}

/* Card positioning handled by JavaScript masonry */
.coa-gallery-card {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

.coa-gallery-card.is-laid-out {
    opacity: 1;
}

/* Image link uses padding-bottom for aspect ratio placeholder */
.coa-gallery-card__image-link {
    display: block;
    position: relative;
    width: 100%;
    height: 0;
    /* padding-bottom set inline based on image ratio */
    overflow: hidden;
    border-radius: 4px;
}

.coa-gallery-card__image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 600px) {
    .coa-gallery-v2__search-input {
        width: 100%;
    }

    .coa-gallery-v2__controls {
        flex-direction: column;
        align-items: stretch;
    }
}

/* ============================================
   Card
   ============================================ */
.coa-gallery-card {
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border-radius: 4px;
}

.coa-gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
}

/* Card Content Wrapper */
.coa-gallery-card__inner {
    position: relative;
}

/* ============================================
   Hover Overlay
   ============================================ */
.coa-gallery-card__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 70%, transparent 100%);
    padding: 30px 12px 12px;
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    border-radius: 0 0 4px 4px;
}

.coa-gallery-card:hover .coa-gallery-card__overlay {
    opacity: 1;
}

/* Text and buttons are clickable, gradient passes through to image link */
.coa-gallery-card__title,
.coa-gallery-card__meta {
    pointer-events: none;
}

.coa-gallery-card__title a,
.coa-gallery-card__author {
    pointer-events: auto;
}

.coa-gallery-card__actions {
    pointer-events: auto;
    display: inline-flex;
}

/* Title */
.coa-gallery-card__title {
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.coa-gallery-card__title a {
    color: white;
    text-decoration: none;
}

/* Author & Date */
.coa-gallery-card__meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

/* Larger text on desktop */
@media (min-width: 900px) {
    .coa-gallery-card__title {
        font-size: 16px;
        margin-bottom: 6px;
    }

    .coa-gallery-card__meta {
        font-size: 13px;
    }

    .coa-gallery-card__overlay {
        padding: 40px 14px 14px;
    }
}

.coa-gallery-card__author {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
}

.coa-gallery-card__author:hover {
    color: white;
}

/* ============================================
   Action Buttons
   ============================================ */
.coa-gallery-card__actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    pointer-events: auto;
}

/* Shared button styles */
.coa-gallery-v2 .coa-gallery-card__like-btn,
.coa-gallery-v2 .coa-gallery-card__follow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    border: none;
    border-radius: 6px;
    color: #fff !important;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    line-height: 1;
    text-decoration: none;
    outline: none;
    box-sizing: border-box;
}

/* Like Button */
.coa-gallery-v2 .coa-gallery-card__like-btn {
    gap: 4px;
    background: rgba(255, 255, 255, 0.2);
    padding: 0 10px;
}

.coa-gallery-v2 .coa-gallery-card__like-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.coa-gallery-v2 .coa-gallery-card__like-btn.is-active {
    background: var(--coa-red);
}

.coa-gallery-v2 .coa-gallery-card__like-btn.is-own {
    cursor: default;
}

/* Follow Button */
.coa-gallery-v2 .coa-gallery-card__follow-btn {
    background: var(--coa-red);
    padding: 0 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.coa-gallery-v2 .coa-gallery-card__follow-btn:hover {
    background: var(--coa-red-darker);
}

.coa-gallery-v2 .coa-gallery-card__follow-btn.is-active {
    background: var(--coa-green);
}

.coa-gallery-v2 .coa-gallery-card__follow-btn.is-active:hover {
    background: var(--coa-green-darker);
}

.coa-gallery-v2 .coa-gallery-card__follow-btn.is-own {
    background: rgba(255, 255, 255, 0.2);
    cursor: default;
}

/* ============================================
   Loader (Infinite Scroll)
   ============================================ */
.coa-gallery-v2__loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    margin-top: 20px;
}

.coa-gallery-v2__spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--coa-card-border);
    border-top-color: var(--coa-red);
    border-radius: 50%;
    animation: coa-spin 0.8s linear infinite;
}

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

/* End of gallery indicator */
.coa-gallery-v2__grid:after {
    content: '';
    display: block;
    clear: both;
}

/* ============================================
   Empty State
   ============================================ */
.coa-gallery-v2__empty {
    text-align: center;
    padding: 48px;
    color: var(--coa-text-muted);
    font-size: 16px;
}

/* ============================================
   Pro Prompt
   ============================================ */
.coa-gallery-v2__pro-prompt {
    text-align: center;
    padding: 64px 24px;
    max-width: 400px;
    margin: 0 auto;
}

.coa-gallery-v2__pro-prompt-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    background: var(--coa-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff !important;
    text-decoration: none;
    transition: transform 0.2s ease;
}

.coa-gallery-v2__pro-prompt-icon:hover {
    transform: scale(1.05);
    color: #fff !important;
}

.coa-gallery-v2__pro-prompt-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--coa-text);
    margin: 0 0 12px;
}

.coa-gallery-v2__pro-prompt-text {
    font-size: 15px;
    color: var(--coa-text-muted);
    margin: 0 0 24px;
    line-height: 1.5;
}

.coa-gallery-v2__pro-prompt-btn {
    display: inline-block;
    padding: 12px 32px;
    background: var(--coa-red);
    color: #fff !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.coa-gallery-v2__pro-prompt-btn:hover {
    background: var(--coa-red-darker);
    text-decoration: none;
}
