/**
 * @package     Joomla.Plugin
 * @subpackage  Content.Performance
 * @description Google PageSpeed Insights Audit Tool Styles
 * @author      SEO Serviss
 * @copyright   Copyright (C) 2026. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 * @version     1.0.0
 * @since       1.0.0
 */

/* Scoped Variables - LIGHT THEME (PSI Style) */
.performance-audit-container {
    --bg-color: #ffffff;
    --card-bg: #ffffff;
    --card-border: #e0e0e0;
    /* Light gray border */
    --primary: #1a73e8;
    /* Google Blue */
    --primary-glow: rgba(26, 115, 232, 0.2);
    --text-primary: #202124;
    /* Google Dark Gray */
    --text-secondary: #5f6368;
    /* Google Medium Gray */
    --accent-gradient: #1a73e8;
    /* Flat blue button */
    --score-good: #0cce6b;
    --score-needs-improvement: #ffa400;
    --score-poor: #ff4e42;

    /* Base Reset & Font */
    all: initial;
    font-family: 'Roboto', 'Outfit', sans-serif !important;
    /* Prefer Roboto for Google look */
    color: var(--text-primary);
    background-color: var(--bg-color);
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 2rem;
    border-radius: 8px;
    /* Sharper corners like PSI */
    position: relative;
    border: 1px solid #dadce0;
}

/* Remove Dark Mode Blobs */
.performance-audit-container::before {
    display: none;
}

.performance-audit-container * {
    box-sizing: border-box;
    font-family: 'Roboto', 'Outfit', sans-serif !important;
}

/* Typography Overrides */
.performance-audit-container h1,
.performance-audit-container h2,
.performance-audit-container h3,
.performance-audit-container h4,
.performance-audit-container p,
.performance-audit-container span,
.performance-audit-container div {
    color: var(--text-primary);
    line-height: 1.5;
}

/* Card Style - Clean White */
.performance-audit-container .audit-card {
    position: relative;
    z-index: 1;
    max-width: 960px;
    /* PSI uses a container width approx this */
    margin: 0 auto;
}

/* Search Box Area - Flat Light */
.performance-audit-container .input-group {
    background: #ffffff !important;
    border: 1px solid #dadce0 !important;
    backdrop-filter: none;
    border-radius: 4px;
    /* PSI buttons are 4px or 24px pill, search is boxy */
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.performance-audit-container .input-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 1rem;
}

/* RESET INPUTS AGGRESSIVELY */
.performance-audit-container input[type="url"] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #202124 !important;
    font-size: 1.1rem !important;
    height: auto !important;
    padding: 0.5rem !important;
    width: 100%;
    outline: none !important;
    margin: 0 !important;
}

.performance-audit-container input[type="url"]::placeholder {
    color: #5f6368;
}

.performance-audit-container .search-icon {
    stroke: var(--text-secondary);
}

/* Cloudflare Turnstile Widget */
.performance-audit-container .turnstile-widget {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

/* Button Styling - Flat Blue */
.performance-audit-container .analyze-btn {
    background: #1a73e8 !important;
    border: none !important;
    color: white !important;
    padding: 0.75rem 2rem !important;
    border-radius: 4px !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    cursor: pointer !important;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.performance-audit-container .analyze-btn:hover {
    background: #1557b0 !important;
    /* Darker blue */
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Strategy Tabs (PSI Style) */
.performance-audit-container .strategy-tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    /* Connected tabs appearance if desired, or gap */
    margin-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
}

.performance-audit-container .strategy-tab {
    cursor: pointer;
    margin: 0;
    position: relative;
}

.performance-audit-container .strategy-tab input {
    display: none;
}

.performance-audit-container .tab-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    /* Prepare for active border */
    margin-bottom: -1px;
    /* Overlap border-bottom of container */
}

.performance-audit-container .strategy-tab input:checked+.tab-content {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(26, 115, 232, 0.04);
    /* Slight active bg */
}

.performance-audit-container .tab-content svg {
    /* Ensure icon size is controlled */
    width: 20px;
    height: 20px;
}

/* Link Styling */
.performance-audit-container a.url-link {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
    /* Ensure long URLs break */
}

.performance-audit-container a.url-link:hover {
    text-decoration: underline;
}

/* Results */
.performance-audit-container .results-section {
    opacity: 0;
    animation: fadeIn 0.6s forwards;
    padding-top: 2rem;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.performance-audit-container .score-card {
    text-align: center;
    margin-bottom: 3rem;
}

/* 4-Column Score Grid */
.performance-audit-container .scores-grid {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.performance-audit-container .score-gauge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 100px;
}

.performance-audit-container .score-ring-small {
    position: relative;
    width: 100px;
    height: 100px;
}

.performance-audit-container .progress-ring-small {
    transform: rotate(-90deg);
}

.performance-audit-container .progress-ring__circle-small {
    transition: stroke-dashoffset 1s ease-in-out;
    transform-origin: 50% 50%;
    stroke-linecap: round;
}

.performance-audit-container .score-value-small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary) !important;
    /* Fixed: Was white, now dark */
    line-height: 1;
}

.performance-audit-container .score-label-small {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.performance-audit-container .results-title {
    font-weight: 700;
    font-size: 1.5rem;
    margin-top: 1rem;
}

/* PSI Layout */
.performance-audit-container .psi-layout-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.performance-audit-container .metrics-column {
    flex: 2;
    min-width: 300px;
}

/* Helper Text */
.performance-audit-container .search-helper-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.performance-audit-container .analyze-btn:hover {
    background: #1557b0 !important;
    /* Darker blue */
    color: white !important;
    /* Force white text */
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Gauge + Screenshot Row */
.performance-audit-container .gauge-screenshot-row {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    align-items: stretch;
    /* Both columns same height */
    justify-content: center;
    margin-bottom: 2rem;
    padding: 2rem;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    background: #fcfcfc;
    min-height: 250px;
    /* Fixed minimum height */
}

.performance-audit-container .complex-gauge-container {
    flex: 1;
    min-width: 200px;
    max-width: 250px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.performance-audit-container .screenshot-column {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
    height: 220px;
    /* Fixed height */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    overflow: hidden;
}

.performance-audit-container .final-screenshot-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.performance-audit-container .final-screenshot-container img {
    max-width: 100%;
    max-height: 200px;
    height: auto;
    object-fit: contain;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

/* Runtime Settings */
.performance-audit-container .runtime-settings {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.performance-audit-container .runtime-row {
    margin-bottom: 0.25rem;
}

.performance-audit-container .runtime-label {
    font-weight: 500;
    color: var(--text-primary);
}

/* Metric Cards - PSI (Cleaner, no borders, just bottom line maybe) */
.performance-audit-container .metrics-grid {
    display: grid;
    /* Force 2 columns on desktop as requested */
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    border-top: 1px solid #e0e0e0;
    padding-top: 1.5rem;
}

@media (max-width: 600px) {
    .performance-audit-container .metrics-grid {
        grid-template-columns: 1fr;
    }
}

.performance-audit-container .metric-card {
    background: #ffffff;
    /* Explicit background for hover contrast */
    border: 1px solid transparent;
    /* Prepare for border transition */
    padding: 1rem;
    border-radius: 8px;
    /* Rounded corners like index.html sample */
    transition: all 0.3s ease;
    border-bottom: 3px solid #f0f0f0;
    /* Thicker bottom like cards */
}

/* Hover effect for Metric Cards */
.performance-audit-container .metric-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: #e0e0e0;
    background: #fdfdfd;
}

.performance-audit-container .metric-title {
    color: #5f6368;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.performance-audit-container .metric-value {
    color: #202124 !important;
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
}

.performance-audit-container .metric-bar-bg {
    background: #e0e0e0;
    height: 4px;
    /* Thinner line */
    border-radius: 2px;
}

/* Screenshot styling */
.performance-audit-container .final-screenshot-container img {
    max-width: 100%;
    height: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    display: block;
}

.performance-audit-container .progress-ring__circle-small {
    stroke-linecap: butt !important;
}


.performance-audit-container .metric-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.performance-audit-container .metric-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.performance-audit-container .metric-value {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white;
}

.performance-audit-container .metric-bar-bg {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.performance-audit-container .metric-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 1s;
}

/* Audit Lists */
.performance-audit-container .audits-container {
    text-align: left;
}

.performance-audit-container .audit-group-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: white;
}

.performance-audit-container .audit-group-desc {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.performance-audit-container .audit-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.performance-audit-container .audit-item {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    overflow: hidden;
    margin-bottom: 0 !important;
}

.performance-audit-container .audit-header-row {
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.performance-audit-container .audit-header-row:hover {
    background: rgba(255, 255, 255, 0.02);
}

.performance-audit-container .audit-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.performance-audit-container .audit-severity {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.performance-audit-container .severity-error {
    color: var(--score-poor);
}

.performance-audit-container .severity-warning {
    color: var(--score-needs-improvement);
}

.performance-audit-container .severity-pass {
    color: var(--score-good);
}

.performance-audit-container .severity-info {
    color: var(--text-secondary);
}

.performance-audit-container .audit-title {
    font-weight: 500;
    font-size: 0.95rem;
}

.performance-audit-container .audit-value {
    font-family: monospace;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.performance-audit-container .audit-chevron {
    opacity: 0.5;
    transition: transform 0.3s;
}

.performance-audit-container .audit-item.expanded .audit-chevron {
    transform: rotate(180deg);
}

/* Details Expansion */
.performance-audit-container .audit-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
    background: rgb(167 169 171 / 20%);
    /* Lighter background as requested */
}

.performance-audit-container .audit-details-inner {
    padding: 1.25rem;
    border-top: 1px solid var(--card-border);
}

/* Tables */
.performance-audit-container table {
    width: 100%;
    border-collapse: collapse;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.performance-audit-container th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-primary);
    font-weight: 600;
}

.performance-audit-container td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    word-break: break-word;
}

.performance-audit-container tr:last-child td {
    border-bottom: none;
}

.performance-audit-container .col-numeric {
    text-align: right;
    font-family: monospace;
}

.performance-audit-container .url-column {
    color: var(--primary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Loader / Utils */
.performance-audit-container .loader {
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-bottom-color: transparent;
    border-radius: 50%;
    animation: rotation 1s linear infinite;
}

@keyframes rotation {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Passed Audits Dropdown */
.performance-audit-container .passed-audits-dropdown {
    margin-top: 3rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.performance-audit-container .passed-audits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    cursor: pointer;
    transition: background 0.2s;
}

.performance-audit-container .passed-audits-header:hover {
    background: #f0f0f0;
}

.performance-audit-container .passed-audits-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

.performance-audit-container .passed-icon {
    color: var(--score-good);
}

.performance-audit-container .passed-count {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.9rem;
}

.performance-audit-container .dropdown-chevron {
    color: var(--text-secondary);
    transition: transform 0.3s;
}

.performance-audit-container .passed-audits-dropdown.expanded .dropdown-chevron {
    transform: rotate(180deg);
}

.performance-audit-container .passed-audits-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out;
}

.performance-audit-container .passed-audits-dropdown.expanded .passed-audits-content {
    max-height: 2000px;
    padding: 1rem;
}

.performance-audit-container .hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .performance-audit-container .search-box-container {
        width: 100%;
    }

    .performance-audit-container .input-group {
        flex-direction: column;
    }

    .performance-audit-container .url-column {
        max-width: 150px;
    }
}