/**
 * Voxel AdRotate Sync - Stats Widget Styles
 */

/* Stats Grid */
.banner-stats-widget {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.banner-stats-widget h4 {
    margin: 0 0 15px;
    font-size: 16px;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    /* auto-fit so 3, 4, 5, 6 cards all flow nicely without squashing.
       Each card is at least 110px wide, expands to fill leftover space. */
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.stat-item {
    text-align: center;
    padding: 15px 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Period tabs */
.stats-period-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.stats-period-tabs button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.stats-period-tabs button:hover {
    background: #f5f5f5;
}

.stats-period-tabs button.active {
    background: #1a1a1a;
    color: #fff;
    border-color: #1a1a1a;
}

/* Schedule info */
.schedule-info {
    padding-top: 15px;
    border-top: 1px solid #eee;
    font-size: 14px;
    color: #555;
}

.schedule-info p {
    margin: 0;
}

.schedule-info .status-active {
    color: #22c55e;
    font-weight: 500;
}

.schedule-info .status-expired {
    color: #ef4444;
    font-weight: 500;
}

.schedule-info .status-pending {
    color: #f59e0b; /* amber — awaiting moderation */
    font-weight: 500;
}

.schedule-info .status-draft,
.schedule-info .status-private {
    color: #6b7280; /* slate — not visible to public */
    font-weight: 500;
}

.schedule-info .status-scheduled {
    color: #3b82f6; /* blue — start date in the future */
    font-weight: 500;
}

.schedule-info .status-trash {
    color: #ef4444;
    font-weight: 500;
    text-decoration: line-through;
}

/* Chart container — fixed height so a sparse bar chart doesn't balloon
   tall on wide screens. Chart.js fills this with maintainAspectRatio:false. */
.stats-chart-container {
    position: relative;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    height: 220px;
}

.stats-chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

@media (max-width: 600px) {
    .stats-chart-container { height: 180px; }
}

/* Inline stats format */
/* Inline mode used by the Elementor "Banner Stats" widget */
.stats-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    font-size: 14px;
}

.stats-inline .stat {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.stats-inline .stat-sep {
    display: inline-block;
    line-height: 1;
    user-select: none;
}

.stats-inline .stat-icon {
    width: 16px;
    height: 16px;
    opacity: 0.6;
}

/* List stats format
   The widget renders <ul class="stats-list"> — keep selectors in sync.
   Defaults are deliberately MINIMAL (no bullets, small padding) so the
   widget drops cleanly into Voxel listing-card templates. */
ul.stats-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

ul.stats-list li {
    padding: 4px 0;
    display: flex;
    justify-content: flex-start;
    gap: 6px;
}

ul.stats-list li strong {
    font-weight: 500;
}

/* Horizontal variant — opt-in via .stats-list--horizontal class.
   Renders items inline with a configurable gap, matching the compact
   look of inline mode while keeping the "label: value" structure. */
ul.stats-list.stats-list--horizontal {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
}

ul.stats-list.stats-list--horizontal li {
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Loading state */
.stats-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    color: #999;
}

.stats-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid #ddd;
    border-top-color: #1a1a1a;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stats-period-tabs {
        flex-wrap: wrap;
    }
}

/* ---------- Previous-campaigns history + reset ---------- */
.adrotate-stats-widget .stats-archived-note {
    margin-top: 10px;
    font-size: 12px;
    opacity: .65;
    text-align: center;
}
.adrotate-stats-widget .stats-reset-row {
    margin-top: 12px;
    text-align: center;
}
.adrotate-stats-widget .stats-reset-btn {
    appearance: none;
    border: 1px solid rgba(0, 0, 0, .18);
    background: transparent;
    color: inherit;
    border-radius: 8px;
    padding: 6px 14px;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background-color .15s ease, opacity .15s ease;
}
.adrotate-stats-widget .stats-reset-btn:hover { background: rgba(0, 0, 0, .05); }
.adrotate-stats-widget .stats-reset-btn[disabled] { opacity: .55; cursor: default; }

/* ---------- Device split (overlay stats) ---------- */
.adrotate-stats-widget .stats-devices {
    margin-top: 10px;
    font-size: 12px;
    opacity: .7;
    text-align: center;
}
