/* Portfolio management + lightbox */
.portfolio-manage-page { padding-top: 24px; }

.portfolio-manage-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.portfolio-manage-head h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.portfolio-manage-lead {
    color: var(--text-secondary);
    font-size: 0.92rem;
    max-width: 640px;
}

.portfolio-manage-grid,
.profile-portfolio-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.portfolio-add-trigger {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #fafbfc;
    min-height: 180px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.portfolio-add-trigger:hover {
    border-color: #00C853;
    color: #00C853;
    background: #f0fdf4;
}

.portfolio-tile-count {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
}

body.portfolio-add-open { overflow: hidden; }

.portfolio-add-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.portfolio-add-modal[hidden] { display: none !important; }

.portfolio-add-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(4px);
}

.portfolio-add-modal-panel {
    position: relative;
    z-index: 1;
    width: min(760px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
    padding: 28px 32px 32px;
    animation: portfolioLightboxIn 0.28s ease;
}

.portfolio-add-modal-panel h2 {
    font-size: 1.35rem;
    margin-bottom: 8px;
}

.portfolio-add-modal-lead {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 22px;
}

.portfolio-add-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.portfolio-add-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.portfolio-upload-drop {
    display: block;
    cursor: pointer;
}

.portfolio-upload-drop input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.portfolio-upload-drop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 140px;
    padding: 24px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #fafbfc;
    text-align: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.portfolio-upload-drop-inner i {
    font-size: 1.8rem;
    color: var(--primary);
}

.portfolio-upload-drop-inner small {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.portfolio-upload-drop.is-dragover .portfolio-upload-drop-inner,
.portfolio-upload-drop:hover .portfolio-upload-drop-inner {
    border-color: var(--primary);
    background: var(--primary-light);
}

.portfolio-upload-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    margin-top: 14px;
}

.portfolio-upload-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.portfolio-upload-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portfolio-upload-preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    cursor: pointer;
    line-height: 1;
}

.portfolio-add-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.portfolio-lightbox-thumbs {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    background: #0f172a;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.portfolio-lightbox-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 48px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.65;
    background: none;
}

.portfolio-lightbox-thumb.active,
.portfolio-lightbox-thumb:hover {
    border-color: #fff;
    opacity: 1;
}

.portfolio-lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portfolio-add-card {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #fafbfc;
    min-height: 180px;
}

.portfolio-add-card summary {
    list-style: none;
    cursor: pointer;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 20px;
}

.portfolio-add-card summary::-webkit-details-marker { display: none; }

.portfolio-add-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e8f5e9;
    color: #00C853;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.portfolio-add-form {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

.portfolio-manage-item {
    position: relative;
}

.portfolio-tile,
.profile-portfolio-item {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: zoom-in;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 4/3;
    text-align: left;
}

.portfolio-tile img,
.profile-portfolio-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.25s ease;
}

.portfolio-tile-caption,
.profile-portfolio-caption {
    position: absolute;
    inset: auto 0 0;
    padding: 28px 12px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
    color: #fff;
    font-size: 0.78rem;
    line-height: 1.35;
    opacity: 0;
    transition: opacity 0.2s;
}

.portfolio-tile:hover img,
.profile-portfolio-item:hover img { transform: scale(1.04); }

.portfolio-tile:hover .portfolio-tile-caption,
.profile-portfolio-item:hover .profile-portfolio-caption { opacity: 1; }

.portfolio-manage-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
}

.portfolio-manage-delete button {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    color: #dc2626;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.portfolio-manage-empty {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.profile-portfolio-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    background: #fafbfc;
    color: var(--text-secondary);
    font-weight: 600;
    min-height: 180px;
    transition: var(--transition);
}

.profile-portfolio-add:hover {
    border-color: #00C853;
    color: #00C853;
    background: #f0fdf4;
}

.profile-portfolio-add i {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e8f5e9;
    color: #00C853;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

/* Lightbox */
body.portfolio-lightbox-open { overflow: hidden; }

.portfolio-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.portfolio-lightbox[hidden] { display: none !important; }

.portfolio-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.82);
    backdrop-filter: blur(4px);
}

.portfolio-lightbox-dialog {
    position: relative;
    z-index: 1;
    width: min(960px, 100%);
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
    animation: portfolioLightboxIn 0.28s ease;
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.9fr);
    grid-template-rows: auto auto;
}

.portfolio-lightbox-stage {
    grid-column: 1;
    grid-row: 1;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
}

.portfolio-lightbox-thumbs {
    grid-column: 1;
    grid-row: 2;
}

.portfolio-lightbox-meta {
    grid-column: 2;
    grid-row: 1 / span 2;
    padding: 24px 22px;
    overflow-y: auto;
}

.portfolio-lightbox-image {
    max-width: 100%;
    max-height: min(72vh, 640px);
    object-fit: contain;
}

.portfolio-lightbox-category {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.portfolio-lightbox-title {
    font-size: 1.2rem;
    margin-bottom: 12px;
    line-height: 1.35;
}

.portfolio-lightbox-description {
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.portfolio-lightbox-counter {
    margin-top: 18px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.portfolio-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.portfolio-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 3;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.portfolio-lightbox-prev { left: 12px; }
.portfolio-lightbox-next { right: 12px; }

@keyframes portfolioLightboxIn {
    from { opacity: 0; transform: scale(0.96) translateY(12px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 900px) {
    .portfolio-manage-grid,
    .profile-portfolio-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .portfolio-lightbox-dialog { grid-template-columns: 1fr; }
    .portfolio-lightbox-stage { min-height: 220px; }
}

@media (max-width: 640px) {
    .portfolio-manage-grid,
    .profile-portfolio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .portfolio-manage-head { flex-direction: column; }
    .portfolio-add-form-grid { grid-template-columns: 1fr; }
    .portfolio-add-modal { padding: 0; }
    .portfolio-add-modal-panel {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
        padding: 20px 16px 24px;
    }
    .portfolio-lightbox { padding: 0; }
    .portfolio-lightbox-dialog {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
}
