/* Image Upload Styles */
.char-portrait {
    position: relative;
    /* Removed overflow: hidden so buttons can float outside */
    /* overflow: hidden; */
    cursor: pointer;
    background: var(--bg-input);
    transition: all 0.3s ease;
    /* Ensure the circle shape is maintained by children or explicit border-radius on container but allowing overflow? 
       Actually, if we want image clipped to circle but buttons outside, 
       we need image to be circular. 
    */
    /* border-radius: 50%; -- defined in style.css but we need to override if we want square container with round image? 
       No, style.css sets border-radius: 50% on .char-portrait. 
       If overflow is visible, the corners of square children will poke out unless they also have radius.
    */
}

.char-portrait.clickable:hover {
    border-color: var(--text-main);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
}

.char-initials {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
    border-radius: 50%;
    /* Clip if needed */
}

.entity-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    border-radius: 50%;
    /* Clip image to circle since parent overflow is visible */
}

.portrait-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    z-index: 3;
    transition: opacity 0.2s;
    border-radius: 50%;
    /* Clip overlay to circle */
}

.char-portrait.clickable:hover .portrait-overlay {
    opacity: 1;
}

/* Document Cover */
.doc-cover-container {
    width: 100%;
    height: 250px;
    background: var(--bg-input);
    border-radius: 8px;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
}

.doc-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.doc-header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.btn-secondary-small {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-secondary-small:hover {
    border-color: var(--accent);
    color: var(--accent);
}

#btn-remove-cover {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
}

#btn-remove-cover:hover {
    background: #ff4757;
    border-color: #ff4757;
}

/* Dashboard Card with Image */
.dash-card.has-image {
    padding: 0;
    height: 200px;
    justify-content: flex-end;
    align-items: flex-start;
}

.dash-card.has-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, transparent 40%, rgba(0, 0, 0, 0.9) 100%);
    z-index: 1;
}

.dash-card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    transition: transform 0.5s ease;
}

.dash-card.has-image:hover .dash-card-bg {
    transform: scale(1.1);
}

.dash-card.has-image .dash-card-content {
    position: relative;
    z-index: 2;
    padding: 1rem;
    width: 100%;
    text-align: left;
}

.dash-card.has-image .dash-card-title {
    color: white;
    text-shadow: 0 2px 4px black;
    font-size: 1.2rem;
}

.dash-card.has-image .dash-card-icon {
    display: none;
    /* Hide icon if image exists */
}

/* Image Controls */
.img-controls {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%) translateY(5px);
    display: flex;
    gap: 8px;
    z-index: 10;
    pointer-events: auto;

    /* Pill Style */
    background: var(--bg-panel);
    padding: 4px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);

    /* Hide by default until hover? */
    opacity: 0;
    transition: all 0.2s ease;
}

.char-portrait:hover .img-controls {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.btn-mini {
    background: transparent;
    border: none;
    border-radius: 4px;
    /* Slightly rounded squares instead of circles contextually better for pill */
    width: 24px;
    height: 24px;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-mini:hover {
    background: var(--bg-hover);
    color: var(--accent);
    transform: scale(1.1);
}

/* Enforce relative positioning for parent to anchor absolute controls */
.char-portrait {
    position: relative;
}

/* When image is present, cursor should be zoom-in */
.entity-img.clickable-zoom {
    cursor: zoom-in;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.lightbox:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.lightbox:not(.hidden) .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    line-height: 1;
    z-index: 2001;
    text-shadow: 0 0 10px black;
}

.lightbox-close:hover {
    color: var(--accent);
}