/*!
 * WordSentinel – Security and CSP management plugin for WordPress
 * (c) 2025 Nexsol Technologies Sàrl
 * License: GPL-2.0-or-later
 */

#adminmenu .toplevel_page_wordsentinel {
    .wp-menu-name {
        font-weight: bold;
    }

    .wp-menu-image::before {
        content: ' ';
        background-clip: content-box;
        background-repeat: no-repeat;
        background-position: center;
        width: 20px;
        height: 20px;
        padding: 7px 0;
    }
}

/* General styling for the plugin wrapper */
.wordsentinel-plugin {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
    color: #333;
}

.wordsentinel-logo {
    background-image: url('../assets/logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    width: 70px;
    height: 65px;
    display: block;
}

.nexsol-logo {
    background-image: url('../assets/nexsol_logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    width: 150px;
    height: 40px;
    display: block;
}

/* Header Section */
.wordsentinel-header {
    display: flex;
    flex-direction: column;
    padding-left: 20px;
    padding-right: 20px;
    margin-bottom: 20px;
    margin-left: -20px;
    margin-right: -20px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    gap: 2px;

    .title {
        width: 100%;
        display: flex;
        align-items: center;
        font-weight: bold;
        font-size: 45px;
        padding: 10px;
        filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5));

        .sentinel {
            color: #f48b2b;
        }
    }
}

.wordsentinel-footer {
    display: flex;
    flex-direction: column;
    padding-left: 10px;

    p {
        margin-bottom: 0;
    }

    img {
        max-width: 150px;
    }
}

/* Dashboard Section */
.wordsentinel-dashboard {
    margin-bottom: 40px;
    padding: 20px;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
}

.wordsentinel-dashboard h2 {
    font-size: 20px;
    color: #0073aa;
    margin-bottom: 20px;
}

/* Banner container */
.ws-donate-banner {
    background: #fff3e6;
    border-left: 4px solid #f48b2b;
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 6px;
}

.ws-donate-banner h3 {
    margin: 0 0 8px;
    font-weight: 600;
}

/* Action buttons container */
.ws-donate-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
}

/* Base button style */
.ws-btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: 0.2s ease-in-out;
}

/* Donate = blue */
.ws-btn-donate {
    background: #3394ff;
    color: #fff;
}

.ws-btn-donate:hover {
    background: #197be8;
}

/* Go Premium = green */
.ws-btn-premium {
    background: #35b653;
    color: #fff;
}

.ws-btn-premium:hover {
    background: #289941;
}

.ws-premium-active-banner {
    position: relative;
    background: #e7f8ee;
    border-left: 4px solid #35b653;
    padding: 28px 22px;
    margin: 20px 0;
    border-radius: 6px;
    overflow: hidden;
}

/* Background logo */
.ws-premium-bg-logo {
    position: absolute;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    opacity: 0.2;
    pointer-events: none;
    /* avoid blocking clicks */
}

.ws-premium-bg-logo img {
    width: 150px !important;
    height: 150px !important;
    object-fit: contain;
}

/* Text above logo */
.ws-premium-text {
    position: relative;
    z-index: 10;
}

.ws-premium-text h3 {
    margin: 0 0 6px;
    font-weight: 600;
    color: #289941;
}

.ws-premium-text p {
    margin: 0 0 6px;
    font-size: 14px;
}

.ws-license-valid-until {
    font-size: 13px;
    color: #1f7b38;
}

@media (max-width: 768px) {

    .wordsentinel-panel,
    .wordsentinel-inner-panel {
        flex: 1 1 100%;
        /* Take full width on small screens */
    }
}

/* Dashboard Panels Container */
.wordsentinel-panels {
    display: flex;
    gap: 20px;
    justify-content: space-between;
}

/* Individual Panels */
.wordsentinel-panel {
    flex: 1 1 auto;
    min-height: 240px;
    /* Adjust height as needed */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Prevent panels from overflowing */
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

/* Individual Panels */
.wordsentinel-inner-panel {
    width: 100%;
    flex: 1 1 auto;
    min-height: 240px;
    /* Adjust height as needed */
    flex-direction: column;
}

.wordsentinel-panel:hover {
    transform: scale(1.02);
    /* Slight zoom effect on hover */
}

/* Loading Spinner */
.wordsentinel-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    /* Light gray */
    border-top: 4px solid #0073aa;
    /* Blue for animation */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.warning-notice {
    color: white;
    padding: 10px;
    background: #d68123;
    display: flex;
    align-items: center;
    gap: 3px;

    .message {
        width: 100%;
        line-height: normal;
    }

    button {
        background: #ff9800;
        color: white;
        padding: 5px;
        border: none;
        cursor: pointer;
    }

}

.wordsentinel-message {
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wordsentinel-description {
    margin: 5px 0 10px;
    color: #666;
    font-size: 13px !important;
}

/* Centered Loading Message */
.wordsentinel-loading-message {
    margin-top: 10px;
    font-size: 14px;
    color: #555;
}

/* Grade Circle */
.wordsentinel-grade-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    justify-content: center;
    margin: 20px auto;
    font-size: 40px;
    font-weight: bold;
    /* Text color is dark for contrast */
    background-color: inherit;
    /* Match the panel background color */
    border: 5px solid transparent;
    /* Default transparent border */
    transition: transform 0.2s ease, border-color 0.2s ease;
}

/* === Grade Circles (aligned with Mozilla Observatory colors) === */

/* A+ / A / A− */
#panel-mozilla .wordsentinel-grade-circle-a-plus,
#panel-mozilla .wordsentinel-grade-circle-a,
#panel-mozilla .wordsentinel-grade-circle-a-minus {
    border-color: #017a37;
    /* --observatory-grade-a-border */
    background-color: #d2fadd;
    /* --observatory-grade-a-bg (light) */
    color: #265c3d;
    /* dark contrast tone */
}

/* B+ / B / B− */
#panel-mozilla .wordsentinel-grade-circle-b-plus,
#panel-mozilla .wordsentinel-grade-circle-b,
#panel-mozilla .wordsentinel-grade-circle-b-minus {
    border-color: #547a01;
    /* --observatory-grade-b-border */
    background-color: #e8fad2;
    /* --observatory-grade-b-bg */
    color: #52662a;
}

/* C+ / C / C− */
#panel-mozilla .wordsentinel-grade-circle-c-plus,
#panel-mozilla .wordsentinel-grade-circle-c,
#panel-mozilla .wordsentinel-grade-circle-c-minus {
    border-color: #7a7001;
    /* --observatory-grade-c-border */
    background-color: #faf8d2;
    /* --observatory-grade-c-bg */
    color: #66602a;
}

/* D+ / D / D− */
#panel-mozilla .wordsentinel-grade-circle-d-plus,
#panel-mozilla .wordsentinel-grade-circle-d,
#panel-mozilla .wordsentinel-grade-circle-d-minus {
    border-color: #a65001;
    /* --observatory-grade-d-border */
    background-color: #fae8d2;
    /* --observatory-grade-d-bg */
    color: #5c3d26;
}

/* F */
#panel-mozilla .wordsentinel-grade-circle-f {
    border-color: #a00;
    /* --observatory-grade-f-border */
    background-color: #fad2d2;
    /* --observatory-grade-f-bg */
    color: #5c2626;
}

#panel-mozilla .wordsentinel-grade-circle-error {
    border-color: #9e9e9e;
    background: #f5f5f5;
    color: #616161;
}

#panel-mozilla {
    position: relative;
}

.ws-grade-tooltip {
    position: absolute;
    display: none;
    background: #222;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    white-space: nowrap;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.ws-grade-tooltip::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px 8px 0;
    border-style: solid;
    border-color: #222 transparent transparent transparent;
}

/* Loading State */
.wordsentinel-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
    font-size: 16px;
    color: #0073aa;
}

/* Details Section */
.wordsentinel-details {
    margin-top: 10px;
    font-size: 14px;
    text-align: left;
    color: #555;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    line-height: 1.4;
}

/* Settings Section */
.wordsentinel-settings {
    padding: 20px;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
}

.wordsentinel-settings h2 {
    font-size: 20px;
    color: #0073aa;
    margin-bottom: 20px;
}

.wordsentinel-settings form {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
}

/* Scan Section */
.wordsentinel-scan-section {
    height: 35px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-end;
}

/* Reload Icon */
.wordsentinel-reload-icon-container {
    cursor: pointer;
}

.wordsentinel-reload-icon-container.disabled {
    cursor: auto;
}

.wordsentinel-reload-icon {
    font-size: 24px;
    color: #0073aa;
}

.wordsentinel-reload-icon.disabled {
    color: #ccc;
    pointer-events: none;
}

/* Tooltip Styling */
.wordsentinel-reload-icon-container[title]:hover::after {
    content: attr(title);
    position: absolute;
    top: -40px;
    /* Adjust position above the icon */
    right: 0;
    background-color: #333;
    color: #fff;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.wordsentinel-reload-icon-container[title]:hover::before {
    content: '';
    position: absolute;
    top: -10px;
    /* Adjust triangle position */
    right: 10px;
    border-width: 6px;
    border-style: solid;
    border-color: transparent transparent #333 transparent;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Toggle Wrapper */
.wordsentinel-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

/* Hide Default Checkbox */
.wordsentinel-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* Base slider */
.wordsentinel-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 24px;
}

/* Circle with icon inside */
.wordsentinel-slider::before {
    content: "✗";
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #888;
    /* gray cross for inactive */
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
    z-index: 2;
    /* ensures icon is visible above background */
}

/* Checked (active) state */
.wordsentinel-toggle input:checked+.wordsentinel-slider {
    background-color: #f48b2b;
    /* light green background */
}

.wordsentinel-toggle input:checked+.wordsentinel-slider::before {
    content: "✓";
    /* check mark */
    color: #2e7d32;
    /* green check for active */
    transform: translateX(26px);
}

/* Settings Container */
.wordsentinel-settings {
    position: relative;
}

/* Footer Inside Settings */
.wordsentinel-settings-footer {
    position: sticky;
    background-color: #fff;
    padding: 10px 20px;
    border-top: 1px solid #ddd;
}

/* Save Button */
.wordsentinel-settings-footer .button-primary {
    padding: 8px 16px;
    font-size: 14px;
}

/* Styles for the navigation tabs */
.nav-tab-wrapper {
    display: flex;
}

.nav-tab {
    color: #007cba;
    text-decoration: none;
    transition: background 0.2s;
}

.nav-tab-active {
    color: #333;
    font-weight: bold;
}

.nav-tab:hover {
    background: #e2e2e2;
    color: #005177;
}

/* Styles for tab content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    height: 100%;
}

.ws-scan-summary {
    display: flex;
    flex-direction: row;
    padding: 2rem;
    gap: 2rem;
    background-color: rgba(80, 87, 94, 0.1);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.ws-scroll-table {
    border-collapse: collapse;
}

.ws-scroll-table thead {
    display: table;
    width: 100%;
    table-layout: fixed;
}

.ws-scroll-body {
    display: block;
    max-height: 400px;
    overflow-y: auto;
    width: 100%;
}

.ws-scroll-body tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

#ws-benchmark-chart {
    width: 100%;
    min-height: 300px;
    max-height: 400px;
    pointer-events: none;
}

.ws-scan-summary h3,
.ws-scan-results h3 {
    font-size: 1.25em;
    margin-bottom: 10px;
}

/* General form styles */
.wordsentinel-settings-page #settings-title {
    font-weight: bold;
    font-size: 20px;
    margin-bottom: 20px;
}

.wordsentinel-settings-page .form-field {
    margin-bottom: 15px;
}

.wordsentinel-settings-page label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.wordsentinel-settings-page textarea,
.wordsentinel-settings-page input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
}

#wordsentinel_validate_license {
    margin-top: 5px;
}

.wordsentinel-message.success {
    color: #4CAF50;
}

.wordsentinel-message.error {
    color: #F44336;
}

#wordsentinel_license_info p {
    margin: 0;
    padding: 5px 0;
}

.wordsentinel-settings-page .submit {
    margin-top: 20px;
}

.wordsentinel-csp-locked-message {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    padding: 16px 24px;
    margin-bottom: 24px;
    font-size: 16px;
}

.wordsentinel-csp-locked-message .button-primary {
    margin-top: 8px;
}

.wordsentinel-csp-disabled {
    opacity: 0.5;
    pointer-events: none;
    user-select: none;
}

.wordsentinel-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.wordsentinel-modal-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #fff;
    border-radius: 8px;
    margin: 10% auto;
    padding: 32px 24px 24px 24px;
    width: 340px;
    box-shadow: 0 6px 32px rgba(0, 0, 0, 0.25);
    text-align: center;
    position: relative;

    .button-primary {
        width: 50px;
        align-self: center;
    }
}

.wordsentinel-modal-close {
    position: absolute;
    right: 14px;
    top: 12px;
    font-size: 28px;
    font-weight: bold;
    color: #bbb;
    cursor: pointer;
}

.wordsentinel-modal-close:hover {
    color: #222;
}

/* === CSP Advanced Options === */
#tab-csp-settings .form-table th {
    display: block;
    width: 100%;
    padding-bottom: 4px;
}

#tab-csp-settings .form-table td {
    display: block;
    width: 100%;
    padding-top: 0;
}

#tab-csp-settings .form-table tr {
    display: block;
    margin-bottom: 16px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.ws-csp-directive {
    margin-bottom: 20px;
    padding: 12px;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    background: #fff;
}

.ws-csp-label {
    font-weight: 600;
    display: block;
    margin-bottom: 6px;
    color: #23282d;
}

/* Input + Add button (horizontal) */
.ws-csp-add {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.ws-csp-input {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.2s;
}

.ws-csp-input:focus {
    border-color: #f48b2b;
    outline: none;
}

/* Add (+) button */
.ws-csp-add-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: #f1f1f1;
    cursor: pointer;
    transition: all 0.2s ease;
    vertical-align: middle;
}

/* Ensure disabled CSP add button looks visually disabled */
.ws-csp-add-btn:disabled,
.ws-csp-add-btn[disabled] {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    /* prevents accidental clicks */
    filter: grayscale(40%);
}

/* Keep + icon visible even when button is hovered */
.ws-csp-add-btn .dashicons {
    color: inherit !important;
    /* base color */
}

.ws-csp-add-btn:hover .dashicons,
.ws-csp-add-btn:focus .dashicons,
.ws-csp-add-btn:active .dashicons {
    color: #000 !important;
    /* force black icon */
}

/* Optional: when disabled */
.ws-csp-add-btn:disabled .dashicons {
    color: #666 !important;
}

.ws-csp-add-btn .dashicons {
    font-size: 20px;
    line-height: 1;
    position: relative;
    top: 0;
    /* adjust if needed: try 1px or -1px for pixel-perfect centering */
    color: #444;
}

.ws-csp-add-btn:hover {
    background-color: #f48b2b !important;
}

.ws-csp-add-btn:hover .dashicons {
    color: #fff;
}

.ws-csp-add-btn:hover {
    background-color: #f48b2b;
}

.ws-csp-add-btn:hover .dashicons {
    color: #fff;
}

/* CSP value chips */
.ws-csp-values {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ws-csp-chip {
    display: inline-flex;
    align-items: center;
    background: #f1f1f1;
    border-radius: 16px;
    padding: 4px 8px;
    font-size: 13px;
}

.ws-csp-detected {
    margin-top: 6px;
    font-size: 13px;
    color: #555;
}

.ws-csp-chip-detected {
    background-color: #e5e5e5;
    color: #333;
    cursor: default;
    opacity: 0.9;
}

.ws-csp-detected-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.ws-csp-remove {
    cursor: pointer;
    margin-left: 6px;
    color: #900;
    font-weight: bold;
    transition: color 0.2s;
}

.ws-csp-remove:hover {
    color: #f48b2b;
}

/* Invalid input feedback */
.ws-csp-invalid {
    border-color: #dc3545 !important;
    background-color: #ffe5e5;
}

/* Optional: Slight spacing between directives for clarity */
.ws-csp-directive+.ws-csp-directive {
    margin-top: 16px;
}

/* --- Mozilla panel loading overlay --- */
.ws-panel-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
    border-radius: 8px;
}

#panel-mozilla {
    position: relative;
}