/* --- Matrix Card Layout --- */

.approval-card {
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

/* --- Header --- */
.card-header {
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid #444;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lz-name {
    font-size: 1.1rem;
    margin: 0;
    color: var(--accent-color, #007bff);
}

.program-name {
    font-family: monospace;
    color: #888;
    font-size: 0.8rem;
}

.req-count-badge {
    background: #444;
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: bold;
}

/* --- Matrix Table Area --- */
.matrix-container {
    padding: 0;
    overflow-x: auto;
    width: 100%;
    position: relative;
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 800px; /* Ensure enough room for columns */
}

.matrix-table th,
.matrix-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color, #444);
    border-right: 1px solid var(--border-color, #444);
    vertical-align: top;
    text-align: left;
}

.matrix-table td:last-child,
.matrix-table th:last-child {
    border-right: none;
}

/* --- Columns --- */

/* Sticky Field Label */
.th-field,
.td-label {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: #2a2a2a;
    border-right: 2px solid #444;
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    font-weight: bold;
    color: #e1e1e1;
}

/* Live Data Column */
.th-live,
.td-live {
    background-color: rgba(255, 255, 255, 0.02);
    min-width: 200px;
    color: #aaa;
}

/* User Request Columns */
.th-user,
.td-req {
    min-width: 200px;
}

/* Preview Column */
.th-preview,
.td-preview {
    min-width: 150px;
    position: sticky;
    right: 0;
    z-index: 2;
    background-color: #252525; /* Slightly darker than main bg */
    border-left: 2px solid #444;
    color: #fff;
}

/* --- Cell Content Styling --- */
.user-col-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

.user-name {
    color: #fff;
}

.change-badge {
    display: inline-block;
    font-size: 0.7em;
    padding: 2px 4px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: bold;
    align-self: flex-start;
}
.change-badge.create {
    background: #28a745;
    color: white;
}
.change-badge.update {
    background: #ffc107;
    color: black;
}
.change-badge.delete {
    background: #dc3545;
    color: white;
}

.cell-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center; /* Vertically center radio with text line */
    justify-content: flex-start; /* Force to LEFT */
    gap: 8px; /* Consistent gap between radio and text */
    width: 100%;
}

/* The Radio Button itself */
.merge-radio {
    cursor: pointer;
    margin: 0; /* Remove default browser margins */
    width: 16px; /* Explicit size */
    height: 16px;
    flex-shrink: 0; /* Prevent radio from squishing if text is long */
}

/* The Content (Span/Button) */
.cell-wrapper > span,
.cell-wrapper > button {
    text-align: left;
    white-space: nowrap; /* Prevent wrapping for short values */
    overflow: hidden;
    text-overflow: ellipsis; /* Handle long text gracefully */
}

.matrix-table tr:hover .td-label,
.matrix-table tr:hover .td-req,
.matrix-table tr:hover .td-live,
.matrix-table tr:hover .td-preview {
    background-color: #333333 !important;
}

/* --- Diff Highlighting --- */
.td-req.is-diff {
    background-color: rgba(40, 167, 69, 0.15);
    color: #fff;
    font-weight: 500;
}

.td-req.no-change {
    opacity: 0.3;
    text-align: center;
}

/* --- Action Footer --- */
.card-actions {
    padding: 12px 15px;
    background-color: rgba(0, 0, 0, 0.2);
    border-top: 1px solid #444;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
}

/* --- Mobile --- */
@media (max-width: 768px) {
    .card-actions {
        flex-direction: column;
    }
    /* Un-stick columns on mobile if they block view */
    .th-field,
    .td-label,
    .th-preview,
    .td-preview {
        position: static;
        border-right: 1px solid #444;
        border-left: none;
    }
}

.status-msg {
    color: #888;
    text-align: center;
    margin-top: 20px;
}

.error-msg {
    color: #dc3545;
}

/* --- Photo Modal Styles --- */

.photo-modal-layout {
    width: fit-content;
    max-width: min(1000px, 90vw);
    min-width: 300px; /* Prevent it from being too skinny for the Header */

    padding: 0;
    background: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px; /* Added rounded corners for polish */
    margin: auto; /* Helps centering if using native dialog */
}

.photo-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #252525;
    border-bottom: 1px solid #444;
}

.photo-modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    white-space: nowrap; /* Prevent header title from wrapping awkwardly */
}

/* CHANGED: Switch to Flexbox for "Shrink Wrap" behavior */
.photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 20px;

    max-height: 70vh;
    overflow-y: auto;

    /* Center photos if there are only a few on a wide row */
    justify-content: center;
}

/* --- The Thumbnail Card --- */
.photo-thumbnail {
    position: relative;

    /* CHANGED: Explicit size because we aren't using Grid tracks anymore */
    width: 150px;
    height: 150px;

    border-radius: 8px;
    overflow: hidden;
    cursor: zoom-in;
    border: 3px solid transparent;
    background: #000;

    /* Prevent flex items from squishing */
    flex-shrink: 0;
}

.photo-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Crop to fit square */
    transition: transform 0.2s ease;
}

.photo-thumbnail:hover img {
    transform: scale(1.05);
}

/* Status Colors */
.photo-thumbnail.added {
    border-color: #28a745;
}
/* Label for added photos */
.photo-thumbnail.added::after {
    content: "NEW";
    position: absolute;
    top: 5px;
    right: 5px;
    background: #28a745;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.photo-thumbnail.removed {
    border-color: #dc3545;
    opacity: 0.7;
}
.photo-thumbnail.removed::after {
    content: "DELETED";
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* --- Fullscreen Lightbox Dialog --- */
.lightbox-modal {
    /* Reset native dialog styles */
    border: none;
    padding: 0;
    background: transparent;
    max-width: 100vw;
    max-height: 100vh;
    width: 100%;
    height: 100%;
    background-color: transparent;
}

.lightbox-modal[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The dark background behind the image */
.lightbox-modal::backdrop {
    background: rgba(0, 0, 0, 0.95);
    cursor: zoom-out; /* Clicking backdrop closes it */
}

/* Wrapper to help with positioning the close button relative to the image */
.lightbox-content {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.lightbox-modal img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}
