/**
 * CapiFlow — Admin Styles.
 *
 * Covers: Settings page, Dashboard, Order columns, Orders metabox,
 * Debug console, System health, Setup wizard.
 * All selectors use capiflow- prefix (not wc-capi-).
 *
 * @package CapiFlow
 */

/* ═══════════════════════════════════════════
   Shared / Base
   ═══════════════════════════════════════════ */

.capiflow-pro-chip {
    display: inline-block;
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 20px;
    margin-left: 10px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.capiflow-pro-badge {
    display: inline-block;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    color: #92400e;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════
   Settings Page
   ═══════════════════════════════════════════ */

.capiflow-settings-wrap {
    max-width: 900px;
}

.capiflow-settings-title {
    font-size: 24px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.capiflow-logo-icon {
    font-size: 22px;
}

.capiflow-tabs {
    margin-bottom: 0 !important;
}

.capiflow-tab-content {
    background: #fff;
    border: 1px solid #c3c4c7;
    border-top: none;
    padding: 24px;
    border-radius: 0 0 4px 4px;
}

.capiflow-pro-teaser {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.capiflow-pro-teaser p {
    margin: 0 0 10px;
    color: #78350f;
    font-size: 13px;
}

.capiflow-test-result {
    display: inline-block;
    margin-left: 10px;
    font-size: 13px;
    vertical-align: middle;
}

/* ═══════════════════════════════════════════
   Order Column Badges
   ═══════════════════════════════════════════ */

.column-capiflow_sync,
.column-capiflow_risk {
    width: 50px !important;
    text-align: center !important;
}

.capiflow-badge {
    display: inline-block;
    font-size: 12px;
    line-height: 1.4;
}

.capiflow-badge--sent       { color: #16a34a; }
.capiflow-badge--pending    { color: #9ca3af; }
.capiflow-badge--high-risk  { color: #dc2626; font-weight: 700; }
.capiflow-badge--medium-risk { color: #f59e0b; }
.capiflow-badge--low-risk   { color: #16a34a; }
.capiflow-badge--clean      { color: #9ca3af; }
.capiflow-badge--neutral    { color: #9ca3af; }

/* ═══════════════════════════════════════════
   Dashboard Page
   ═══════════════════════════════════════════ */

.capiflow-dashboard {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ═══════════════════════════════════════════
   Order Metabox
   ═══════════════════════════════════════════ */

.capiflow-timeline {
    font-size: 12px;
}

/* ═══════════════════════════════════════════
   Debug Console
   ═══════════════════════════════════════════ */

.capiflow-debug-console {
    /* container */
}

.capiflow-debug-tabs {
    margin-bottom: 15px;
    display: flex;
    gap: 6px;
}

.capiflow-debug-tab {
    cursor: pointer;
}

.capiflow-debug-tab.active,
.capiflow-debug-tab:focus {
    background: #2271b1 !important;
    color: #fff !important;
    border-color: #2271b1 !important;
}

.capiflow-debug-panel {
    display: none;
}

.capiflow-debug-panel.active {
    display: block;
}

.capiflow-debug-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.capiflow-debug-filters select {
    min-width: 140px;
}

/* Debug table */
#capiflow-queue-table,
#capiflow-logs-table {
    font-size: 12px;
    table-layout: fixed;
}

#capiflow-queue-table td,
#capiflow-logs-table td {
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

/* ═══════════════════════════════════════════
   System Health
   ═══════════════════════════════════════════ */

.capiflow-system-health table {
    margin-bottom: 20px;
}

.capiflow-system-health code {
    background: #f0f0f1;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
}

/* ═══════════════════════════════════════════
   Setup Wizard
   ═══════════════════════════════════════════ */

.capiflow-wizard-wrap {
    max-width: 680px;
    margin: 24px auto;
}

/* ═══════════════════════════════════════════
   WP Dashboard Widget
   ═══════════════════════════════════════════ */

#capiflow_dashboard_widget .inside {
    padding: 0 !important;
    margin: 0 !important;
}

.capiflow-widget {
    padding: 0;
}

/* ═══════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════ */

@media (max-width: 782px) {
    .capiflow-debug-filters {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD — Dark theme, cards
   ═══════════════════════════════════════════════════════════════ */

.capiflow-dashboard {
    background: #1a1a2e;
    color: #e0e0e0;
    padding: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    margin: 0 0 -10px -20px;
    width: calc(100% + 20px);
    box-sizing: border-box;
    overflow-x: hidden;
}
.capiflow-dashboard h1,
.capiflow-dashboard h2,
.capiflow-dashboard h3 { color: #fff; margin-top: 0; }

.capiflow-card {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px;
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.capiflow-dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}

.capiflow-period-select {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.15);
    color: #e0e0e0;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.capiflow-refresh-btn {
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    color: #e0e0e0;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background .2s;
}
.capiflow-refresh-btn:hover { background: rgba(255,255,255,.18); }

/* ═══════════════════════════════════════════════════════════════
   KPI GRID — 4-column responsive
   ═══════════════════════════════════════════════════════════════ */

.capiflow-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.capiflow-kpi {
    background: rgba(255,255,255,.05);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 10px;
    padding: 18px 20px;
    min-height: 90px;
}
.capiflow-kpi-label {
    font-size: 11px;
    color: rgba(255,255,255,.5);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 6px;
}
.capiflow-kpi-value {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
}
.capiflow-kpi-sub   { font-size: 12px; color: rgba(255,255,255,.4); margin-top: 4px; }
.capiflow-kpi-trend-up   { color: #10b981; }
.capiflow-kpi-trend-down { color: #f87171; }

@media (max-width: 1100px) { .capiflow-kpi-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 600px)  { .capiflow-kpi-grid { grid-template-columns: 1fr; } }

/* ═══════════════════════════════════════════════════════════════
   SKELETON SHIMMER
   ═══════════════════════════════════════════════════════════════ */

.capiflow-skeleton {
    background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.04) 75%);
    background-size: 200% 100%;
    animation: capiflow-shimmer 1.6s infinite;
    border-radius: 8px;
    min-height: 80px;
}
.capiflow-loading-row {
    height: 14px;
    border-radius: 4px;
    margin-bottom: 8px;
    background: linear-gradient(90deg, rgba(255,255,255,.04) 25%, rgba(255,255,255,.09) 50%, rgba(255,255,255,.04) 75%);
    background-size: 200% 100%;
    animation: capiflow-shimmer 1.6s infinite;
}
@keyframes capiflow-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════════════════
   LIVE EVENT TERMINAL
   ═══════════════════════════════════════════════════════════════ */

.capiflow-terminal {
    background: #0f0f23;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Courier New', Consolas, monospace;
    font-size: 12px;
    color: #00ff41;
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid rgba(0,255,65,.1);
}
.capiflow-terminal::-webkit-scrollbar       { width: 4px; }
.capiflow-terminal::-webkit-scrollbar-track { background: transparent; }
.capiflow-terminal::-webkit-scrollbar-thumb { background: rgba(0,255,65,.3); border-radius: 2px; }

.capiflow-terminal-entry {
    padding: 3px 0;
    border-bottom: 1px solid rgba(0,255,65,.07);
    line-height: 1.5;
}
.capiflow-terminal-entry:last-child { border-bottom: none; }
.capiflow-terminal-entry .t-time  { color: rgba(0,255,65,.4); margin-right: 8px; }
.capiflow-terminal-entry .t-ok    { color: #00ff41; }
.capiflow-terminal-entry .t-fail  { color: #ff5555; }
.capiflow-terminal-entry .t-ms    { color: rgba(0,255,65,.5); margin-left: 6px; }

.capiflow-terminal-cursor {
    display: inline-block;
    width: 8px;
    height: 14px;
    background: #00ff41;
    vertical-align: middle;
    animation: capiflow-blink 1s step-end infinite;
}
@keyframes capiflow-blink { 0%,100% { opacity:1; } 50% { opacity:0; } }

/* ═══════════════════════════════════════════════════════════════
   ORDER LIST — Row borders + Event Status column
   ═══════════════════════════════════════════════════════════════ */

.capiflow-row-safe     td:first-child { border-left: 4px solid #10b981 !important; }
.capiflow-row-caution  td:first-child { border-left: 4px solid #f59e0b !important; }
.capiflow-row-danger   td:first-child { border-left: 4px solid #dc2626 !important; }
.capiflow-row-critical td:first-child { border-left: 4px solid #dc2626 !important; background: rgba(220,38,38,.04) !important; }
.capiflow-row-neutral  td:first-child { border-left: 4px solid #e5e7eb !important; }

.capiflow-event-status {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    line-height: 1.4;
}
.capiflow-es-sent    { background: #dcfce7; color: #166534; }
.capiflow-es-queued  { background: #fef3c7; color: #92400e; }
.capiflow-es-failed  { background: #fee2e2; color: #991b1b; }
.capiflow-es-pending { background: #f1f5f9; color: #94a3b8; }

/* Upsell hint icon on Event Status column header (FREE only) */
.capiflow-pro-hint {
    opacity: 0.6;
    transition: opacity 0.2s;
}
.capiflow-pro-hint:hover {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY STATES (Dashboard)
   ═══════════════════════════════════════════════════════════════ */

.capiflow-empty-state {
    text-align: center;
    padding: 28px 20px;
    color: rgba(255,255,255,.3);
}
.capiflow-empty-state .capiflow-empty-icon { font-size: 36px; display: block; margin-bottom: 10px; opacity: .5; }
.capiflow-empty-state p  { font-size: 13px; margin: 0 0 12px; color: rgba(255,255,255,.4); }
.capiflow-empty-state a  { font-size: 12px; color: #60a5fa; }

/* ═══════════════════════════════════════════════════════════════
   DISMISS BUTTON (Widget CTA)
   ═══════════════════════════════════════════════════════════════ */

.capiflow-dismiss {
    position: absolute;
    top: 6px;
    right: 10px;
    cursor: pointer;
    font-size: 18px;
    color: #92400e;
    line-height: 1;
    opacity: .65;
    background: none;
    border: none;
    padding: 0;
    transition: opacity .15s;
}
.capiflow-dismiss:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   SETUP SUCCESS NOTICE
   ═══════════════════════════════════════════════════════════════ */

.capiflow-setup-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-left: 4px solid #16a34a;
    border-radius: 8px;
    padding: 14px 48px 14px 18px;
    margin-bottom: 20px;
    position: relative;
    font-size: 13px;
    color: #166534;
}
.capiflow-setup-success strong { display: block; margin-bottom: 4px; }

/* ═══════════════════════════════════════════════════════════════
   CHARTS GRID (Dashboard)
   ═══════════════════════════════════════════════════════════════ */

.capiflow-charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.capiflow-chart-wrap {
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 10px;
    padding: 20px;
    min-width: 0; /* Prevent Chart.js canvas from overflowing grid */
}
.capiflow-chart-wrap h3 {
    font-size: 13px;
    color: rgba(255,255,255,.7);
    margin: 0 0 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
}
@media (max-width: 900px) {
    .capiflow-charts-grid { grid-template-columns: 1fr; }
    .capiflow-dashboard-header { flex-direction: column; align-items: flex-start; }
    .capiflow-dashboard-grid { grid-template-columns: 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════════
   DASHBOARD GRIDS — Layouts for widget sections
   ═══════════════════════════════════════════════════════════════ */

.capiflow-dashboard-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}
.capiflow-dashboard-grid--two {
    grid-template-columns: 1fr 1fr;
}
.capiflow-dashboard-grid--wide-side {
    grid-template-columns: 2fr 1fr;
}
@media (max-width: 768px) {
    .capiflow-dashboard-grid--two,
    .capiflow-dashboard-grid--wide-side {
        grid-template-columns: 1fr;
    }
}

