/* Design Review Portal — Styles */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --color-primary: #2563EB;
    --color-primary-dark: #1E40AF;
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-border: #E2E8F0;
    --color-text: #1E293B;
    --color-text-muted: #64748B;
    --color-success: #16A34A;
    --color-highlight: rgba(37, 99, 235, 0.15);
    --sidebar-width: 140px;
    --panel-width: 320px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* --- Header --- */

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 600;
}

.version-badge {
    font-size: 13px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--color-highlight);
    color: var(--color-primary);
    font-weight: 500;
}

.status-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.status-draft { background: #FEF3C7; color: #92400E; }
.status-review { background: #DBEAFE; color: #1E40AF; }
.status-final { background: #D1FAE5; color: #065F46; }

.header-right {
    font-size: 14px;
    color: var(--color-text-muted);
}

.link-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 13px;
    padding: 0;
}

.link-btn:hover {
    text-decoration: underline;
}

/* --- Main Layout (3 columns) --- */

.review-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--panel-width);
    height: calc(100vh - 57px - 60px); /* header + submit bar */
    overflow: hidden;
}

/* --- Thumbnail Sidebar --- */

.thumbnail-nav {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.thumbnail {
    position: relative;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 2px;
    transition: border-color 0.15s;
}

.thumbnail:hover {
    border-color: var(--color-primary);
}

.thumbnail.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.thumbnail img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 2px;
}

.thumbnail-number {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
}

/* --- Page Viewer --- */

.page-viewer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--color-bg);
    position: relative;
}

.nav-mode-indicator {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.8);
    color: white;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 14px;
    border-radius: 20px;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.15s;
}

.nav-mode-indicator[hidden] {
    display: none;
}

.page-container {
    flex: 1;
    overflow: hidden;  /* OSD handles its own viewport */
    position: relative;
    padding: 0;
}

.page-container[hidden] {
    display: none;
}

.osd-viewer {
    width: 100%;
    height: 100%;
    background: var(--color-bg);
}

/* Ensure page container scrolls when image is zoomed beyond viewport */
.page-container {
    overflow: hidden;
}

.page-nav-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 10px 16px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.page-nav-bar button {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 6px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text);
    transition: background 0.15s;
}

.page-nav-bar button:hover {
    background: var(--color-highlight);
}

.page-nav-bar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#page-counter {
    font-size: 14px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.zoom-controls button {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
}

.zoom-controls button:hover {
    background: var(--color-highlight);
}

#zoom-level {
    min-width: 40px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Ensure page container scrolls when image is zoomed beyond viewport */
.page-container {
    overflow: auto;
}

/* --- Feedback Panel --- */

.feedback-panel {
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 16px;
}

.feedback-panel h2 {
    font-size: 16px;
    margin-bottom: 12px;
}

.controls-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: var(--color-bg);
    border-radius: 6px;
}

.controls-hint p {
    margin: 0;
}

.controls-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 11px;
    font-family: inherit;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    box-shadow: 0 1px 0 var(--color-border);
}

.feedback-panel h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--color-text-muted);
}

.feedback-panel hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 16px 0;
}

.hint {
    font-size: 13px;
    color: var(--color-text-muted);
    font-style: italic;
}

.annotation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.annotation-item {
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--color-bg);
}

.annotation-item .annotation-label {
    font-weight: 600;
    font-size: 12px;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.annotation-item .annotation-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.annotation-item .annotation-label .remove-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
}

.annotation-item .annotation-label .remove-btn:hover {
    color: #EF4444;
}

.annotation-item .annotation-text {
    color: var(--color-text);
}

/* --- Annotation Comment Form --- */

.annotation-comment-form {
    padding: 12px;
    border: 2px solid var(--color-primary);
    border-radius: 8px;
    background: var(--color-highlight);
    margin-top: 8px;
}

.annotation-comment-form[hidden] {
    display: none;
}

.annotation-comment-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-primary-dark);
    margin-bottom: 6px;
}

.annotation-comment-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 8px;
}

.annotation-comment-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.form-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 5px 12px;
    font-size: 13px;
}

/* --- Save Indicator --- */

.save-indicator {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-right: 16px;
    align-self: center;
}

.save-indicator[hidden] {
    display: none;
}

.general-comment-section {
    margin-top: 8px;
}

.general-comment-section textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 8px;
}

.general-comment-section textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-highlight);
}

.general-comments-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.general-comment-item {
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--color-bg);
    position: relative;
}

.general-comment-item .remove-btn {
    position: absolute;
    top: 4px;
    right: 6px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.general-comment-item .remove-btn:hover {
    color: #EF4444;
}

/* --- Buttons --- */

.btn {
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border);
}

.btn-large {
    padding: 12px 32px;
    font-size: 16px;
}

/* --- Submit Section --- */

.submit-section {
    display: flex;
    justify-content: center;
    padding: 12px 20px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

/* --- Modal --- */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal[hidden] {
    display: none;
}

.modal-content {
    background: var(--color-surface);
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.modal-content h2 {
    font-size: 20px;
    margin-bottom: 8px;
}

.modal-content p {
    margin-bottom: 16px;
    color: var(--color-text-muted);
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.modal-content input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-highlight);
}

/* --- Build Version --- */

.build-version {
    font-size: 10px;
    color: var(--color-text-muted);
    opacity: 0.4;
    margin-left: 12px;
}

/* --- Mobile --- */

@media (max-width: 768px) {
    .review-layout {
        grid-template-columns: 1fr;
        height: auto;
    }

    .thumbnail-nav {
        display: none;
    }

    .feedback-panel {
        border-left: none;
        border-top: 1px solid var(--color-border);
    }

    .page-container {
        padding: 0;
        min-height: 60vh;
    }
}
