/* V1 (WRI-1) read-only pages: patient list and image viewer. All classes are prefixed with v1-. */

.v1-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.v1-page-header h2 {
    margin: 0 0 4px;
    font-size: 24px;
    color: var(--text, #0f172a);
}

.v1-subtitle {
    color: var(--text-secondary, #64748b);
    font-size: 14px;
}

.v1-subtitle span + span::before {
    content: " · ";
}

.v1-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.v1-search {
    position: relative;
}

.v1-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary, #64748b);
}

.v1-search input {
    height: 40px;
    width: 300px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius-sm, 8px);
    font-size: 14px;
}

.v1-button,
.v1-toggle button {
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--border, #e2e8f0);
    background: #fff;
    border-radius: var(--radius-sm, 8px);
    cursor: pointer;
    font-size: 14px;
    color: var(--text, #0f172a);
}

.v1-button:hover {
    background: var(--primary-light, rgba(91, 111, 206, 0.12));
}

.v1-toggle {
    display: inline-flex;
}

.v1-toggle button {
    border-radius: 0;
}

.v1-toggle button:first-child {
    border-radius: var(--radius-sm, 8px) 0 0 var(--radius-sm, 8px);
}

.v1-toggle button:last-child {
    border-radius: 0 var(--radius-sm, 8px) var(--radius-sm, 8px) 0;
    border-left: none;
}

.v1-toggle button.active {
    background: var(--primary, #5B6FCE);
    border-color: var(--primary, #5B6FCE);
    color: #fff;
}

.v1-card {
    background: #fff;
    border-radius: var(--radius-md, 14px);
    border: 1px solid var(--border, #e2e8f0);
    overflow: hidden;
}

.v1-empty-card {
    padding: 32px;
    text-align: center;
    color: var(--text-secondary, #64748b);
}

.v1-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.v1-table th {
    text-align: left;
    padding: 12px 16px;
    background: #f8fafc;
    color: var(--text-secondary, #64748b);
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.v1-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.v1-table tbody tr {
    cursor: pointer;
}

.v1-table tbody tr:hover {
    background: var(--primary-light, rgba(91, 111, 206, 0.12));
}

.v1-table .v1-name {
    font-weight: 600;
}

.v1-table .v1-num {
    text-align: right;
}

.v1-table .v1-empty td {
    text-align: center;
    color: var(--text-secondary, #64748b);
    cursor: default;
}

.v1-loading,
.v1-error {
    padding: 32px;
    text-align: center;
    color: var(--text-secondary, #64748b);
}

.v1-error {
    color: var(--danger, #ef4444);
}

.v1-back {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--primary, #5B6FCE);
    text-decoration: none;
    font-size: 14px;
}

.v1-day {
    font-size: 15px;
    color: var(--text-secondary, #64748b);
    margin: 24px 0 12px;
    font-weight: 600;
}

.v1-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.v1-thumb {
    padding: 0;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: var(--radius-md, 14px);
    background: #000;
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.v1-thumb:hover {
    box-shadow: 0 0 0 3px var(--primary-ring, rgba(91, 111, 206, 0.25));
}

.v1-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.v1-thumb-caption {
    background: #fff;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text, #0f172a);
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.v1-badge {
    background: var(--primary-light, rgba(91, 111, 206, 0.12));
    color: var(--primary, #5B6FCE);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

/* V1 single-image thumbnails are stored mirrored; flip them like the WRI2 desktop apps do.
   They are also cropped to the fundus ellipse, trimming the lens ring: 3% inset per side, the same
   as the full images rendered by WRI2.V1ImageConverter (EllipseInset). Stitches are left as they are. */
.v1-mirror {
    transform: scaleX(-1);
    clip-path: ellipse(47% 47% at 50% 50%);
}

.v1-hidden {
    display: none !important;
}

/* ------------------------------------------------------------------ full-screen image viewer (v1review.js) */

body.v1v-open {
    overflow: hidden;
}

.v1v {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #05081a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    user-select: none;
}

.v1v-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #0A1032;
    flex-wrap: wrap;
}

.v1v-info {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.v1v-patient {
    font-weight: 600;
    color: #fff;
}

.v1v-date,
.v1v-count,
.v1v-status {
    color: #94a3b8;
}

.v1v-warn {
    color: #f59e0b;
}

.v1v-tools {
    display: flex;
    align-items: center;
    gap: 6px;
}

.v1v-tools button,
.v1v-tools a {
    height: 34px;
    min-width: 34px;
    padding: 0 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 13px;
}

.v1v-tools button:hover,
.v1v-tools a:hover {
    background: rgba(255, 255, 255, 0.08);
}

.v1v-tools button:disabled {
    opacity: 0.3;
    cursor: default;
}

.v1v-zoom {
    min-width: 48px;
    text-align: center;
    color: #94a3b8;
}

.v1v-sep {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 6px;
}

.v1v-body {
    flex: 1;
    min-height: 0;
    display: flex;
}

/* Filter list (left), same filters as the V2 viewer */
.v1v-filters {
    width: 112px;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 10px 8px;
    background: #0A1032;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.v1v-filter {
    border: 2px solid transparent;
    background: transparent;
    color: #cbd5e1;
    border-radius: 8px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.v1v-filter img {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 6px;
    background: #000;
}

.v1v-filter:hover {
    background: rgba(255, 255, 255, 0.06);
}

.v1v-filter.active {
    border-color: var(--primary, #5B6FCE);
    color: #fff;
}

.v1v-filter.disabled {
    opacity: 0.3;
    cursor: default;
}

/* Image stage: the full image keeps its natural size and is scaled with a transform */
.v1v-stage {
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
    background: #000;
    cursor: grab;
}

.v1v-stage.dragging {
    cursor: grabbing;
}

.v1v-canvas {
    position: absolute;
    inset: 0;
}

.v1v-full {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: center center;
    max-width: none;
    max-height: none;
    image-rendering: auto;
}

.v1v-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: blur(1px);
}

/* Mirrored V1 thumbnails, cropped to the fundus ellipse like the full images (3% inset) */
.v1v-mirror {
    transform: scaleX(-1);
    clip-path: ellipse(47% 47% at 50% 50%);
}

.v1v-filter img.v1v-mirror {
    clip-path: ellipse(47% 47% at 50% 50%);
}

/* Brightness / contrast panel (right) */
.v1v-panel {
    width: 220px;
    flex-shrink: 0;
    padding: 16px;
    background: #0A1032;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.v1v-panel label {
    display: flex;
    justify-content: space-between;
    color: #cbd5e1;
    margin-top: 8px;
}

.v1v-panel input[type=range] {
    width: 100%;
    accent-color: var(--primary, #5B6FCE);
}

.v1v-reset {
    margin-top: 12px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
}

.v1v-reset:hover {
    background: rgba(255, 255, 255, 0.08);
}

.v1v-hint {
    margin-top: auto;
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 900px) {
    .v1v-panel { width: 160px; }
    .v1v-filters { width: 84px; }
    .v1v-filter img { width: 64px; height: 64px; }
}
