/* Analysis History Page Styles */
/* Container width inherited from common.css (1600px) */
/* Filter styles inherited from common.css */

/* Override margin when embedded in iframe */
.embedded .content,
.embedded main,
.embedded body > .container:first-of-type {
    margin-top: 0 !important;
}

.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #ddd;
}

.tab {
    padding: 12px 24px;
    background: #f5f5f5;
    border: none;
    border-radius: 4px 4px 0 0;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background 0.3s, color 0.3s;
}

.tab:hover {
    background: var(--lansa-light-green);
    color: var(--lansa-dark-green);
}

.tab.active {
    background: var(--lansa-dark-green);
    color: white;
}

.tab-content {
    display: none;
}

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

/* Inner history tab content (scoped class to avoid conflicts with parent tab-content) */
.history-tab-content {
    display: none;
}

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

.analyses-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.analyses-table thead {
    background: linear-gradient(135deg, var(--lansa-dark-green) 0%, #1b5e20 100%);
    color: white;
}

.analyses-table th {
    padding: 12px;
    text-align: left;
    font-weight: bold;
    font-size: 0.9em;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.analyses-table th.sortable:hover {
    background: rgba(255,255,255,0.1);
}

.analyses-table th .sort-indicator {
    margin-left: 5px;
    font-size: 0.8em;
    opacity: 0.5;
}

.analyses-table th.sorted .sort-indicator {
    opacity: 1;
}

.analyses-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.9em;
}

.analyses-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

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

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
}

.badge-single { background: var(--lansa-light-green); color: var(--lansa-dark-green); }
.badge-batch { background: #f3e5f5; color: #7b1fa2; }
.badge-semantic { background: #e8f5e9; color: #388e3c; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    font-size: 2em;
    color: var(--lansa-dark-green);
    margin-bottom: 5px;
}

.stat-card p {
    color: #666;
    font-size: 0.9em;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 16px;
    background: var(--lansa-dark-green);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

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

.pagination button:hover:not(:disabled) {
    background: #1b5e20;
}

.detail-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
}

.detail-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

/* Modal chat panel styles are in common.css */

.modal-header {
    background: linear-gradient(135deg, var(--lansa-dark-green) 0%, #1b5e20 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-header h2 {
    margin: 0;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header-actions .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-header-actions .btn-sm:hover {
    background: rgba(255, 255, 255, 0.3);
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-btn:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
}

.detail-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.detail-section h3 {
    color: var(--lansa-dark-green);
    margin-bottom: 10px;
    font-size: 1.1em;
}

.detail-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 10px;
    font-size: 0.9em;
}

.detail-grid dt {
    font-weight: bold;
    color: #666;
}

.detail-grid dd {
    margin: 0;
    color: #333;
}

/* Structural counts table (shared with analyze page) */
.struct-table {
    width: 100%;
    border-collapse: collapse;
}

.struct-table td {
    padding: 8px 15px;
    border-top: 1px solid #e0e0e0;
}

.struct-table td:first-child {
    width: 40%;
    color: #666;
    font-size: 13px;
}

.struct-table td:last-child {
    font-size: 13px;
}

/* Remediation dependency indicator */
.struct-table tr.remediation-row {
    background: #fff8e1;
}

.struct-table tr.remediation-row td:first-child::before {
    content: "\26A0";
    margin-right: 5px;
    color: #e65100;
}

/* Modal diagram container */
.modal-diagram-container {
    min-height: 300px;
    max-height: 500px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    overflow: auto;
    position: relative;
}

.modal-diagram-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.modal-diagram-controls button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.modal-diagram-controls button:hover {
    background: #f0f0f0;
}

.modal-diagram-controls .zoom-level {
    font-size: 12px;
    color: #666;
    min-width: 50px;
    text-align: center;
}

.modal-diagram-wrapper {
    overflow: auto;
    max-height: 400px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: white;
}

.modal-diagram-content {
    transform-origin: top left;
    transition: transform 0.2s ease;
    padding: 20px;
    display: inline-block;
    min-width: 100%;
}

.modal-diagram-container .mermaid-diagram {
    display: flex;
    justify-content: flex-start;
}

.modal-diagram-container svg {
    height: auto;
}

.modal-diagram-container .hint {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

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

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

/* Help button styling */
.help-button {
    padding: 8px 16px;
    background: var(--lansa-dark-green);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.help-button:hover {
    background: #1b5e20;
}

/* Chat message styles now in ai-assistant.css */

/* Charts Tab Styles */
.charts-container {
    padding: 20px 0;
}

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

.charts-header h3 {
    margin: 0;
    color: var(--lansa-dark-green);
}

.charts-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.charts-controls label {
    font-weight: 600;
    color: #666;
}

.charts-controls select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.file-input-label {
    display: inline-block;
    padding: 8px 16px;
    background: var(--lansa-light-green);
    color: var(--lansa-dark-green);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.file-input-label:hover {
    background: #c8e6c9;
}

.file-input-label input[type="file"] {
    display: none;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chart-card h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chart-card canvas {
    max-height: 400px;
}

@media (max-width: 1200px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

/* Remediation summary table */
.risk-remediation-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.risk-remediation-table th {
    background: #fff3e0;
    color: #e65100;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ffcc80;
}

.risk-remediation-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}

.risk-remediation-table tr:hover {
    background: #fff8e1;
}

.risk-count-badge {
    display: inline-block;
    min-width: 28px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85em;
}

.risk-count-badge.risk-high {
    background: #ffccbc;
    color: #bf360c;
}

.risk-count-badge.risk-medium {
    background: #fff9c4;
    color: #f57f17;
}

.risk-count-badge.risk-none {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Diagrams Section Styles */
.charts-diagrams {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.charts-diagrams h4 {
    margin: 0 0 15px 0;
    color: var(--lansa-dark-green);
}

.diagram-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.diagram-control-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.diagram-control-group label {
    font-weight: 600;
    color: #666;
    white-space: nowrap;
}

.diagram-control-group select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 200px;
}

.diagram-export-group {
    display: flex;
    gap: 5px;
    margin-left: auto;
}

.diagram-export-group .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.diagram-export-group .btn-sm:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.diagram-container {
    min-height: 300px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    background: #fafafa;
    overflow: auto;
}

.diagram-container .hint {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 40px;
}

.diagram-container .mermaid {
    display: flex;
    justify-content: center;
}

.diagram-container svg {
    max-width: 100%;
    height: auto;
}

.diagram-error {
    color: #dc3545;
    padding: 20px;
    text-align: center;
}

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

/* Modal chat panel styles are in common.css */

/* ==========================================
   Modal Summary Card
   ========================================== */
.modal-summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
}

.modal-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.modal-component-badge {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 10px;
}

.modal-entity-name {
    font-size: 18px;
    font-weight: 700;
}

.modal-cost {
    font-size: 24px;
    font-weight: 700;
}

.modal-metrics {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.modal-metric {
    text-align: center;
    min-width: 60px;
}

.modal-metric .value {
    font-size: 20px;
    font-weight: 700;
    display: block;
}

.modal-metric .label {
    font-size: 10px;
    opacity: 0.8;
    text-transform: uppercase;
}

.modal-metric.highlight {
    background: rgba(255,255,255,0.15);
    padding: 8px 12px;
    border-radius: 8px;
}

/* ==========================================
   Modal Tabs
   ========================================== */
.modal-tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.modal-tab {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: #666;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.modal-tab:hover {
    color: #333;
    background: #f5f5f5;
}

.modal-tab.active {
    color: #005EB8;
    border-bottom-color: #005EB8;
}

.modal-tab-badge {
    background: #ff9800;
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10px;
    margin-left: 5px;
}

.modal-tab-panel {
    display: none;
}

.modal-tab-panel.active {
    display: block;
}

/* ==========================================
   Modal Metrics Grid
   ========================================== */
.modal-metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.modal-metrics-grid .metric-box {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px 10px;
    text-align: center;
}

.modal-metrics-grid .metric-box .value {
    font-size: 20px;
    font-weight: 700;
    color: #005EB8;
    display: block;
}

.modal-metrics-grid .metric-box .label {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
}

.modal-metrics-grid .metric-box.highlight {
    background: #e8f5e9;
}

.modal-metrics-grid .metric-box.highlight .value {
    color: #2e7d32;
}

/* ==========================================
   Flags Row
   ========================================== */
.flags-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.flag-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.flag-badge.flag-yes {
    background: #d4edda;
    color: #155724;
}

.flag-badge.flag-no {
    background: #f8f9fa;
    color: #6c757d;
}

/* Hint text */
p.hint {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px;
}
