/**
 * Aipatch Security Scanner – Admin Styles
 *
 * @package AipatchSecurityScanner
 */

/* ---------------------------------------------------------------
   Layout & General
   --------------------------------------------------------------- */

.aipatch-hidden {
    display: none;
}

.aipatch-wrap {
    max-width: 1200px;
}

.aipatch-page-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 23px;
    font-weight: 400;
    margin: 10px 0 20px;
}

.aipatch-page-title .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.aipatch-page-desc {
    color: #50575e;
    margin-bottom: 20px;
    font-size: 14px;
}

.aipatch-section {
    margin-top: 20px;
}

.aipatch-section h2 {
    font-size: 18px;
    margin-bottom: 12px;
}

.aipatch-inline-form {
    display: inline-block;
    margin: 0;
}

/* ---------------------------------------------------------------
   Top Bar: Score + Actions
   --------------------------------------------------------------- */

.aipatch-top-bar {
    display: flex;
    align-items: center;
    gap: 24px;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.aipatch-score-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.aipatch-score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 4px solid #ddd;
}

.aipatch-score-excellent .aipatch-score-circle { border-color: #00a32a; background: #f0faf0; }
.aipatch-score-good .aipatch-score-circle { border-color: #72aee6; background: #f0f6fc; }
.aipatch-score-warning .aipatch-score-circle { border-color: #dba617; background: #fcf4e6; }
.aipatch-score-danger .aipatch-score-circle { border-color: #d63638; background: #fcecec; }

.aipatch-score-number {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}

.aipatch-score-excellent .aipatch-score-number { color: #00a32a; }
.aipatch-score-good .aipatch-score-number { color: #2271b1; }
.aipatch-score-warning .aipatch-score-number { color: #996800; }
.aipatch-score-danger .aipatch-score-number { color: #d63638; }

.aipatch-score-max {
    font-size: 11px;
    color: #8c8f94;
    line-height: 1;
}

.aipatch-score-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.aipatch-score-label {
    font-size: 16px;
    font-weight: 600;
}

.aipatch-score-date {
    font-size: 12px;
    color: #8c8f94;
}

.aipatch-top-actions {
    margin-left: auto;
    text-align: right;
}

.aipatch-top-actions .button-hero {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.aipatch-top-actions .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    margin-top: 2px;
}

.aipatch-next-scan {
    font-size: 12px;
    color: #8c8f94;
    margin-top: 6px;
}

/* ---------------------------------------------------------------
   Cards Grid
   --------------------------------------------------------------- */

.aipatch-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.aipatch-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color 0.2s;
}

.aipatch-card:hover {
    border-color: #2271b1;
}

.aipatch-card-warning {
    border-left: 4px solid #dba617;
}

.aipatch-card-danger {
    border-left: 4px solid #d63638;
}

.aipatch-card-info {
    border-left: 4px solid #72aee6;
}

.aipatch-card-icon {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #8c8f94;
}

.aipatch-card-warning .aipatch-card-icon { color: #996800; }
.aipatch-card-danger .aipatch-card-icon { color: #d63638; }

.aipatch-card-content {
    display: flex;
    flex-direction: column;
}

.aipatch-card-value {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
    color: #1d2327;
}

.aipatch-card-label {
    font-size: 12px;
    color: #8c8f94;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---------------------------------------------------------------
   Badges
   --------------------------------------------------------------- */

.aipatch-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.6;
}

.aipatch-severity-critical {
    background: #d63638;
    color: #fff;
}

.aipatch-severity-high {
    background: #e65100;
    color: #fff;
}

.aipatch-severity-medium {
    background: #dba617;
    color: #1d2327;
}

.aipatch-severity-low {
    background: #72aee6;
    color: #fff;
}

.aipatch-severity-info {
    background: #8c8f94;
    color: #fff;
}

/* ---------------------------------------------------------------
   Recommendations
   --------------------------------------------------------------- */

.aipatch-recommendations {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.aipatch-recommendation {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 14px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.aipatch-rec-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 100%;
}

.aipatch-recommendation > p {
    flex: 1 1 100%;
    margin: 4px 0 0;
    color: #50575e;
    font-size: 13px;
}

.aipatch-recommendation .aipatch-inline-form {
    margin-left: auto;
}

/* ---------------------------------------------------------------
   All Clear
   --------------------------------------------------------------- */

.aipatch-all-clear {
    text-align: center;
    padding: 40px 20px;
    background: #f0faf0;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
}

.aipatch-all-clear .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #00a32a;
}

.aipatch-all-clear p {
    font-size: 15px;
    color: #1d2327;
    margin-top: 8px;
}

/* ---------------------------------------------------------------
   Dismissed Issues
   --------------------------------------------------------------- */

.aipatch-dismissed-list {
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
}

.aipatch-dismissed-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #dcdcde;
}

.aipatch-dismissed-item:last-child {
    border-bottom: none;
}

/* ---------------------------------------------------------------
   Tables
   --------------------------------------------------------------- */

.aipatch-table {
    margin-top: 0;
}

.aipatch-table th {
    font-weight: 600;
}

.aipatch-table td {
    vertical-align: middle;
}

.aipatch-table .description {
    margin-top: 4px;
    color: #8c8f94;
    font-size: 12px;
}

.aipatch-fix-available {
    color: #00a32a;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.aipatch-fix-available .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.aipatch-source-badge {
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    color: #50575e;
}

.aipatch-col-severity { width: 90px; }
.aipatch-col-event { width: 150px; }
.aipatch-col-date { width: 180px; }

/* ---------------------------------------------------------------
   Logs
   --------------------------------------------------------------- */

.aipatch-logs-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 10px 16px;
    margin-bottom: 0;
}

.aipatch-severity-filters a {
    text-decoration: none;
    padding: 2px 4px;
}

.aipatch-severity-filters a.current {
    font-weight: 600;
    color: #1d2327;
}

.aipatch-log-severity {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

.aipatch-log-severity-critical { background: #d63638; color: #fff; }
.aipatch-log-severity-error { background: #e65100; color: #fff; }
.aipatch-log-severity-warning { background: #dba617; color: #1d2327; }
.aipatch-log-severity-info { background: #f0f0f1; color: #50575e; }

.aipatch-pagination {
    margin-top: 12px;
    text-align: right;
}

.aipatch-pagination .page-numbers {
    display: inline-block;
    padding: 4px 10px;
    margin: 0 2px;
    text-decoration: none;
    border: 1px solid #c3c4c7;
    border-radius: 3px;
    background: #fff;
}

.aipatch-pagination .page-numbers.current {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

/* ---------------------------------------------------------------
   Hardening
   --------------------------------------------------------------- */

.aipatch-hardening-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aipatch-hardening-item {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 18px 20px;
}

.aipatch-hardening-active {
    border-left: 4px solid #00a32a;
}

.aipatch-hardening-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.aipatch-hardening-info {
    flex: 1;
}

.aipatch-hardening-info h3 {
    margin: 0 0 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.aipatch-hardening-info p {
    margin: 0 0 4px;
    color: #50575e;
    font-size: 13px;
}

.aipatch-hardening-warning {
    color: #996800 !important;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px !important;
}

.aipatch-hardening-warning .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.aipatch-hardening-settings {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f1;
}

.aipatch-hardening-settings ul {
    margin: 4px 0 0 20px;
    list-style: disc;
}

.aipatch-meta-label {
    font-weight: 600;
    font-size: 12px;
    color: #8c8f94;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

/* Toggle Button */
.aipatch-toggle-btn {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    border-radius: 13px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 0;
    vertical-align: middle;
}

.aipatch-toggle-on {
    background: #00a32a;
}

.aipatch-toggle-off {
    background: #c3c4c7;
}

.aipatch-toggle-slider {
    position: absolute;
    top: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    transition: left 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.aipatch-toggle-on .aipatch-toggle-slider {
    left: 25px;
}

.aipatch-toggle-off .aipatch-toggle-slider {
    left: 3px;
}

/* ---------------------------------------------------------------
   Muted Box / Info Box
   --------------------------------------------------------------- */

.aipatch-muted-box {
    background: #f6f7f7;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 16px 20px;
    margin-top: 20px;
}

.aipatch-muted-box h3 {
    margin-top: 0;
}

.aipatch-muted-box p {
    color: #50575e;
    font-size: 13px;
}

/* ---------------------------------------------------------------
   Provider Status
   --------------------------------------------------------------- */

.aipatch-provider-status {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 14px 20px;
    margin-bottom: 20px;
}

.aipatch-provider-status h3 {
    margin: 0 0 8px;
    font-size: 14px;
}

.aipatch-provider-status ul {
    margin: 0;
    list-style: none;
    padding: 0;
}

.aipatch-provider-status li {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.aipatch-text-success { color: #00a32a; }
.aipatch-text-muted { color: #8c8f94; }

/* ---------------------------------------------------------------
   Settings
   --------------------------------------------------------------- */

.aipatch-settings-table th {
    width: 200px;
}

.aipatch-info-table {
    width: auto;
    border-collapse: collapse;
}

.aipatch-info-table td {
    padding: 4px 16px 4px 0;
}

/* ---------------------------------------------------------------
   Vulnerabilities Page
   --------------------------------------------------------------- */

#aipatch-vuln-table code {
    background: #f0f0f1;
    padding: 1px 5px;
    font-size: 12px;
}

/* ---------------------------------------------------------------
   Score Chart
   --------------------------------------------------------------- */

.aipatch-chart-container {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 16px;
    overflow: hidden;
}

.aipatch-chart-container canvas {
    width: 100%;
    display: block;
}

.aipatch-chart-empty {
    text-align: center;
    color: #50575e;
    padding: 20px 0;
}

.aipatch-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.aipatch-section-header h2 {
    margin: 0;
}

.aipatch-export-buttons {
    display: flex;
    gap: 6px;
}

.aipatch-export-buttons .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    vertical-align: text-bottom;
}

/* ---------------------------------------------------------------
   Recommendation Actions
   --------------------------------------------------------------- */

.aipatch-rec-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* ---------------------------------------------------------------
   Skeleton Loaders
   --------------------------------------------------------------- */

@keyframes aipatch-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.aipatch-skeleton-pulse {
    background: linear-gradient(90deg, #f0f0f1 25%, #e2e4e7 50%, #f0f0f1 75%);
    background-size: 200% 100%;
    animation: aipatch-shimmer 1.5s ease infinite;
}

.aipatch-skeleton-text {
    display: inline-block;
    background: linear-gradient(90deg, #f0f0f1 25%, #e2e4e7 50%, #f0f0f1 75%);
    background-size: 200% 100%;
    animation: aipatch-shimmer 1.5s ease infinite;
    border-radius: 3px;
    color: transparent !important;
    min-width: 40px;
    height: 1em;
}

.aipatch-card-skeleton {
    opacity: 0.6;
}

.aipatch-card-skeleton .aipatch-skeleton-pulse {
    background-color: #e2e4e7;
}

.aipatch-skeleton-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

/* ---------------------------------------------------------------
   Scan Level Selector
   --------------------------------------------------------------- */

.aipatch-scan-levels {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.aipatch-scan-level {
    cursor: pointer;
    margin: 0;
}

.aipatch-scan-level input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.aipatch-scan-level-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    border: 2px solid #c3c4c7;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    min-width: 80px;
}

.aipatch-scan-level-card strong {
    font-size: 13px;
    color: #1d2327;
}

.aipatch-scan-level-card small {
    font-size: 11px;
    color: #8c8f94;
}

.aipatch-scan-level-card:hover {
    border-color: #2271b1;
}

.aipatch-scan-level-selected,
.aipatch-scan-level input:checked + .aipatch-scan-level-card {
    border-color: #2271b1;
    background: #f0f6fc;
    box-shadow: 0 0 0 1px #2271b1;
}

.aipatch-scan-level-recommended {
    position: relative;
}

.aipatch-scan-level-recommended::after {
    content: '\2605';
    position: absolute;
    top: -6px;
    right: -6px;
    background: #2271b1;
    color: #fff;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

/* ---------------------------------------------------------------
   Scan Progress Panel
   --------------------------------------------------------------- */

.aipatch-scan-progress {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.aipatch-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.aipatch-progress-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aipatch-progress-title-row .dashicons {
    color: #2271b1;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.aipatch-progress-pct {
    font-size: 14px;
    font-weight: 600;
    color: #2271b1;
    font-variant-numeric: tabular-nums;
}

.aipatch-progress-bar-wrap {
    height: 8px;
    background: #f0f0f1;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}

.aipatch-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2271b1, #135e96);
    border-radius: 4px;
    width: 0;
    transition: width 0.4s ease;
}

.aipatch-progress-steps {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.aipatch-step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    transition: background 0.2s;
}

.aipatch-step-pending {
    color: #8c8f94;
}

.aipatch-step-pending .aipatch-step-icon {
    color: #c3c4c7;
}

.aipatch-step-running {
    background: #f0f6fc;
    color: #1d2327;
    font-weight: 500;
}

.aipatch-step-running .aipatch-step-icon {
    color: #2271b1;
}

.aipatch-step-done {
    color: #1d2327;
}

.aipatch-step-done .aipatch-step-icon {
    color: #00a32a;
}

.aipatch-step-label {
    flex: 1;
}

.aipatch-step-time {
    font-size: 11px;
    color: #8c8f94;
    font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
   Chart Section – fade-in animation
   --------------------------------------------------------------- */

.aipatch-chart-section {
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.4s ease, transform 0.3s ease;
}

.aipatch-chart-section.aipatch-chart-visible {
    opacity: 1;
    transform: translateY(0);
}

.aipatch-rec-actions .button-primary .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    vertical-align: text-bottom;
    margin-right: 2px;
}

/* ---------------------------------------------------------------
   Responsive
   --------------------------------------------------------------- */

@media screen and (max-width: 782px) {
    .aipatch-top-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .aipatch-top-actions {
        margin-left: 0;
        text-align: left;
    }

    .aipatch-cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .aipatch-hardening-header {
        flex-direction: column;
    }

    .aipatch-logs-toolbar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .aipatch-section-header {
        flex-direction: column;
        gap: 8px;
    }
}

/* ---------------------------------------------------------------
   Performance Diagnostics
   --------------------------------------------------------------- */

.aipatch-health-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.aipatch-health-badge > .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
}

.aipatch-health-good > .dashicons { color: #00a32a; }
.aipatch-health-warning > .dashicons { color: #dba617; }
.aipatch-health-poor > .dashicons { color: #d63638; }
.aipatch-health-none > .dashicons { color: #8c8f94; }

.aipatch-health-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.aipatch-health-label {
    font-size: 18px;
    font-weight: 600;
    color: #1d2327;
}

.aipatch-health-date {
    font-size: 12px;
    color: #8c8f94;
}

/* Performance Findings Grid */
.aipatch-perf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
}

.aipatch-perf-card {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    padding: 16px 18px;
    transition: border-color 0.2s;
}

.aipatch-perf-card:hover {
    border-color: #2271b1;
}

.aipatch-perf-status-good {
    border-left: 4px solid #00a32a;
}

.aipatch-perf-status-warning {
    border-left: 4px solid #dba617;
}

.aipatch-perf-status-poor {
    border-left: 4px solid #d63638;
}

.aipatch-perf-card-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.aipatch-perf-icon {
    font-size: 20px;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    flex-shrink: 0;
}

.aipatch-perf-status-good .aipatch-perf-icon { color: #00a32a; }
.aipatch-perf-status-warning .aipatch-perf-icon { color: #996800; }
.aipatch-perf-status-poor .aipatch-perf-icon { color: #d63638; }

.aipatch-perf-card-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.aipatch-perf-card-title strong {
    font-size: 14px;
    color: #1d2327;
}

.aipatch-perf-value {
    font-size: 12px;
    color: #50575e;
    font-weight: 600;
}

.aipatch-perf-desc {
    margin: 0 0 6px;
    color: #50575e;
    font-size: 13px;
    line-height: 1.5;
}

.aipatch-perf-rec {
    margin: 0;
    padding: 8px 10px;
    background: #fcf4e6;
    border-radius: 3px;
    font-size: 12px;
    color: #996800;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    line-height: 1.5;
}

.aipatch-perf-rec .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Performance Detail Tables */
.aipatch-perf-detail-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 12px;
}

.aipatch-perf-detail-table th {
    text-align: left;
    font-weight: 600;
    padding: 4px 8px;
    background: #f6f7f7;
    border-bottom: 1px solid #dcdcde;
}

.aipatch-perf-detail-table td {
    padding: 4px 8px;
    border-bottom: 1px solid #f0f0f1;
}

.aipatch-perf-detail-table code {
    background: #f0f0f1;
    padding: 1px 5px;
    font-size: 11px;
}

/* Recommendation value in header */
.aipatch-rec-value {
    margin-left: auto;
    font-size: 12px;
    color: #50575e;
    font-weight: 600;
}

/* Tools List */
.aipatch-tools-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.aipatch-tool-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.aipatch-tool-item p {
    flex: 1 1 100%;
    margin: 2px 0 0;
    color: #50575e;
    font-size: 13px;
}

@media screen and (max-width: 782px) {
    .aipatch-perf-grid {
        grid-template-columns: 1fr;
    }
}
