/* LabelCheck – Milestone 1 styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f7fa;
    color: #1a1a2e;
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a2e;
    color: #fff;
    padding: 0.6rem 1.5rem;
    height: 48px;
}
.navbar-brand { font-weight: 700; font-size: 1.1rem; color: #fff; text-decoration: none; }
.navbar-links { display: flex; align-items: center; gap: 1rem; }
.navbar-links a { color: #ccc; text-decoration: none; font-size: 0.85rem; }
.navbar-links a:hover { color: #fff; }
.navbar-user { color: #8888aa; font-size: 0.85rem; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #4f46e5;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.btn-icon:hover { background: #4f46e5; color: #fff; }

/* Flash */
.flash { padding: 0.75rem 1rem; border-radius: 6px; font-size: 0.9rem; margin-bottom: 0.5rem; }
.flash-error { background: #fde8e8; color: #991b1b; }
.flash-success { background: #d1fae5; color: #065f46; }

/* Form controls */
.form-control {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
}
.form-control:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }
.text-muted { color: #9ca3af; font-size: 0.85rem; }

/* Auth page */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 48px);
}
.auth-card {
    max-width: 400px;
    width: 100%;
    background: #fff;
    border-radius: 10px;
    padding: 2.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.auth-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 0.25rem; }
.auth-subtitle { text-align: center; color: #6b7280; font-size: 0.9rem; margin-bottom: 1.5rem; }
.auth-card label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.auth-card input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}
.auth-card input:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }
.auth-card .btn-primary { width: 100%; margin-top: 0.5rem; }
.auth-links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: 0.85rem; }
.auth-links a { color: #4f46e5; text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-divider { text-align: center; margin: 1.25rem 0; color: #d1d5db; font-size: 0.8rem; position: relative; }
.auth-divider span { background: #fff; padding: 0 0.75rem; position: relative; z-index: 1; }
.auth-divider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid #e5e7eb; }
.btn-guest {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.55rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-guest:hover { background: #f9fafb; }

/* Guest sidebar */
.guest-sidebar {
    padding: 2rem 1.25rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.85rem;
}
.guest-sidebar p { margin-bottom: 1rem; }
.btn-small { font-size: 0.8rem; padding: 0.4rem 1rem; }

/* Legacy email card (remove later) */
.email-card {
    max-width: 400px;
    margin: 8rem auto;
    background: #fff;
    border-radius: 10px;
    padding: 2.5rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    text-align: center;
}
.email-card h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.email-card p { color: #6b7280; margin-bottom: 1.5rem; font-size: 0.9rem; }
.email-card label { display: block; text-align: left; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; }
.email-card input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}
.email-card input:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }
.email-card .btn-primary { width: 100%; }

/* Workspace layout */
.workspace {
    display: flex;
    height: calc(100vh - 48px);
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.sidebar-header h2 { font-size: 1rem; font-weight: 700; }

.new-label-row {
    padding: 0.7rem 1.25rem;
    cursor: pointer;
    color: #4f46e5;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid #e5e7eb;
    transition: background 0.1s;
}
.new-label-row:hover { background: #f5f3ff; }

.label-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}
.label-item {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.1s;
}
.label-item:hover { background: #f9fafb; }
.label-item.active { background: #eef2ff; border-left: 3px solid #4f46e5; }
.label-item { position: relative; }
.label-item-info { }
.label-item-name { font-size: 0.9rem; font-weight: 500; padding-right: 1.5rem; }
.label-delete {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    color: #d1d5db;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
    opacity: 0;
}
.label-item:hover .label-delete { opacity: 1; }
.label-delete:hover { color: #dc2626; }
.label-item-date { font-size: 0.75rem; color: #9ca3af; margin-top: 0.15rem; }
.empty-sidebar { padding: 2rem 1.25rem; color: #9ca3af; font-size: 0.85rem; text-align: center; }
.loading { padding: 2rem; text-align: center; color: #9ca3af; }

/* Main panel */
.main-panel {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.main-panel.showing-result {
    align-items: stretch;
    justify-content: stretch;
}
.main-panel.showing-result #result-state {
    width: 100%;
}

/* Upload area */
.upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 4rem 3rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    max-width: 500px;
    width: 100%;
}
.upload-area:hover, .upload-area.drag-over {
    border-color: #4f46e5;
    background: #f5f3ff;
}
.upload-icon {
    font-size: 3rem;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    line-height: 1;
}
.upload-area p { color: #6b7280; font-size: 0.9rem; margin: 0.25rem 0; }
.upload-area a { color: #4f46e5; text-decoration: none; font-weight: 600; }

/* Processing spinner */
.processing {
    text-align: center;
    color: #6b7280;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-steps {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    justify-content: center;
}
.progress-step {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.75rem;
    border-radius: 12px;
    background: #f3f4f6;
    color: #9ca3af;
    transition: all 0.2s;
}
.progress-step.active {
    background: #4f46e5;
    color: #fff;
}
.progress-step.done {
    background: #d1fae5;
    color: #065f46;
}

/* Result layout — vertical: preview on top, text on bottom */
.result-layout {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    width: 100%;
}

#result-state {
    display: flex;
    width: 100%;
    flex: 1;
}
.preview-panel, .text-panel {
    background: #fff;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.preview-panel {
    min-width: 0;
    flex-shrink: 0;
}
.preview-container { overflow: hidden; }
.preview-container img { width: 100%; height: auto; display: block; }
.preview-container iframe { width: 100%; aspect-ratio: 8.5 / 11; display: block; }
.text-panel {
    flex: none;
}
.preview-panel h3, .text-panel h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}

/* Preview */
.preview-img { border-radius: 4px; }
.preview-iframe { border: none; border-radius: 4px; }

/* OCR textarea */
.ocr-textarea {
    flex: 1;
    width: 100%;
    min-height: 0;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-family: "SF Mono", Monaco, "Cascadia Code", monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    resize: none;
    color: #1a1a2e;
}
.ocr-textarea:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 2px rgba(79,70,229,0.15); }
.ocr-textarea[readonly] { background: #f9fafb; color: #374151; }

/* Result top bar */
.result-topbar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-shrink: 0;
}
.topbar-name {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0.75rem;
    flex-shrink: 0;
}
.tab {
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.tab:hover { color: #374151; }
.tab.active { color: #4f46e5; border-bottom-color: #4f46e5; }

.tab-content { flex: 1; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; }
.tab-content[style*="display: none"] { display: none !important; }

/* Structured fields */
.structured-fields { font-size: 0.85rem; padding: 0 20px; }
.sf-row {
    display: flex;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f3f4f6;
    gap: 1rem;
}
.sf-row:last-child { border-bottom: none; }
.sf-label {
    min-width: 160px;
    font-weight: 600;
    color: #6b7280;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.sf-input {
    flex: 1;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.25rem 0.4rem;
    font-size: 0.85rem;
    font-family: inherit;
    color: #1a1a2e;
    background: transparent;
    transition: border-color 0.15s, background 0.15s;
}
.sf-input:hover { background: #f9fafb; border-color: #e5e7eb; }
.sf-input:focus { outline: none; border-color: #4f46e5; background: #fff; box-shadow: 0 0 0 2px rgba(79,70,229,0.1); }
.sf-input::placeholder { color: #d1d5db; font-style: italic; }
.sf-textarea { resize: vertical; min-height: 2.5rem; font-family: inherit; }
.sf-table-input { width: 100%; padding: 0.2rem 0.3rem; font-size: 0.82rem; }
.claim-input { flex: 1; }

.sf-section {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}
.sf-section h4 {
    font-size: 0.8rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.sf-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.82rem;
}
.sf-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    background: #f9fafb;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    border-bottom: 1px solid #e5e7eb;
}
.sf-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.claim-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.claim-text { flex: 1; }
.claim-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: #ede9fe;
    color: #5b21b6;
    white-space: nowrap;
}

/* Findings */
.findings-list { padding: 0 20px; }
.findings-empty { padding: 2rem; text-align: center; color: #9ca3af; }
.finding-card {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border-left: 3px solid #e5e7eb;
}
.finding-card.sev-critical { border-left-color: #dc2626; }
.finding-card.sev-major { border-left-color: #ea580c; }
.finding-card.sev-minor { border-left-color: #ca8a04; }
.finding-card.finding-resolved { opacity: 0.5; }
.finding-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}
.sev-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
    text-transform: uppercase;
}
.sev-badge.sev-critical { background: #fee2e2; color: #dc2626; }
.sev-badge.sev-major { background: #ffedd5; color: #ea580c; }
.sev-badge.sev-minor { background: #fef9c3; color: #a16207; }
.finding-code { font-size: 0.75rem; color: #6b7280; font-family: monospace; }
.finding-actions { margin-left: auto; display: flex; gap: 0.3rem; }
.finding-status-label { margin-left: auto; font-size: 0.75rem; color: #9ca3af; font-style: italic; }
.fbtn {
    border: none;
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
}
.fbtn-resolve { background: #d1fae5; color: #065f46; }
.fbtn-resolve:hover { background: #a7f3d0; }
.fbtn-dismiss { background: #f3f4f6; color: #6b7280; }
.fbtn-dismiss:hover { background: #e5e7eb; }
.fbtn-reopen { background: #dbeafe; color: #1d4ed8; }
.fbtn-reopen:hover { background: #bfdbfe; }
.finding-title { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.2rem; }
.finding-desc { font-size: 0.8rem; color: #4b5563; }
.finding-fix {
    font-size: 0.8rem;
    color: #065f46;
    background: #ecfdf5;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    margin-top: 0.4rem;
}
.findings-count-badge {
    background: #dc2626;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 8px;
    margin-left: 0.3rem;
}

/* Save row */
#save-controls { flex-shrink: 0; }
.save-row {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    align-items: center;
}
.save-row .form-control { flex: 1; }
.save-row .btn-primary { width: auto; white-space: nowrap; }

/* Responsive */
@media (max-width: 800px) {
    .workspace { flex-direction: column; }
    .sidebar { width: 100%; min-width: 100%; max-height: 200px; border-right: none; border-bottom: 1px solid #e5e7eb; }
}
