/* Synkti Pro - Patent Drafting Platform */
/* Dark Orange Theme */

:root {
    --primary: #f97316;
    --primary-dark: #ea580c;
    --primary-light: #fb923c;
    --secondary: #78716c;
    --success: #22c55e;
    --warning: #fbbf24;
    --error: #ef4444;
    --bg: #1c1917;
    --bg-elevated: #292524;
    --surface: #292524;
    --surface-hover: #3f3a36;
    --text: #fafaf9;
    --text-muted: #a8a29e;
    --border: #44403c;
    --border-light: #57534e;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --glow: 0 0 20px rgba(249, 115, 22, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Header */
.header {
    background: linear-gradient(to right, var(--bg-elevated), #1f1a17);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.session-info {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Main Layout */
.main-container {
    display: flex;
    height: calc(100vh - 50px);
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    font-size: 0.7rem;
    color: var(--primary);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.stages-list {
    flex: 1;
}

.stage-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.stage-item:hover {
    background: var(--surface-hover);
    border-color: var(--border-light);
}

.stage-item.active {
    background: rgba(249, 115, 22, 0.12);
    border-color: var(--primary);
    border-left: 3px solid var(--primary);
    box-shadow: 0 2px 8px rgba(249, 115, 22, 0.15);
}

.stage-item.completed {
    background: rgba(34, 197, 94, 0.1);
    border-color: var(--success);
}

.stage-item.waiting {
    background: rgba(251, 191, 36, 0.1);
    border-color: var(--warning);
}

.stage-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.75rem;
    background: var(--secondary);
    flex-shrink: 0;
}

.stage-item.active .stage-indicator {
    background: var(--primary);
    box-shadow: 0 0 12px var(--primary);
    animation: pulse 1.5s infinite;
}

.stage-item.completed .stage-indicator {
    background: var(--success);
}

.stage-item.waiting .stage-indicator {
    background: var(--warning);
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 12px var(--primary); }
    50% { opacity: 0.7; box-shadow: 0 0 20px var(--primary); }
}

.stage-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.usage-info {
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.refresh-btn {
    width: 100%;
    margin-top: 1rem;
    padding: 0.6rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Main Content */
.content {
    flex: 1;
    padding: 1.5rem 2rem;
    background: var(--bg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Upload Section */
.upload-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.upload-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.demo-notice {
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 0.5rem;
}

.demo-disclaimer {
    font-size: 0.825rem;
    color: var(--text);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    font-weight: 500;
}

.demo-cta {
    font-size: 0.825rem;
    color: var(--text);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.demo-cta .cta-link {
    color: #6366f1;
    text-decoration: none;
    font-weight: 600;
    border-bottom: 1px solid rgba(99, 102, 241, 0.4);
    transition: all 0.2s;
}

.demo-cta .cta-link:hover {
    border-bottom-color: #6366f1;
    color: #4f46e5;
}

.privacy-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    line-height: 1.4;
}

.privacy-note::before {
    content: '🔒';
    font-size: 0.75rem;
}

.upload-area {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.upload-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.upload-area p {
    margin: 0.75rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.upload-area textarea {
    width: 100%;
    flex: 1;
    min-height: 180px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    background: var(--bg);
    color: var(--text);
    transition: border-color 0.2s;
}

.upload-area textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.upload-area textarea::placeholder {
    color: var(--text-muted);
}

.sample-disclosures {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.sample-disclosures label {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.sample-disclosures select {
    flex: 1;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text);
    font-size: 0.85rem;
    cursor: pointer;
}

.sample-disclosures select:hover {
    border-color: var(--primary);
}

.sample-disclosures select:focus {
    outline: none;
    border-color: var(--primary);
}

.submit-btn {
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

.submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.25);
}

.workflow-tagline {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

.document-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-between;
    color: var(--success);
    font-size: 0.85rem;
}

/* Pipeline Controls - Always visible */
.pipeline-controls {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--surface);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

/* Control buttons */
.control-buttons {
    display: flex;
    gap: 1rem;
}

.analyze-btn {
    flex: 1;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.analyze-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.4);
}

/* Analyze button disabled - greyed out like demo */
.analyze-btn:disabled {
    background: #3a3633;
    color: #6b6560;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.start-btn {
    flex: 1;
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.start-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

/* Generate Draft button disabled - very visible grey */
.start-btn:disabled {
    background: #3a3633;
    color: #6b6560;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.status.ready {
    color: var(--success);
    font-weight: 500;
}

.status.not-ready {
    color: var(--warning);
    font-weight: 500;
}

.status.running {
    color: var(--primary);
    font-weight: 500;
}

.status.ai-unavailable {
    color: var(--error);
    font-weight: 500;
}

/* Disclosure Analysis Section */
.disclosure-analysis {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--surface);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.disclosure-analysis h2 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text);
}

.analysis-summary {
    margin-bottom: 1rem;
}

.analysis-summary p {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.ready-indicator {
    display: inline-block;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.ready-indicator.ready {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
}

.ready-indicator.not-ready {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.ready-indicator.ai-unavailable {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid var(--error);
}

.analysis-details {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.analysis-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.75rem;
    background: var(--bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.analysis-item strong {
    font-size: 0.7rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.analysis-item span {
    color: var(--text);
    font-size: 0.9rem;
}

/* Depth indicator */
.depth-score {
    font-weight: 600;
    margin-right: 0.5rem;
    color: var(--primary);
}

.depth-bar {
    display: inline-block;
    width: 100px;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    vertical-align: middle;
}

.depth-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--primary-light));
    transition: width 0.3s;
}

/* Missing elements and clarification */
.missing-elements,
.clarification-needed {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

.missing-elements {
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid var(--warning);
    border-left: 3px solid var(--warning);
}

.clarification-needed {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid var(--primary);
    border-left: 3px solid var(--primary);
}

.missing-elements strong,
.clarification-needed strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.missing-elements ul,
.clarification-needed ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-muted);
}

.missing-elements li,
.clarification-needed li {
    margin-bottom: 0.25rem;
}

/* Output Section */
.output-section {
    margin-top: 1.25rem;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.output-header h2 {
    color: var(--text);
    font-size: 1.1rem;
}

.output-controls {
    display: flex;
    gap: 0.5rem;
}

.output-controls select {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 0.85rem;
}

.output-controls button {
    padding: 0.5rem 1rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.output-controls button:hover {
    background: var(--primary-dark);
}

.output-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    min-height: 300px;
    white-space: pre-wrap;
    font-family: 'Georgia', serif;
    line-height: 1.8;
    color: var(--text);
    font-size: 0.95rem;
}

/* Analysis Section (post-draft) */
.analysis-section {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: var(--surface);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.analysis-section h2 {
    color: var(--text);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.confidence-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.confidence-indicator span {
    color: var(--text-muted);
}

.confidence-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--success));
    transition: width 0.3s;
}

.issues-list {
    margin-top: 1rem;
}

.issue-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.9rem;
}

.issue-item.critical {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid var(--error);
    color: var(--text);
}

.issue-item.warning {
    background: rgba(251, 191, 36, 0.1);
    border-left: 3px solid var(--warning);
    color: var(--text);
}

.issue-item.info {
    background: rgba(249, 115, 22, 0.1);
    border-left: 3px solid var(--primary);
    color: var(--text);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal.wide {
    max-width: 800px;
}

.modal h2 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.question-text {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    color: var(--text);
}

.question-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.question-option {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    background: var(--bg);
}

.question-option:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.question-option.selected {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--primary);
}

.modal textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-family: inherit;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
}

.modal textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.prompt-editor {
    min-height: 400px;
    font-family: monospace;
    font-size: 0.875rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.cancel-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.cancel-btn:hover {
    background: var(--surface-hover);
    color: var(--text);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Responsive */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .stages-list {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .stage-item {
        flex-shrink: 0;
    }

    .control-buttons {
        flex-direction: column;
    }

    .content {
        padding: 1rem;
    }
}
