/* ============================================================
   Inline Photo Gallery (IPG) — Replicates project.html styles
   ============================================================ */

/* Outer wrapper (used in client.js template) */
.inline-photos-section {
    background: var(--bg-card, #fff);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Container-level variable overrides for project.html parity */
#inlinePhotosGallery {
    --ipg-radius: 12px;
    --ipg-radius-sm: 6px;
    --ipg-shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --ipg-shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
    --ipg-bg-secondary: #f0f2f5;
}

/* --- Loading & Empty States --- */

.ipg-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 0;
}

.ipg-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ipgSpin 0.8s linear infinite;
}

.ipg-loading-small {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}

.ipg-spinner-small {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ipgSpin 0.8s linear infinite;
}

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

.ipg-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Toolbar (Ver favoritas / Ver ocultos) --- */

.ipg-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.ipg-toolbar-btn {
    padding: 6px 14px;
    border-radius: var(--ipg-radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card, #fff);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ipg-toolbar-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.ipg-toolbar-favs {
    color: #ef4444;
}

.ipg-toolbar-hidden {
    color: var(--text-secondary);
}

/* --- Director Banner --- */

.ipg-director-banner {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: var(--ipg-radius-sm);
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 16px;
    text-align: center;
}

/* --- Decorado Group --- */

.ipg-decorado-group {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border);
    border-radius: var(--ipg-radius);
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: var(--ipg-shadow);
}

.ipg-decorado-none {
    border-style: dashed;
    border-color: var(--text-muted);
    opacity: 0.85;
    box-shadow: none;
}

/* Header — 9-column grid */
.ipg-decorado-header {
    display: grid;
    grid-template-columns: 32px 1fr auto 140px auto auto 24px auto 36px;
    align-items: center;
    column-gap: 10px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #f0f4ff 0%, #faf8ff 50%, #fff5f5 100%);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.ipg-decorado-header::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--primary) 0%, #a78bfa 100%);
    border-radius: 0 4px 4px 0;
}

.ipg-decorado-header-muted {
    background: var(--ipg-bg-secondary);
}

.ipg-decorado-header-muted::before {
    background: var(--text-muted);
}

/* Grid column assignments */
.ipg-decorado-header > .ipg-decorado-icon        { grid-column: 1; }
.ipg-decorado-header > .ipg-decorado-info        { grid-column: 2; }
.ipg-decorado-header > .ipg-deco-search-back     { grid-column: 3; }
.ipg-decorado-header > .ipg-deco-search-input    { grid-column: 4; width: 100%; box-sizing: border-box; }
.ipg-decorado-header > .ipg-deco-search-btn      { grid-column: 5; }
.ipg-decorado-header > .ipg-deco-search-favs     { grid-column: 6; }
.ipg-decorado-header > .ipg-deco-fav-indicator    { grid-column: 7; text-align: center; }
.ipg-decorado-header > .ipg-deco-count           { grid-column: 8; }
.ipg-decorado-header > .ipg-deco-collapse        { grid-column: 9; }

.ipg-decorado-icon {
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card, #fff);
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    color: #ea4335;
}

.ipg-decorado-icon svg {
    width: 18px; height: 18px;
}

.ipg-decorado-info {
    min-width: 0;
    overflow: hidden;
}

.ipg-decorado-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.ipg-decorado-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ipg-deco-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.ipg-decorado-none .ipg-deco-count {
    color: var(--text-muted);
    background: var(--bg-hover);
}

/* Search */
.ipg-deco-search-input {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--ipg-radius-sm);
    font-size: 0.75rem;
    background: var(--bg-card, #fff);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ipg-deco-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79,110,247,0.12);
}

.ipg-deco-search-btn {
    padding: 4px 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--ipg-radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
}

.ipg-deco-search-btn:hover {
    background: var(--primary-hover);
}

.ipg-deco-search-btn svg {
    width: 14px; height: 14px;
}

.ipg-deco-search-favs {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}

.ipg-deco-search-favs input[type="checkbox"] {
    accent-color: var(--primary);
    cursor: pointer;
    width: 13px; height: 13px;
}

.ipg-deco-search-back {
    display: none;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    color: var(--primary);
    cursor: pointer;
    white-space: nowrap;
    font-weight: 500;
    text-decoration: none;
    padding: 3px 8px;
    border-radius: var(--ipg-radius-sm);
    background: var(--primary-light);
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.ipg-deco-search-back:hover {
    background: #e0e7ff;
    border-color: var(--primary);
}

.ipg-deco-search-back svg {
    width: 12px; height: 12px; flex-shrink: 0;
}

.ipg-deco-search-back.visible {
    display: flex;
}

/* Fav indicator */
.ipg-deco-fav-indicator {
    font-size: 1.1rem;
    color: #9ca3af;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.ipg-deco-fav-indicator.has-favs {
    color: #ef4444;
}

/* Collapse */
.ipg-deco-collapse {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.ipg-deco-collapse:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.ipg-deco-collapse svg {
    width: 18px; height: 18px;
    transition: transform 0.3s ease;
}

.ipg-deco-collapse.collapsed svg {
    transform: rotate(-90deg);
}

/* Content & Sections */
.ipg-decorado-content {
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    max-height: 8000px;
    opacity: 1;
}

.ipg-decorado-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.ipg-decorado-sections {
    padding: 24px 28px 28px;
    background: var(--ipg-bg-secondary);
}

.ipg-decorado-none .ipg-decorado-sections {
    background: transparent;
}

.ipg-deco-search-results {
    padding: 16px 20px;
    background: var(--ipg-bg-secondary);
}

/* --- Folders Grid --- */

.ipg-folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 20px;
}

.ipg-folder-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border);
    border-radius: var(--ipg-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: var(--ipg-shadow);
}

.ipg-folder-card:hover {
    border-color: var(--primary);
    box-shadow: var(--ipg-shadow-lg);
    transform: translateY(-3px);
}

.ipg-folder-cover {
    width: 100%;
    aspect-ratio: 16/10;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.ipg-folder-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 60%, rgba(0,0,0,0.06) 100%);
    pointer-events: none;
}

.ipg-folder-cover-ph {
    font-size: 3rem;
    opacity: 0.3;
}

.ipg-folder-info {
    padding: 16px;
}

.ipg-folder-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ipg-folder-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Folder fav button */
.ipg-folder-fav-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 0.2s, background 0.2s, opacity 0.2s;
    padding: 0;
    line-height: 1;
    opacity: 0;
}

.ipg-folder-card:hover .ipg-folder-fav-btn,
.ipg-folder-fav-btn.has-favs,
.ipg-folder-fav-btn.partial-favs {
    opacity: 1;
}

.ipg-folder-fav-btn:hover {
    background: rgba(0,0,0,0.65);
    transform: scale(1.15);
}

.ipg-folder-fav-btn .heart {
    font-size: 1.15rem;
    color: rgba(255,255,255,0.8);
    transition: color 0.2s;
    pointer-events: none;
}

.ipg-folder-fav-btn.has-favs .heart {
    color: #ef4444;
}

.ipg-folder-fav-btn.has-favs {
    background: rgba(255,255,255,0.9);
}

.ipg-folder-fav-btn.partial-favs .heart {
    color: #f6ad55;
}

.ipg-folder-fav-btn.partial-favs {
    background: rgba(255,255,255,0.9);
}

/* Folder hide button */
.ipg-folder-hide-btn {
    position: absolute;
    bottom: 8px; right: 8px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 0.2s, background 0.2s, opacity 0.2s;
    padding: 0;
    opacity: 0;
}

.ipg-folder-card:hover .ipg-folder-hide-btn {
    opacity: 1;
}

.ipg-folder-hide-btn:hover {
    background: rgba(239,68,68,0.8);
    transform: scale(1.15);
}

.ipg-folder-hide-btn svg {
    width: 16px; height: 16px;
    stroke: rgba(255,255,255,0.85);
    fill: none; stroke-width: 2;
    pointer-events: none;
}

.ipg-folder-hide-btn.is-hidden {
    opacity: 1;
    background: rgba(239,68,68,0.7);
}

.ipg-folder-hide-btn.is-hidden svg {
    stroke: #fff;
}

/* --- Photos Grid --- */

.ipg-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: 16px;
}

.ipg-photo-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border);
    border-radius: var(--ipg-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: var(--ipg-shadow);
    position: relative;
}

.ipg-photo-card:hover {
    border-color: var(--primary);
    box-shadow: var(--ipg-shadow-lg);
    transform: translateY(-3px);
}

.ipg-photo-thumb {
    width: 100%;
    aspect-ratio: 1;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-hover);
}

.ipg-photo-info {
    padding: 10px;
}

.ipg-photo-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Photo fav button */
.ipg-photo-fav-btn {
    position: absolute;
    top: 8px; right: 8px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 0.2s, background 0.2s;
    padding: 0; line-height: 1;
}

.ipg-photo-fav-btn:hover {
    background: rgba(0,0,0,0.65);
    transform: scale(1.15);
}

.ipg-photo-fav-btn .heart {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.8);
    transition: color 0.2s, transform 0.2s;
    pointer-events: none;
}

.ipg-photo-fav-btn.favorited .heart {
    color: #ef4444;
}

.ipg-photo-fav-btn.favorited {
    background: rgba(255,255,255,0.9);
}

@keyframes ipgHeartPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.ipg-photo-fav-btn.pop .heart {
    animation: ipgHeartPop 0.35s ease;
}

/* Photo hide button */
.ipg-photo-hide-btn {
    position: absolute;
    bottom: 8px; right: 8px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 0.2s, background 0.2s;
    padding: 0;
    opacity: 0;
}

.ipg-photo-card:hover .ipg-photo-hide-btn {
    opacity: 1;
}

.ipg-photo-hide-btn:hover {
    background: rgba(239,68,68,0.8);
    transform: scale(1.15);
}

.ipg-photo-hide-btn svg {
    width: 16px; height: 16px;
    stroke: rgba(255,255,255,0.85);
    fill: none; stroke-width: 2;
    pointer-events: none;
}

.ipg-photo-hide-btn.is-hidden {
    opacity: 1;
    background: rgba(239,68,68,0.7);
}

.ipg-photo-hide-btn.is-hidden svg {
    stroke: #fff;
}

/* --- Breadcrumb --- */

.ipg-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-size: 0.85rem;
    padding: 8px 0;
}

.ipg-breadcrumb-item {
    color: var(--primary);
    cursor: pointer;
    font-weight: 500;
}

.ipg-breadcrumb-item:hover {
    text-decoration: underline;
}

.ipg-breadcrumb-sep {
    color: var(--text-muted);
}

.ipg-breadcrumb-current {
    color: var(--text-secondary);
    font-weight: 500;
}

.ipg-breadcrumb-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* --- Lightbox --- */

.ipg-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.ipg-lightbox.show {
    display: flex;
}

.ipg-lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
}

.ipg-lightbox-img-wrap {
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-in;
    max-width: 95vw;
    max-height: 90vh;
}

.ipg-lightbox-img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    transition: transform 0.15s ease;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
}

.ipg-lightbox-close {
    position: fixed;
    top: 16px; right: 20px;
    background: none;
    border: none;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    padding: 8px;
    z-index: 10010;
    line-height: 1;
}

.ipg-lightbox-close:hover {
    color: var(--primary);
}

.ipg-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 3rem;
    padding: 20px;
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 8px;
    z-index: 2;
    line-height: 1;
}

.ipg-lightbox-nav:hover {
    background: rgba(255,255,255,0.2);
}

.ipg-lightbox-prev {
    left: 20px;
}

.ipg-lightbox-next {
    right: 20px;
}

.ipg-lightbox-info {
    margin-top: 16px;
    text-align: center;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.ipg-lightbox-caption {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.8);
}

.ipg-lightbox-counter {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
}

/* Lightbox fav button */
.ipg-lightbox-fav-btn {
    position: fixed;
    top: 20px; left: 20px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10010;
    transition: background 0.2s, transform 0.2s;
}

.ipg-lightbox-fav-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.ipg-lightbox-fav-btn .heart {
    font-size: 1.6rem;
    color: rgba(255,255,255,0.8);
    transition: color 0.2s;
    pointer-events: none;
}

.ipg-lightbox-fav-btn.favorited .heart {
    color: #ef4444;
}

/* Lightbox hide button */
.ipg-lightbox-hide-btn {
    position: fixed;
    top: 20px; left: 80px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10010;
    transition: background 0.2s, transform 0.2s;
}

.ipg-lightbox-hide-btn:hover {
    background: rgba(239,68,68,0.5);
    transform: scale(1.1);
}

.ipg-lightbox-hide-btn svg {
    width: 22px; height: 22px;
    stroke: rgba(255,255,255,0.8);
    fill: none; stroke-width: 2;
}

.ipg-lightbox-hide-btn.is-hidden svg {
    stroke: #ef4444;
}

/* Zoom hint */
.ipg-lightbox-zoom-hint {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: rgba(255,255,255,0.7);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.78rem;
    transition: opacity 0.5s;
    pointer-events: none;
    z-index: 10010;
}

/* --- Section title within decorado --- */

.ipg-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
}

.ipg-section-title .ipg-section-fav-indicator {
    font-size: 0.9rem;
    color: #9ca3af;
}

.ipg-section-title .ipg-section-fav-indicator.has-favs {
    color: #ef4444;
}

/* --- Responsive --- */

@media (max-width: 768px) {
    .ipg-decorado-group {
        border-radius: var(--radius, 6px);
    }
    .ipg-decorado-header {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 12px;
    }
    .ipg-decorado-header > .ipg-deco-search-input {
        width: 80px;
    }
    .ipg-decorado-sections {
        padding: 16px;
    }
    .ipg-deco-search-favs span {
        display: none;
    }
    .ipg-folders-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    }
    .ipg-photos-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
    }
    .ipg-lightbox-prev { left: 4px; }
    .ipg-lightbox-next { right: 4px; }
    .ipg-lightbox-nav { font-size: 2rem; padding: 12px; }
    .ipg-lightbox-fav-btn,
    .ipg-lightbox-hide-btn {
        width: 40px; height: 40px;
    }
    .ipg-lightbox-hide-btn { left: 68px; }
}
