/* ============================================================================
   Scoring Test Tool - Main Stylesheet
   ============================================================================ */

/* Reset and Base Styles */
* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding: 20px;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
}

h1 {
    color: #333;
    margin-bottom: 30px;
    padding-bottom: 10px;
    border-bottom: 3px solid #007bff;
}

h2 {
    color: #333;
    margin-bottom: 20px;
}

h3 {
    color: #555;
    margin-bottom: 10px;
    font-size: 16px;
}

/* Cards and Layout */
.card {
    background: white;
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Forms */
.form-group { 
    margin-bottom: 15px; 
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    align-items: flex-end;
}

.form-row .form-group {
    margin-bottom: 0;
}

.form-row .form-group:first-child {
    flex: 1;
    max-width: 400px;
}

.form-row .form-group:last-child {
    flex: 0 0 auto;
}

.form-row input[type="number"] {
    width: 100px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

input[type="text"], 
input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

input[type="checkbox"] {
    margin-right: 5px;
}

/* Buttons */
button {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

button:hover { 
    background: #0056b3; 
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.view-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.view-btn:hover { 
    background: #218838; 
}

/* Status Badges */
.status { 
    padding: 5px 10px; 
    border-radius: 3px; 
    font-size: 12px; 
    font-weight: 600; 
}

.status.completed { 
    background: #d4edda; 
    color: #155724; 
}

.status.in-progress { 
    background: #fff3cd; 
    color: #856404; 
}

.status.failed { 
    background: #f8d7da; 
    color: #721c24; 
}

/* Tables */
.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    background: #f8f9fa;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
}

.history-table td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
}

.history-table tr:hover {
    background: #f8f9fa;
}

/* Pagination */
#paginationControls button {
    transition: background-color 0.2s;
}

#paginationControls button:hover:not(:disabled) {
    background-color: #0056b3 !important;
}

#paginationControls button:disabled {
    background-color: #ccc !important;
    cursor: not-allowed;
    opacity: 0.6;
}

#pageSizeSelect:hover {
    border-color: #007bff;
}

.page-link:hover {
    background-color: #f0f0f0 !important;
}

.page-link.current-page {
    cursor: default !important;
}

.page-link.current-page:hover {
    background-color: #007bff !important;
}

/* Alerts */
#status { 
    margin-top: 20px; 
}

.alert {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-left: 4px solid #ffc107;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Branding */
.brand-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 20px 30px;
    margin: -20px -20px 30px -20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.brand-header h1 {
    color: white;
    margin: 0;
    border: none;
    padding: 0;
    font-size: 24px;
    font-weight: 600;
}

.brand-logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.brand-footer {
    text-align: center;
    padding: 20px;
    margin-top: 40px;
    color: #666;
    font-size: 14px;
    border-top: 1px solid #ddd;
}

/* Links */
.back-link {
    display: inline-block;
    margin-bottom: 20px;
    color: #007bff;
    text-decoration: none;
}

.back-link:hover { 
    text-decoration: underline; 
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.info-item label {
    display: block;
    color: #666;
    font-size: 12px;
    margin-bottom: 3px;
}

.info-item value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Timeline */
.timeline {
    list-style: none;
    padding: 0;
}

.timeline li {
    padding: 10px 15px;
    border-left: 3px solid #007bff;
    margin-bottom: 10px;
    background: #f8f9fa;
}

.timeline li.success { 
    border-color: #28a745; 
}

.timeline li.warning { 
    border-color: #ffc107; 
}

.timeline li.error { 
    border-color: #dc3545; 
}

.timestamp {
    font-family: 'Courier New', monospace;
    color: #666;
    margin-right: 10px;
}

/* Analysis */
.analysis {
    list-style: none;
    padding: 0;
}

.analysis li {
    padding: 10px 15px;
    border-left: 3px solid #17a2b8;
    margin-bottom: 10px;
    background: #f8f9fa;
}

.analysis li strong {
    font-size: 14px;
    margin-bottom: 5px;
}

.analysis li div {
    font-size: 13px;
    color: #555;
}

.loading {
    text-align: center;
    padding: 50px;
    color: #666;
}

/* ============================================================================
   Threat Intelligence Components
   ============================================================================ */

.threat-detail-card {
    margin-top: 12px;
    padding: 12px;
    background: #fff;
    border-radius: 6px;
    border-left: 4px solid #dc3545;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.threat-detail-title {
    color: #dc3545;
    font-size: 13px;
    font-weight: 600;
}

.badge-count {
    background: #525151;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.threat-lists-grid {
    display: grid;
    /* Use auto-fill with fixed min width for even spacing, or set fixed columns */
    /* Option 1: Auto-fill with even spacing (cards will be equal width) */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    /* Option 2: Fixed 3 columns per row (uncomment to use instead) */
    /* grid-template-columns: repeat(3, 1fr); */
    gap: 15px;
    justify-items: stretch; /* Ensure all cards stretch to fill their grid cell */
    justify-content: center; /* Center the grid items when there are fewer cards than columns */
}

.threat-list-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #6c757d;
    /* Remove max-width to allow cards to grow evenly with grid */
    width: 100%;
    box-sizing: border-box;
}

.threat-list-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.threat-list-name {
    font-size: 13px;
    color: #212529;
    font-weight: 600;
}

.threat-list-category {
    color: #6c757d;
    font-size: 11px;
    margin-left: 6px;
}

.score-badge {
    background: #dc3545;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
}

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

.threat-list-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 6px;
    font-size: 11px;
    color: #555;
    margin-bottom: 8px;
}

/* Calculation sections for detailed formulas */
.calculation-section {
    margin-top: 10px;
    padding: 8px;
    background: #f0f4f8;
    border-radius: 4px;
    border-left: 2px solid #4a90e2;
}

.calculation-title {
    font-size: 10px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.calculation-formula {
    font-size: 11px;
    color: #34495e;
    font-family: 'Courier New', monospace;
    font-weight: 600;
    margin-bottom: 2px;
}

.calculation-explanation {
    display: block;
    font-size: 9px;
    color: #7f8c8d;
    font-style: italic;
    margin-top: 2px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.stat-label {
    color: #6c757d;
}

.threat-list-note {
    margin-top: 6px;
    font-size: 10px;
    color: #6c757d;
    font-style: italic;
}

/* Weighted Score Calculation - uses same card format as Matched Threat Lists */
.weighted-card {
    background: linear-gradient(135deg, #e7f3f5 0%, #d1ecf1 100%) !important;
    border-left: 4px solid #0c5460 !important;
}

.weighted-header {
    border-bottom-color: rgba(12, 84, 96, 0.2) !important;
}

.weighted-card .threat-detail-title {
    color: #0c5460 !important;
}

.weighted-score-badge {
    background: linear-gradient(135deg, #0c5460 0%, #117a8b 100%) !important;
    font-size: 14px !important;
    padding: 4px 12px !important;
}

.weighted-list-item {
    background: rgba(255,255,255,0.7) !important;
    border-left: 3px solid #0c5460 !important;
}

.weighted-badge {
    background: #0c5460 !important;
}

/* Contribution footer at bottom of threat list cards */
.contribution-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
    text-align: center;
    background: #e8f5e9;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-radius: 4px;
    padding: 8px;
}

.contribution-formula {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(135deg, #e8f4f8 0%, #d1ecf1 100%);
    border-radius: 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 11px;
    color: #0c5460;
    font-weight: 600;
}

.stat-note {
    font-size: 10px;
    color: #6c757d;
    font-weight: normal;
}

/* Weighted score title with info icon */
.weighted-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-icon {
    cursor: help;
    font-size: 14px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.info-icon:hover {
    opacity: 1;
}

/* Weighted score formula display */
.weighted-formula-container {
    padding: 15px;
    background: rgba(255,255,255,0.8);
    border-radius: 6px;
    text-align: center;
}

.weighted-formula {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 16px;
    margin-bottom: 10px;
}

.formula-fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.formula-numerator,
.formula-denominator {
    color: #0c5460;
    font-weight: 600;
    padding: 2px 8px;
}

.formula-line {
    width: 100%;
    height: 2px;
    background: #0c5460;
}

.formula-equals {
    color: #6c757d;
    font-weight: bold;
    font-size: 20px;
}

.formula-result {
    color: #0c5460;
    font-weight: 600;
    font-size: 18px;
}

.formula-arrow {
    color: #6c757d;
    font-size: 18px;
}

.formula-final {
    color: #fff;
    background: linear-gradient(135deg, #0c5460 0%, #117a8b 100%);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 18px;
}

.formula-labels {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 10px;
    color: #6c757d;
    margin-top: 5px;
}

.formula-label {
    text-align: center;
}

.weighted-score-simple {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 16px;
}

.simple-label {
    color: #6c757d;
}

.simple-value {
    color: #0c5460;
    font-weight: 600;
    font-size: 18px;
}

/* Legacy weighted score display (kept for backwards compatibility) */
.weighted-score-card {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #e7f3f5 0%, #d1ecf1 100%);
    border-radius: 6px;
    border-left: 4px solid #0c5460;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.weighted-score-title {
    color: #0c5460;
    font-size: 13px;
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

.weighted-score-description {
    margin-bottom: 10px;
    font-size: 11px;
    color: #0c5460;
    opacity: 0.9;
}

.weighted-score-display {
    display: flex;
    align-items: baseline;
    gap: 15px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
}

.score-value-group {
    flex: 1;
}

.score-label {
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 2px;
}

.score-value {
    font-size: 18px;
    font-weight: 700;
    color: #0c5460;
}

.score-value-large {
    font-size: 24px;
}

.score-divider {
    border-left: 1px solid #dee2e6;
    padding-left: 15px;
}

/* Conflict Resolution */
.conflict-card {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    border-radius: 6px;
    border-left: 4px solid #ffc107;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.conflict-title {
    color: #856404;
    font-size: 13px;
    font-weight: 600;
}

.conflict-badge {
    background: #856404;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
}

.conflict-message {
    font-size: 12px;
    color: #856404;
}

/* Critical Override */
.critical-card {
    margin-top: 12px;
    padding: 12px;
    background: linear-gradient(135deg, #ffebee 0%, #f8d7da 100%);
    border-radius: 6px;
    border-left: 4px solid #dc3545;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

.critical-title {
    color: #721c24;
    font-size: 13px;
    font-weight: 600;
}

.critical-badge {
    background: #dc3545;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
}

.critical-message {
    font-size: 12px;
    color: #721c24;
}

.critical-message.with-lists {
    margin-bottom: 8px;
}

.critical-lists-container {
    margin-top: 8px;
    padding: 8px;
    background: rgba(255,255,255,0.6);
    border-radius: 4px;
}

.critical-lists-label {
    font-size: 11px;
    color: #721c24;
    font-weight: 600;
    margin-bottom: 4px;
}

.critical-lists-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.list-badge {
    background: #721c24;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
}

/* List Contribution */
.contribution-item {
    margin-top: 6px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-left: 3px solid #0c5460;
    border-radius: 4px;
    font-size: 11px;
    color: #555;
}

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

.contribution-name {
    color: #212529;
    font-weight: 600;
}

.contribution-badge {
    background: #0c5460;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
}

.contribution-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    color: #6c757d;
}

.contribution-stat-value {
    color: #212529;
    font-weight: 600;
}

