/**
 * Dashboard widget styles for Nginx Cache Purge Preload
 * Description: Styles the WordPress dashboard cache widget and preload progress elements.
 * Version: 2.1.6
 * Author: Hasan CALISIR
 * Author Email: hasan.calisir@psauxit.com
 * Author URI: https://www.psauxit.com
 * License: GPL-2.0+
 */

/* Loader Overlay */
#nppp-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    pointer-events: none;
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#nppp-loader-overlay.active {
    display: flex;
    pointer-events: all;
}

/* Spinner Container */
.nppp-spinner-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 12vw;
    height: 12vw;
    max-width: 80px;
    max-height: 80px;
    border-radius: 50%;
}

/* Spinner Animation */
.nppp-loader {
    position: absolute;
    border: 8px solid rgba(224, 224, 224, 1);
    border-top: 8px solid rgba(77, 184, 255, 1);
    border-radius: 50%;
    width: 100%;
    height: 100%;
    animation: nppp-spin 1s linear infinite;
    z-index: 3;
}

@keyframes nppp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mask Container (used for filling effect) */
.nppp-fill-mask {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    z-index: 1;
}

/* Circular Filling Effect */
.nppp-loader-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 200%;
    background: rgba(51, 122, 183, 1);
    transform: scaleY(0);
    transform-origin: bottom;
    animation: nppp-fill 5s ease-in-out infinite;
}

@keyframes nppp-fill {
    0% {
        transform: scaleY(0);
    }
    50% {
        transform: scaleY(1);
    }
    100% {
        transform: scaleY(0);
    }
}

/* Static Text */
.nppp-loader-text {
    position: absolute;
    color: #ffffff;
    font-weight: bold;
    font-size: 1.8em;
    pointer-events: none;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 4;
}

@media (max-width: 600px) {
    .nppp-loader-text {
        font-size: 1.4em;
    }
}

/* Loader Message */
.nppp-loader-message {
    margin-top: 20px;
    color: #ffffff;
    font-size: 1.4em;
    font-weight: 600;
    text-align: center;
}

@media (max-width: 600px) {
    .nppp-loader-message {
        font-size: 1.2em;
    }
}

/* Disable focus styles for your NPP dashboard widget buttons */
#nppp_dashboard_widget a:focus,
#nppp_dashboard_widget a:focus .gravatar,
#nppp_dashboard_widget a:focus .media-icon img,
#nppp_dashboard_widget a:focus .plugin-icon {
    color: inherit !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Buttons disabled */
.disabled {
    pointer-events: none;
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hover effects for the widget buttons */
.nppp-action-button[data-action="nppp-widget-purge"]:hover {
    color: white !important;
    background-color: #c9302c !important;
}

.nppp-action-button[data-action="nppp-widget-preload"]:hover {
    color: white !important;
    background-color: #2e8b57 !important;
}

.nppp-settings-button:hover {
    color: white !important;
    background-color: #006099 !important;
}

.nppp-give-star-button:hover {
    color: indigo !important;
    background-color: #e6b800 !important;
}

/* Widget buttons on mobile */
@media screen and (max-width: 768px) {
    .nppp-settings-button {
        flex: 55% !important;
    }

    .nppp-give-star-button {
        flex: 45% !important;
    }
}

/* Keyframes for blinking effect */
@keyframes nppp-blink {
    0% {
        background-color: white;
    }
    50% {
        background-color: #90ee90;
    }
    100% {
        background-color: white;
    }
}

#wp-admin-bar-fastcgi-cache-operations {
    background-color: midnightblue !important;
}

/* =============================================================
   Cache Hit Ratio
   ============================================================= */

.nppp-ratio-strip {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 14px 16px;
    background: #fafafa;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    border-left: 5px solid #ddd;
    transition: border-left-color 0.5s ease;
    min-height: 90px;
    margin-bottom: 8px;
}

.nppp-ratio-gauge {
    position: relative;
    flex-shrink: 0;
    width: 96px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nppp-gauge-svg     { display: block; overflow: visible; }
.nppp-gauge-track   { stroke: #c8c8c8; }

.nppp-gauge-progress {
    stroke: #3CB371;
    stroke-dasharray: 232.48;
    stroke-dashoffset: 232.48;
}

.nppp-gauge-pct {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15px;
    font-weight: 800;
    color: #444;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
    text-align: center;
    letter-spacing: -0.3px;
    transition: color 0.5s ease, font-size 0.2s ease;
}

.nppp-ratio-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.nppp-ratio-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #444;
    letter-spacing: 1.1px;
}

.nppp-ratio-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #ddd;
}

.nppp-ratio-detail {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: #555;
    line-height: 1.5;
    word-break: break-word;
}

.nppp-ratio-stats-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    font-size: 12.5px;
    font-weight: 500;
}

.nppp-ratio-age-row {
    display: flex;
    align-items: center;
}

.nppp-ratio-hit   { color: #3CB371; font-weight: 700; }
.nppp-ratio-miss  { color: #d9534f; font-weight: 700; }
.nppp-ratio-total { color: #555; font-weight: 700; }
.nppp-ratio-sep   { color: #bbb; }

.nppp-ratio-na {
    color: #666;
    font-style: italic;
    font-size: 12.5px;
}

.nppp-ratio-age {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
    background: #efefef;
    color: #666;
    white-space: nowrap;
    border: 1px solid #e0e0e0;
}

@media screen and (max-width: 600px) {
    .nppp-ratio-strip {
        flex-direction: column;
        align-items: center;
        text-align: center;
        border-left: none;
        border-top: 1px solid #e0e0e0;
        border-bottom: 5px solid #ddd;
        padding: 16px 14px 18px;
        gap: 10px;
        margin-bottom: 15px;
    }

    .nppp-ratio-gauge {
        width: 108px;
        height: 108px;
        margin-bottom: 6px;
    }

    .nppp-ratio-gauge svg.nppp-gauge-svg {
        width: 108px;
        height: 108px;
    }

    .nppp-ratio-info {
        align-items: center;
    }

    .nppp-ratio-title::after {
        display: none;
    }

    .nppp-ratio-stats-row,
    .nppp-ratio-age-row {
        justify-content: center;
    }
}

/* =============================================================
   Gauge refresh button
   ============================================================= */
.nppp-ratio-refresh {
    position: absolute;
    bottom: -9px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1.5px solid #c8c8c8;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 1;
    z-index: 10;
    box-shadow: 0 2px 5px rgba(0,0,0,0.14);
    line-height: 1;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.nppp-ratio-refresh:hover {
    background: #f0f0f0;
    border-color: #888;
    box-shadow: 0 3px 7px rgba(0,0,0,0.2);
    transform: translateX(-50%) scale(1.1);
}

.nppp-ratio-refresh .dashicons {
    font-size: 15px;
    width: 15px;
    height: 15px;
    color: #555;
    line-height: 1;
    margin: 0;
}

/* Icon spins while the AJAX directory scan is running */
.nppp-ratio-refresh.nppp-refreshing .dashicons {
    animation: nppp-spin 0.8s linear infinite;
}

/* Dim the arc while loading so user sees something is happening */
.nppp-ratio-strip.nppp-ratio-loading .nppp-gauge-progress {
    opacity: 0.25;
    transition: opacity 0.25s ease;
}

/* Arc dims when data is stale >30 min */
.nppp-gauge-progress.nppp-gauge-stale {
    opacity: 0.35;
    transition: opacity 0.4s ease;
}

/* Refresh button pulses when data is stale >30 min */
.nppp-ratio-refresh.nppp-btn-pulse {
    animation: nppp-btn-pulse 2s ease-in-out infinite;
    border-color: #f0a500;
}
.nppp-ratio-refresh.nppp-btn-pulse .dashicons {
    color: #f0a500;
}

@keyframes nppp-btn-pulse {
    0%, 100% { box-shadow: 0 0 0 0   rgba(240,165,0,0.5); }
    50%       { box-shadow: 0 0 0 6px rgba(240,165,0,0);   }
}

/* Age badge turns amber */
.nppp-ratio-age.nppp-age-warn {
    background: #fff8e6;
    border-color: #f0a500;
    color: #b07800;
}
