/* InfaNeer - Remediation Playbooks Styles */

/* Page Layout */
.playbooks-content {
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title h1 {
    margin: 0 0 4px 0;
    font-size: 24px;
    font-weight: 600;
}

.page-title p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.page-actions {
    display: flex;
    gap: 12px;
}

/* Stats Cards */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.total {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.stat-icon.verified {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.stat-icon.draft {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.stat-icon.executions {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
}

.stat-details {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Filters */
.filters-section {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--surface-color);
    border-radius: 8px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    min-width: 180px;
    background: var(--background-color);
    color: var(--text-primary);
}

.filter-info {
    margin-left: auto;
    font-size: 14px;
    color: var(--text-secondary);
}

/* Playbooks Table */
.playbooks-table-container {
    background: var(--surface-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 24px;
}

.playbooks-table {
    width: 100%;
    border-collapse: collapse;
}

.playbooks-table th,
.playbooks-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.4;
}

.playbooks-table th {
    background: var(--background-color);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    padding: 10px 14px;
}

.select-col {
    width: 34px;
    min-width: 34px;
    text-align: center !important;
}

.playbooks-table tbody tr {
    background: var(--surface-color);
}

.playbooks-table tbody tr:hover {
    background: var(--surface-hover);
}

.playbooks-table tbody tr:last-child td {
    border-bottom: none;
}

.trigger-cell {
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 180px;
}

.trigger-cell strong {
    color: var(--text-primary);
}

.actions-cell {
    white-space: nowrap;
}

.bulk-actions-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    margin: -12px 0 24px 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.badge-warning {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.action-badge {
    display: inline-block;
    padding: 4px 8px;
    background: var(--background-color);
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Monaco', monospace;
    color: var(--text-primary);
}

.rate-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.rate-badge.high {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.rate-badge.medium {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.rate-badge.low {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

/* Empty State */
.empty-state {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background: var(--surface-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.empty-state svg {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.empty-state h3 {
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.empty-state p {
    margin: 0 0 20px 0;
    color: var(--text-secondary);
    max-width: 400px;
}

/* Info Section */
.info-section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 24px;
}

.info-section h3 {
    margin: 0 0 20px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.info-item {
    display: flex;
    gap: 16px;
}

.info-number {
    width: 36px;
    height: 36px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.info-content strong {
    display: block;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.info-content p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Form Styles */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--background-color);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* View Modal Styles */
.view-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.view-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.view-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.view-value {
    font-size: 16px;
    color: var(--text-primary);
}

.view-value.trigger-pattern {
    font-family: 'Monaco', monospace;
    background: var(--background-color);
    padding: 12px;
    border-radius: 6px;
}

.view-keywords {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.view-keywords .keyword {
    display: inline-block;
    padding: 2px 8px;
    background: var(--surface-hover);
    border-radius: 4px;
    margin: 2px;
}

.view-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.view-label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 100px;
}

.view-code {
    background: var(--background-color);
    padding: 12px;
    border-radius: 6px;
    font-family: 'Monaco', monospace;
    font-size: 12px;
    overflow-x: auto;
    margin: 0;
    flex: 1;
}

.view-text {
    color: var(--text-primary);
    line-height: 1.6;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-item .stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.stat-item .stat-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.stat-item .stat-value.verified {
    color: #4ade80;
}

.stat-item .stat-value.draft {
    color: #fbbf24;
}

/* Execution History */
.execution-history {
    background: var(--background-color);
    border-radius: 6px;
    overflow: hidden;
}

.execution-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
}

.execution-item:last-child {
    border-bottom: none;
}

.execution-item.success .exec-status {
    color: #4ade80;
}

.execution-item.failed .exec-status {
    color: #f87171;
}

.exec-status {
    font-weight: 700;
    width: 20px;
    text-align: center;
}

.exec-host {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 100px;
}

.exec-trigger {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exec-time {
    color: var(--text-muted);
    font-size: 12px;
}

.exec-approved {
    color: var(--text-muted);
    font-size: 11px;
}

/* Loading & Error States */
.loading-row td,
.error-row td {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
    vertical-align: middle;
}

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

.error-text {
    color: var(--error-color);
}

/* Button Styles */
.btn svg {
    vertical-align: middle;
    margin-right: 6px;
}

.btn-small {
    padding: 6px 10px;
    font-size: 12px;
}

.btn-small svg {
    margin-right: 0;
}

.btn-danger {
    color: var(--error-color);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Load from Zabbix Section */
.load-from-zabbix {
    margin-bottom: 16px;
}

.zabbix-alert-loader {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

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

.loader-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.loader-filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.loader-filters .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.loader-results {
    max-height: 250px;
    overflow-y: auto;
}

.zabbix-test-results-scroll {
    max-height: 360px;
    overflow: auto;
    resize: vertical;
    min-height: 120px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    background: var(--background-color);
}

.loader-hint {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-item {
    padding: 12px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.alert-item:hover {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.05);
}

.alert-trigger {
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 13px;
}

.alert-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Action Parameter Hints */
.action-param-hints {
    margin-bottom: 16px;
}

.param-hint {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-size: 13px;
}

.param-hint p {
    margin: 0 0 8px 0;
}

.param-hint code {
    display: block;
    font-family: 'Monaco', monospace;
    font-size: 11px;
    background: var(--background-color);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
}

/* Trigger Pattern Tester */
.trigger-tester-section {
    margin-bottom: 20px;
}

.tester-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

.tester-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tester-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.tester-header h3 svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.tester-description {
    margin: 8px 0 12px 0;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.tester-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.tester-input-group input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--background-color);
    color: var(--text-primary);
}

.tester-input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.tester-results-scroll {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.tester-results-table {
    width: 100%;
    border-collapse: collapse;
}

.tester-results-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.tester-results-table th,
.tester-results-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

.tester-results-table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--background-color);
    white-space: nowrap;
    padding: 10px 12px;
}

/* Score Badges */
.score-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.score-badge.score-high {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.score-badge.score-medium {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.score-badge.score-low {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.score-badge.score-small {
    padding: 2px 6px;
    font-size: 10px;
}

/* Match indicators */
.match-yes {
    color: #4ade80;
    font-weight: 700;
    font-size: 16px;
}

.match-no {
    color: #f87171;
    font-weight: 700;
    font-size: 16px;
}

.no-match {
    color: var(--text-muted);
    font-style: italic;
    font-size: 13px;
}

.matched-playbook {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* ==================== Resizable Scroll Boxes ==================== */

.resizable-section {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.resizable-scroll-box {
    overflow: auto;
    resize: vertical;
    min-height: 100px;
    max-height: 800px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--background-color);
    position: relative;
}

/* Sticky header inside scroll boxes */
.resizable-scroll-box thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.resizable-scroll-box thead th {
    background: var(--surface-color);
    border-bottom: 2px solid var(--border-color);
}

/* Resize handle hint */
.resizable-scroll-box::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    display: block;
    height: 3px;
    background: linear-gradient(to right, transparent, var(--border-color) 30%, var(--border-color) 70%, transparent);
    opacity: 0.5;
    pointer-events: none;
}

/* Section headers — consistent across all sections */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.section-header h3 svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

/* Tables inside scroll boxes */
.resizable-scroll-box .match-history-table,
.resizable-scroll-box .tester-results-table {
    width: 100%;
    margin: 0;
}

.match-history-table {
    width: 100%;
    border-collapse: collapse;
}

.match-history-table th,
.match-history-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.4;
}

.match-history-table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--background-color);
    white-space: nowrap;
    padding: 10px 12px;
}

.match-history-table tbody tr:hover {
    background: var(--surface-hover);
}

/* Trigger cells in all tables — word-wrap instead of truncate */
.match-history-table .trigger-cell,
.tester-results-table .trigger-cell {
    word-break: break-word;
    overflow-wrap: break-word;
    min-width: 180px;
    max-width: 400px;
}

.empty-cell {
    text-align: center;
    padding: 30px !important;
    color: var(--text-muted);
    font-style: italic;
}

.time-cell {
    white-space: nowrap;
    color: var(--text-muted);
    font-size: 12px;
    min-width: 80px;
}

/* Threshold Slider */
.threshold-slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.threshold-slider-group input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border-color);
    border-radius: 3px;
    outline: none;
    border: none;
    padding: 0;
}

.threshold-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.threshold-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 45px;
    text-align: right;
}

/* Test Against Zabbix Alerts (in modal) */
.test-zabbix-section {
    margin-bottom: 16px;
}

.zabbix-test-loader {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.playbook-edit-modal {
    width: min(96vw, 1280px) !important;
    max-width: 1280px !important;
    height: 88vh !important;
    resize: both;
    overflow: hidden !important;
    min-width: 760px;
    min-height: 620px;
}

.playbook-edit-modal .modal-body {
    overflow: auto;
    display: block;
}

.playbook-edit-modal .modal-footer,
.playbook-edit-modal .modal-header {
    flex-shrink: 0;
}

.playbook-import-section {
    margin-top: 24px;
}

.section-description {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    margin: -4px 0 16px 0;
}

.import-controls {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(240px, 1fr) auto auto;
    gap: 12px;
    align-items: end;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    padding-bottom: 10px;
}

.import-progress {
    margin-top: 14px;
}

.progress-track {
    height: 8px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: var(--primary-color);
    transition: width 0.25s ease;
}

.import-results {
    margin-top: 12px;
    font-size: 13px;
}

.import-summary {
    padding: 10px 12px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 6px;
}

.import-errors {
    margin-top: 10px;
    padding: 10px;
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: auto;
    max-height: 220px;
}

.zabbix-test-results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.zabbix-test-results-table th,
.zabbix-test-results-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-primary);
}

.zabbix-test-results-table th {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--background-color);
}

.test-summary {
    padding: 10px 12px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
    }

    .filters-section {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group input,
    .filter-group select {
        min-width: 100%;
    }

    .filter-info {
        margin-left: 0;
        margin-top: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .playbooks-table {
        font-size: 13px;
    }

    .playbooks-table th,
    .playbooks-table td {
        padding: 8px;
    }
}
