/* LegalLens Contract Reviewer - Professional Legal UI */

* {
    box-sizing: border-box;
}

:root {
    /* Professional Legal Color Palette */
    --primary: #1e3a5f;          /* Navy Blue - trust & authority */
    --primary-light: #2c5282;
    --primary-dark: #1a365d;
    --accent: #2d6a4f;           /* Forest Green - success */
    --accent-light: #38a169;
    --warning: #b45309;          /* Amber - attention */
    --warning-light: #d69e2e;
    --danger: #991b1b;           /* Deep Red - high risk */
    --danger-light: #c53030;

    /* Neutral Colors */
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border: #e2e8f0;
    --border-light: #edf2f7;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-tertiary: #edf2f7;
}

body {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* Header - Clean Professional */
.header-section {
    background: var(--primary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    border-bottom: 3px solid var(--accent);
}

.header-section .logo {
    width: 24px;
    height: 24px;
}

.header-section h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
    letter-spacing: -0.01em;
}

/* Authentication */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    padding: 20px;
}

.auth-content {
    text-align: center;
    max-width: 300px;
}

.auth-content h2 {
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
}

.auth-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 14px;
}

.auth-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 16px;
    line-height: 1.5;
}

/* User Info Bar */
.user-info-bar {
    background: var(--bg-primary);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

#user-email {
    color: var(--text-secondary);
    font-weight: 500;
}

/* Content Section */
.content-section {
    padding: 20px 16px;
}

.process-container {
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 24px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border);
    margin-bottom: 16px;
}

.process-container h2 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
}

.description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
}

/* Buttons - Professional Style */
.primary-button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.primary-button:hover:not(:disabled) {
    background: var(--primary-light);
}

.primary-button:active:not(:disabled) {
    background: var(--primary-dark);
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-button.large {
    padding: 14px 28px;
    font-size: 15px;
}

/* Button icon - use proper icon font or SVG */
.button-icon {
    font-size: 16px;
    line-height: 1;
}

/* Icon styles for Fluent UI icons */
.icon-review::before { content: "\E8A1"; }
.icon-upload::before { content: "\E898"; }

.secondary-button {
    background: var(--bg-primary);
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.secondary-button:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.text-button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.text-button:hover {
    background: var(--bg-tertiary);
}

/* Cancel/Stop Button */
.stop-button {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    margin-top: 16px;
    transition: all 0.15s ease;
}

.stop-button:hover {
    background: #fef2f2;
}

/* Status Monitor - Clean Professional */
.status-monitor {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.status-monitor h4 {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
}

/* Progress Section - Simplified */
.progress-section {
    margin-bottom: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-indicator.completed {
    background: var(--accent);
    animation: none;
}

.status-indicator.error {
    background: var(--danger);
    animation: none;
}

.progress-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-count {
    font-size: 13px;
    color: var(--text-muted);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-fill.completed {
    background: var(--accent);
}

/* Live Stats */
.live-stats {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
}

.stat-icon.highlighted {
    background: #fef3c7;
    color: var(--warning);
}

.stat-icon.attention {
    background: #fee2e2;
    color: var(--danger);
}

.stat-icon.success {
    background: #d1fae5;
    color: var(--accent);
}

/* Completion Summary */
.completion-summary {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--accent);
}

.completion-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.completion-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.completion-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.completion-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* Risk Summary Grid */
.risk-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.risk-item {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 6px;
    text-align: center;
}

.risk-count {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
}

.risk-count.high { color: var(--danger); }
.risk-count.medium { color: var(--warning); }
.risk-count.low { color: var(--accent); }

.risk-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Cancelled Status */
.cancelled-message {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
}

.cancelled-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Status Error */
.status-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 12px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid #fecaca;
}

.error-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

/* Hidden state for process button during processing */
.process-button-hidden {
    display: none !important;
}

/* New Analysis Button (shown after completion) */
.new-analysis-button {
    margin-top: 16px;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.tab-button {
    flex: 1;
    padding: 14px 16px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab-button:hover {
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-primary);
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Info Box */
.info-box {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #1e40af;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-box .info-icon {
    flex-shrink: 0;
}

/* Playbook Badge */
.playbook-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.playbook-badge strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Upload Section */
.upload-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.upload-section h3 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.file-input-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.file-name {
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status Box for Playbook Upload */
.status-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}

.status-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

.progress-bar-container {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-container .progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Playbook List Section */
.playbook-list-section {
    margin-top: 20px;
}

.playbook-list-section h3 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: inline-block;
}

.playbook-list-section .text-button {
    float: right;
}

.playbook-list {
    margin-top: 12px;
}

.playbook-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s ease;
}

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

.playbook-item.is-default {
    border-color: var(--primary);
    background: #eff6ff;
}

.playbook-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.playbook-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.playbook-status {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-block;
    width: fit-content;
    font-weight: 500;
}

.playbook-status.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.playbook-status.status-processing,
.playbook-status.status-queued {
    background: #dbeafe;
    color: #1e40af;
}

.playbook-status.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.playbook-status.status-pending_upload {
    background: #fef3c7;
    color: #92400e;
}

.default-badge {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.set-default-btn {
    font-size: 12px;
}

.no-playbooks {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px dashed var(--border);
}

/* Form Controls */
.playbook-selector {
    margin-bottom: 16px;
}

.playbook-selector label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

/* Auth Form */
.auth-form {
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.15s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.error-message {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

/* Help Section - Collapsible */
.help-section {
    margin-top: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.help-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--bg-secondary);
    border: none;
    width: 100%;
    text-align: left;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.help-toggle:hover {
    background: var(--bg-tertiary);
}

.help-content {
    padding: 16px;
    display: none;
}

.help-content.expanded {
    display: block;
}

.help-section h3 {
    margin: 0 0 12px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.help-section ol {
    margin: 0 0 16px 0;
    padding-left: 20px;
    color: var(--text-secondary);
    font-size: 13px;
}

.help-section li {
    margin-bottom: 6px;
}

/* Legend */
.legend {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.legend h4 {
    margin: 0 0 10px 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.color-box {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    gap: 16px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Results Actions */
#results-actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
}

#results-actions button {
    flex: 1;
}

/* File input */
.file-input-hidden {
    position: absolute;
    left: -9999px;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.file-input-label {
    display: inline-block;
    cursor: pointer;
}

.file-input-label:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

/* Cancel Confirmation Dialog */
.cancel-confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.cancel-confirmation-dialog {
    background: white;
    border-radius: 12px;
    padding: 28px;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.cancel-warning-icon {
    width: 48px;
    height: 48px;
    background: #fef2f2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    font-size: 24px;
}

.cancel-confirmation-dialog h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.cancel-warning-text {
    color: var(--danger);
    font-size: 14px;
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.cancel-info-text {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 24px 0;
    line-height: 1.5;
}

.cancel-confirmation-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.cancel-confirm-btn {
    padding: 10px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}

.cancel-confirm-btn.cancel-yes {
    background: var(--danger);
    color: white;
}

.cancel-confirm-btn.cancel-yes:hover {
    background: var(--danger-light);
}

.cancel-confirm-btn.cancel-no {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.cancel-confirm-btn.cancel-no:hover {
    background: var(--border);
}

/* Highlight Progress */
.highlight-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.highlight-icon {
    color: var(--warning);
}

/* Responsive adjustments */
@media (max-height: 600px) {
    .help-section {
        display: none;
    }
}

/* Processing state - hide button */
body.processing-active #process-button {
    display: none;
}

/* No Playbook Warning */
.no-playbook-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 6px;
    padding: 14px 16px;
    margin-bottom: 20px;
}

.no-playbook-warning .warning-icon {
    width: 24px;
    height: 24px;
    background: #f59e0b;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.no-playbook-warning .warning-content {
    flex: 1;
}

.no-playbook-warning .warning-content strong {
    display: block;
    color: #92400e;
    font-size: 14px;
    margin-bottom: 4px;
}

.no-playbook-warning .warning-content p {
    margin: 0;
    color: #a16207;
    font-size: 13px;
    line-height: 1.4;
}
