/* ==========================================================================
   Relevance Engine — Shared Stylesheet
   Extracted from index.html + report.html inline <style> blocks (Phase 14.5).
   ========================================================================== */

/* --- Google Font (loaded via <link> in HTML <head>) --- */

/* --- Base / Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f6f9;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 20px;
}

/* --- Utility --- */
.hidden { display: none; }

/* --- Typography --- */
h1, h2 { color: #1a253c; }

h1 {
    font-size: 2em;
    border-bottom: 2px solid #e0e5eb;
    padding-bottom: 10px;
    margin-top: 0;
}

h2 {
    font-size: 1.5em;
    margin-top: 0;
}

code {
    background-color: #e9ecef;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

pre {
    background-color: #eee;
    padding: 15px;
    border-radius: 6px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* --- Layout --- */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

#login-section, #register-section, #analysis-section {
    max-width: 900px;
    margin: 0 auto;
}

#report-view-section {
    margin-top: 2em;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* --- Card --- */
.card {
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid #e0e5eb;
}

/* --- Forms --- */
label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: #495057;
}

textarea, input[type="text"], input[type="email"], input[type="password"], select {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 1em;
    border-radius: 6px;
    border: 1px solid #ced4da;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.95em;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus, input[type="text"]:focus, input[type="email"]:focus,
input[type="password"]:focus, select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.input-group label {
    margin-right: 1em;
    display: inline-block;
    font-weight: normal;
}
.input-group input[type="radio"] {
    margin-right: 0.3em;
    vertical-align: middle;
}

/* --- Buttons --- */
button {
    background-color: #007bff;
    color: white;
    padding: 12px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-family: inherit;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s;
}
button:hover {
    background-color: #0056b3;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
button:active {
    transform: scale(0.98);
}
button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.back-button {
    background-color: #6c757d;
    margin-bottom: 1em;
}
.back-button:hover { background-color: #5a6268; }

.report-link-button {
    background-color: #28a745;
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    margin-top: 1em;
    font-weight: 500;
    transition: background-color 0.2s;
}
.report-link-button:hover { background-color: #218838; }

.copy-button {
    background-color: #6c757d;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    margin-left: 10px;
    transition: background-color 0.2s;
}
.copy-button:hover { background-color: #5a6268; }

/* --- Status / Result --- */
#result, #login-error, #analysis-error, #register-error, #create-project-error {
    background-color: #fff;
    padding: 1em;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-top: 1em;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.status { font-weight: bold; }
.error { color: #dc3545; font-weight: bold; }

.error-message {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 1em;
    border-radius: 6px;
    margin-top: 1em;
}
.error-message p { font-weight: bold; color: #e74c3c; }
.error-message pre { white-space: pre-wrap; word-wrap: break-word; font-size: 0.9em; }

/* --- Dashboard (project reports table) --- */
#project-dashboard-section { margin-top: 2em; }

.reports-table { width: 100%; border-collapse: collapse; }
.reports-table th, .reports-table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #ddd;
}
.reports-table th { background-color: #f8f9fa; font-weight: 600; }
.reports-table tr:hover { background-color: #f1f3f5; }

.status-SUCCESS { color: #28a745; }
.status-PENDING { color: #fd7e14; }
.status-FAILED  { color: #dc3545; }
.status-pending { color: #f39c12; }
.status-success { color: #2ecc71; }
.status-failed  { color: #e74c3c; }

.view-report-btn {
    background-color: #17a2b8;
    color: white;
    padding: 5px 10px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.2s;
}
.view-report-btn:hover { background-color: #138496; }

/* --- Report Layout (shared between index.html embedded + report.html standalone) --- */
.report-container {
    max-width: 1100px;
    margin: 2em auto;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.report-header {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    padding: 1.5em;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}
.report-header h1 { margin: 0; font-size: 1.8em; border-bottom: none; color: white; }
.report-header p { margin: 5px 0 0; opacity: 0.9; }
.report-header a { color: #fff; text-decoration: underline; }

.report-section {
    padding: 1.5em 2em;
    border-bottom: 1px solid #eee;
}
.report-section:last-child { border-bottom: none; }
.report-section h2 {
    margin-top: 0;
    color: #343a40;
    border-bottom: 2px solid #007bff;
    padding-bottom: 0.3em;
    margin-bottom: 1em;
    font-size: 1.5em;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.report-section h3 {
    color: #495057;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    font-size: 1.2em;
}

/* --- Score Cards --- */
.scores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 1.5em;
}

.score-card {
    background-color: #fff;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 150px;
    cursor: help;
    transition: box-shadow 0.2s, transform 0.15s;
}
.score-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}
.score-card .score-value { font-size: 3.2em; font-weight: 600; line-height: 1.1; }
.score-card .score-title { font-size: 1.1em; font-weight: 500; color: #343a40; margin-top: 8px; margin-bottom: 5px; }
.score-card .score-description { font-size: 0.85em; color: #6c757d; line-height: 1.3; }

.score-high   { color: #28a745; }
.score-medium { color: #fd7e14; }
.score-low    { color: #dc3545; }

/* --- Stats Grid (report.html only, but shared CSS) --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 1.5em;
}
.stats-block {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
}
.stats-block h3 { margin-top: 0; font-size: 1.2em; color: #495057; }
.stats-block ul { list-style-type: none; padding: 0; margin: 0; }
.stats-block li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #dee2e6; }
.stats-block li:last-child { border-bottom: none; }
.stats-block li .label { color: #6c757d; }
.stats-block li .value { font-weight: 600; color: #343a40; }

/* --- Term Grid --- */
.term-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1em;
}

.term-item {
    background-color: #e9ecef;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 0.9em;
    line-height: 1.4;
    transition: background-color 0.15s;
}
.term-item:hover {
    background-color: #dee2e6;
}
.term-item .term { font-weight: 500; color: #343a40; }
.term-item .score { color: #6c757d; margin-left: 5px; font-size: 0.85em; }

/* --- Details Section --- */
.details-section ul { list-style-type: disc; padding-left: 25px; margin-top: 0.5em; }
.details-section li { margin-bottom: 0.6em; }
.details-section code { background-color: #e9ecef; padding: 0.2em 0.4em; border-radius: 3px; font-size: 0.9em; border: 1px solid #ced4da; }

/* --- Markdown Task --- */
.markdown-task pre {
    background-color: #f8f9fa;
    padding: 1em;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    max-height: 600px;
    overflow-y: auto;
    font-size: 0.9em;
}

/* --- Checklist --- */
.checklist ul { list-style-type: disc; padding-left: 20px; }
.checklist li { margin-bottom: 0.6em; }

/* --- Intent Mismatch Banner (Phase 15.4) --- */
.intent-mismatch-banner {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border-left: 4px solid #e65100;
    border-radius: 8px;
    padding: 16px 20px;
    margin-top: 12px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(230, 81, 0, 0.15);
}
.intent-mismatch-banner .banner-icon {
    font-size: 1.5em;
    line-height: 1;
    flex-shrink: 0;
}
.intent-mismatch-banner .banner-content {
    color: #4e342e;
}
.intent-mismatch-banner .banner-content strong {
    display: block;
    font-size: 1.05em;
    margin-bottom: 4px;
    color: #bf360c;
}
.intent-mismatch-banner .banner-content p {
    margin: 0;
    font-size: 0.95em;
    line-height: 1.5;
    opacity: 1;
    color: #4e342e;
}

/* --- PDF Export Button --- */
.pdf-export-button {
    display: inline-block;
    background-color: #28a745;
    color: white;
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.95em;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.2s, box-shadow 0.2s;
}
.pdf-export-button:hover {
    background-color: #218838;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* --- Loading Spinner (CSS-only) --- */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #dee2e6;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

/* --- Print --- */
@media print {
    .pdf-export-button, .copy-button, .back-button { display: none !important; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    body { padding: 10px; }
    .scores-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
    .stats-grid { grid-template-columns: 1fr; }
    .report-section { padding: 1em 1.2em; }
}