/* Site Protection Widget Styles */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* Base Container */
.sp-dashboard {
    --sp-font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    font-family: var(--sp-font-family);
    background: var(--sp-container-bg, #ffffff);
    border-radius: var(--sp-container-radius, 16px);
    padding: 24px;
    max-width: 420px;
    margin: 0 auto;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

/* Header */
.sp-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.sp-badge {
    width: 40px;
    height: 40px;
    background: var(--sp-badge-color, #22c55e);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.sp-badge::before {
    content: '';
    position: absolute;
    inset: -3px;
    background: var(--sp-badge-color, #22c55e);
    opacity: 0.2;
    border-radius: 12px;
}

.sp-badge svg {
    width: 22px;
    height: 22px;
    color: #ffffff;
    position: relative;
    z-index: 1;
}

.sp-title {
    font-family: var(--sp-font-family);
    font-size: 18px;
    font-weight: 700;
    color: var(--sp-title-color, #1e293b);
    margin: 0;
    line-height: 1.3;
}

/* Chart Container */
.sp-chart-container {
    margin-bottom: 16px;
}

.sp-chart-wrapper {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.sp-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0 0 4px 0;
    min-width: 24px;
    text-align: right;
}

.sp-y-axis span {
    font-size: 11px;
    font-weight: 500;
    color: var(--sp-axis-color, #94a3b8);
    line-height: 1;
}

.sp-chart-area {
    flex: 1;
    height: 160px;
    position: relative;
    background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.01) 100%);
    border-radius: 8px;
}

.sp-chart-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.sp-grid-line {
    stroke: var(--sp-grid-color, #e2e8f0);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.sp-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sp-line-1 {
    stroke: var(--sp-line1-color, #22c55e);
}

.sp-line-2 {
    stroke: var(--sp-line2-color, #ef4444);
}

.sp-endpoint {
    opacity: 0;
}

.sp-endpoint-1 {
    fill: var(--sp-line1-color, #22c55e);
}

.sp-endpoint-2 {
    fill: var(--sp-line2-color, #ef4444);
}

/* Legend */
.sp-legend {
    display: flex;
    justify-content: center;
    gap: 24px;
}

.sp-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.sp-legend-line-1 {
    background: var(--sp-line1-color, #22c55e);
}

.sp-legend-line-2 {
    background: var(--sp-line2-color, #ef4444);
}

.sp-legend-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--sp-title-color, #1e293b);
}

/* Alert Card */
.sp-alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    background: var(--sp-alert-bg, #fefce8);
    border: 1px solid var(--sp-alert-border, #fef08a);
    border-radius: 12px;
    margin-top: 16px;
}

.sp-alert-content {
    display: flex;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.sp-alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    color: var(--sp-alert-icon, #eab308);
    margin-top: 2px;
}

.sp-alert-icon svg {
    width: 100%;
    height: 100%;
}

.sp-alert-message {
    font-size: 13px;
    font-weight: 400;
    color: var(--sp-alert-text, #1e293b);
    margin: 0;
    line-height: 1.5;
}

.sp-alert-button {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    background: var(--sp-button-bg, #2563eb);
    color: var(--sp-button-text, #ffffff);
    border: none;
    border-radius: 8px;
    font-family: var(--sp-font-family);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.sp-alert-button:hover {
    background: var(--sp-button-hover-bg, #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    color: var(--sp-button-text, #ffffff);
    text-decoration: none;
}

.sp-alert-button:active {
    transform: translateY(0);
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Initial states for animated elements */
.sp-animated .sp-header {
    opacity: 0;
    transform: translateY(-10px);
}

.sp-animated .sp-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.sp-animated .sp-legend {
    opacity: 0;
}

.sp-animated .sp-alert {
    opacity: 0;
    transform: translateY(20px);
}

.sp-animated .sp-endpoint {
    opacity: 0;
    transform: scale(0);
}

/* Animation states when in view */
.sp-animated.sp-in-view .sp-header {
    animation: spFadeInDown 0.6s ease forwards;
}

.sp-animated.sp-in-view .sp-badge {
    animation: spPulse 2s ease-in-out infinite 0.6s;
}

.sp-animated.sp-in-view .sp-line-1 {
    animation: spDrawLine var(--sp-chart-duration, 2000ms) cubic-bezier(0.4, 0, 0.2, 1) 0.4s forwards;
}

.sp-animated.sp-in-view .sp-line-2 {
    animation: spDrawLine var(--sp-chart-duration, 2000ms) cubic-bezier(0.4, 0, 0.2, 1) 0.6s forwards;
}

.sp-animated.sp-in-view .sp-endpoint-1 {
    animation: spEndpointPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: calc(var(--sp-chart-duration, 2000ms) + 0.4s);
}

.sp-animated.sp-in-view .sp-endpoint-2 {
    animation: spEndpointPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: calc(var(--sp-chart-duration, 2000ms) + 0.6s);
}

.sp-animated.sp-in-view .sp-legend {
    animation: spFadeIn 0.5s ease forwards;
    animation-delay: calc(var(--sp-chart-duration, 2000ms) * 0.5);
}

.sp-animated.sp-in-view .sp-alert {
    animation: spSlideInUp 0.5s ease forwards;
    animation-delay: var(--sp-alert-delay, 1500ms);
}

/* Keyframes */
@keyframes spFadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes spSlideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spDrawLine {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes spEndpointPop {
    from {
        opacity: 0;
        transform: scale(0);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
    }
}

/* Alert Icon Shake Animation */
.sp-animated.sp-in-view .sp-alert-icon {
    animation: spShake 0.5s ease forwards;
    animation-delay: calc(var(--sp-alert-delay, 1500ms) + 0.3s);
}

@keyframes spShake {
    0%, 100% { transform: rotate(0deg); }
    20% { transform: rotate(-8deg); }
    40% { transform: rotate(8deg); }
    60% { transform: rotate(-4deg); }
    80% { transform: rotate(4deg); }
}

/* Hover Effects */
.sp-badge {
    transition: transform 0.3s ease;
}

.sp-badge:hover {
    transform: scale(1.1);
}

.sp-alert {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sp-alert:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Line hover effect */
.sp-line {
    transition: stroke-width 0.2s ease;
}

.sp-chart-area:hover .sp-line {
    stroke-width: 3.5;
}

/* Responsive */
@media (max-width: 480px) {
    .sp-dashboard {
        padding: 20px 16px;
    }
    
    .sp-title {
        font-size: 16px;
    }
    
    .sp-chart-area {
        height: 140px;
    }
    
    .sp-alert {
        flex-direction: column;
        gap: 12px;
    }
    
    .sp-alert-button {
        width: 100%;
    }
    
    .sp-legend {
        gap: 16px;
    }
    
    .sp-legend-label {
        font-size: 11px;
    }
}

/* Elementor Editor Styles */
.elementor-editor-active .sp-animated .sp-header,
.elementor-editor-active .sp-animated .sp-legend,
.elementor-editor-active .sp-animated .sp-alert,
.elementor-editor-active .sp-animated .sp-endpoint {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

.elementor-editor-active .sp-animated .sp-line {
    stroke-dashoffset: 0 !important;
    animation: none !important;
}

.elementor-editor-active .sp-animated .sp-badge {
    animation: none !important;
}
