/* FinePrint — AI Contract Scanner */
:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #232736;
    --border: #2e3347;
    --text: #e8eaf0;
    --text-dim: #8b90a5;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --green: #10b981;
    --yellow: #f59e0b;
    --red: #ef4444;
    --orange: #f97316;
    --radius: 12px;
    --radius-sm: 8px;
}

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

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

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 60px;
}

.view { display: none; }
.view.active { display: block; }

/* Header / Hero */
.hero {
    text-align: center;
    padding: 40px 0 20px;
}

.logo, .logo-sm {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.logo-icon { font-size: 32px; }
.logo-text { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.logo-sm .logo-icon { font-size: 20px; }
.logo-sm .logo-text { font-size: 18px; font-weight: 700; }

.tagline {
    color: var(--text-dim);
    font-size: 16px;
    margin-top: 8px;
}

/* Upload Area */
.upload-area {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    margin: 24px 0;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-area h2 { font-size: 20px; margin-bottom: 4px; }
.upload-area p { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }

/* Buttons */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-full { width: 100%; padding: 14px; font-size: 16px; }
.btn-ghost { background: none; color: var(--text-dim); padding: 8px 0; }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* Paste Area */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
    color: var(--text-dim);
    font-size: 13px;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

textarea {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
    margin-bottom: 12px;
}

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

/* Demo Contracts */
.demo-contracts { text-align: center; margin-top: 32px; }
.demo-label { color: var(--text-dim); font-size: 13px; margin-bottom: 10px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.chip {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover { border-color: var(--primary); background: rgba(99, 102, 241, 0.1); }

/* Analyzing View */
.analyzing-container {
    text-align: center;
    padding: 60px 20px;
}

.analyzing-icon { font-size: 48px; margin-bottom: 16px; animation: pulse 1.5s infinite; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.progress-bar {
    background: var(--surface);
    border-radius: 6px;
    height: 6px;
    margin: 20px auto;
    max-width: 400px;
    overflow: hidden;
}

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

.analyzing-steps {
    margin-top: 24px;
    text-align: left;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.step {
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-dim);
    transition: color 0.3s;
}

.step.done { color: var(--green); }
.step.active { color: var(--text); }
.step-icon { margin-right: 6px; }

/* Results Header */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* Scorecard */
.scorecard {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.score-main {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
}

.grade-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 3px solid;
}

.grade-circle.grade-a { border-color: var(--green); background: rgba(16, 185, 129, 0.1); }
.grade-circle.grade-b { border-color: var(--yellow); background: rgba(245, 158, 11, 0.1); }
.grade-circle.grade-c { border-color: var(--orange); background: rgba(249, 115, 22, 0.1); }
.grade-circle.grade-d, .grade-circle.grade-f { border-color: var(--red); background: rgba(239, 68, 68, 0.1); }

.grade {
    font-size: 32px;
    font-weight: 800;
}

.score-info h2 { font-size: 18px; margin-bottom: 4px; }
.score-summary { color: var(--text-dim); font-size: 14px; }

.score-categories { display: flex; flex-direction: column; gap: 10px; }

.category {
    display: grid;
    grid-template-columns: 120px 1fr 60px;
    align-items: center;
    gap: 10px;
}

.cat-label { font-size: 13px; color: var(--text-dim); }
.cat-bar { background: var(--bg); border-radius: 4px; height: 8px; overflow: hidden; }

.cat-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}

.cat-fill[data-level="low"] { background: var(--green); }
.cat-fill[data-level="medium"] { background: var(--yellow); }
.cat-fill[data-level="high"] { background: var(--red); }

.cat-value { font-size: 12px; font-weight: 600; text-align: right; }

/* Sections */
.section {
    margin-bottom: 28px;
}

.section h3 {
    font-size: 16px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.badge-red { background: rgba(239, 68, 68, 0.2); color: var(--red); }

/* Summary Card */
.summary-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 16px;
}

.summary-card p {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
}

.summary-card p + p { margin-top: 10px; }

/* Flags */
.flags-list { display: flex; flex-direction: column; gap: 10px; }

.flag-card {
    background: var(--surface);
    border-left: 3px solid var(--red);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}

.flag-card .flag-title {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 4px;
}

.flag-card .flag-clause {
    font-size: 12px;
    color: var(--text-dim);
    font-style: italic;
    margin-bottom: 6px;
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
}

.flag-card .flag-explain {
    font-size: 13px;
    color: var(--text);
}

.flag-card .flag-benchmark {
    font-size: 12px;
    color: var(--yellow);
    margin-top: 6px;
}

/* Clause Filters */
.clause-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    overflow-x: auto;
}

.filter {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.filter.active { border-color: var(--primary); color: var(--primary); background: rgba(99, 102, 241, 0.1); }
.filter:hover { border-color: var(--primary); }

/* Clause Cards */
.clauses-list { display: flex; flex-direction: column; gap: 8px; }

.clause-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border-left: 3px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.clause-card[data-severity="red"] { border-left-color: var(--red); }
.clause-card[data-severity="watch"] { border-left-color: var(--yellow); }
.clause-card[data-severity="ok"] { border-left-color: var(--green); }

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

.clause-title { font-weight: 600; font-size: 14px; }
.clause-severity { font-size: 12px; }

.clause-plain { font-size: 13px; color: var(--text); line-height: 1.5; }

.clause-detail {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.clause-detail.open { display: block; }

.clause-original {
    font-size: 12px;
    color: var(--text-dim);
    font-style: italic;
    padding: 8px;
    background: var(--bg);
    border-radius: 4px;
    margin-bottom: 6px;
}

.clause-benchmark { font-size: 12px; color: var(--yellow); }

/* Tips */
.tips-list { display: flex; flex-direction: column; gap: 10px; }

.tip-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border-left: 3px solid var(--primary);
}

.tip-card .tip-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.tip-card .tip-text { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }

.tip-card .tip-suggestion {
    font-size: 12px;
    background: rgba(99, 102, 241, 0.1);
    padding: 8px;
    border-radius: 4px;
    color: var(--primary-hover);
    font-style: italic;
}

/* Chat */
.chat-area {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.chat-msg {
    margin-bottom: 12px;
}

.chat-msg.bot p {
    background: var(--surface-2);
    padding: 10px 14px;
    border-radius: 12px 12px 12px 4px;
    font-size: 13px;
    display: inline-block;
    max-width: 90%;
}

.chat-msg.user {
    text-align: right;
}

.chat-msg.user p {
    background: var(--primary);
    padding: 10px 14px;
    border-radius: 12px 12px 4px 12px;
    font-size: 13px;
    display: inline-block;
    max-width: 90%;
}

.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.chat-input-area input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text);
    font-size: 13px;
}

.chat-input-area input:focus { outline: none; border-color: var(--primary); }

/* Responsive */
@media (max-width: 480px) {
    .score-main { flex-direction: column; text-align: center; }
    .category { grid-template-columns: 100px 1fr 50px; }
    .grade-circle { width: 64px; height: 64px; }
    .grade { font-size: 26px; }
}
