/* Contexa Analytics Dashboard — Platform-style design */

/* Reset WordPress admin styles within our dashboard */
.contexa-dashboard {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #1a1a2e;
    max-width: 1400px;
}

.contexa-dashboard * {
    box-sizing: border-box;
}

/* Page header */
.contexa-dashboard h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0 0 4px;
    color: #0f0f23;
}

.contexa-dashboard .subtitle {
    color: #64748b;
    font-size: 14px;
    margin: 0 0 24px;
}

/* Tab navigation — pill style like platform */
.contexa-tabs {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 24px;
    width: fit-content;
}

.contexa-tabs a {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.15s;
}

.contexa-tabs a:hover {
    color: #1a1a2e;
    background: #e2e8f0;
}

.contexa-tabs a.active {
    background: #fff;
    color: #0f0f23;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-weight: 600;
}

/* Card grid */
.contexa-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.contexa-card-grid.cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.contexa-card-grid.cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.contexa-card-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Card */
.contexa-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: box-shadow 0.15s;
}

.contexa-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.contexa-card .card-label {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.contexa-card .card-label .tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid #cbd5e1;
    font-size: 10px;
    color: #94a3b8;
    cursor: help;
    position: relative;
}

.contexa-card .card-label .tip:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    font-size: 11px;
    font-weight: 400;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    max-width: 250px;
    white-space: normal;
    z-index: 100;
    line-height: 1.4;
}

.contexa-card .card-value {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.contexa-card .card-value .unit {
    font-size: 14px;
    font-weight: 400;
    color: #64748b;
}

.contexa-card .card-sub {
    font-size: 12px;
    color: #94a3b8;
    margin: 4px 0 0;
}

/* Score colors */
.score-excellent { color: #16a34a; }
.score-good { color: #2563eb; }
.score-fair { color: #0891b2; }
.score-warning { color: #d97706; }
.score-poor { color: #dc2626; }

/* Section titles */
.contexa-dashboard h2 {
    font-size: 20px;
    font-weight: 700;
    margin: 32px 0 16px;
    color: #0f0f23;
    letter-spacing: -0.3px;
}

.contexa-dashboard h2:first-child {
    margin-top: 0;
}

.contexa-dashboard h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 24px 0 12px;
    color: #1e293b;
}

/* Section card (wraps a section like demand intel) */
.contexa-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.contexa-section .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.contexa-section .section-title {
    font-size: 16px;
    font-weight: 600;
    color: #0f0f23;
    margin: 0;
}

.contexa-section .section-subtitle {
    font-size: 13px;
    color: #94a3b8;
    margin: 2px 0 0;
}

/* Tables */
.contexa-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.contexa-table thead th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.contexa-table thead th:hover {
    color: #1e293b;
}

.contexa-table thead th.sort-asc::after { content: " \25B2"; font-size: 9px; }
.contexa-table thead th.sort-desc::after { content: " \25BC"; font-size: 9px; }

.contexa-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.contexa-table tbody tr:hover {
    background: #f8fafc;
}

.contexa-table .text-right {
    text-align: right;
}

.contexa-table .text-muted {
    color: #94a3b8;
}

.contexa-table .font-medium {
    font-weight: 500;
}

.contexa-table .font-bold {
    font-weight: 700;
}

/* Trend indicators */
.trend-up { color: #16a34a; font-weight: 600; }
.trend-down { color: #dc2626; font-weight: 600; }
.trend-stable { color: #94a3b8; }

/* Insights cards */
.contexa-insight {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 10px;
    border-left: 4px solid #2563eb;
}

.contexa-insight.critical { border-left-color: #dc2626; }
.contexa-insight.high { border-left-color: #d97706; }
.contexa-insight.medium { border-left-color: #2563eb; }
.contexa-insight.info { border-left-color: #64748b; }

.contexa-insight .insight-title {
    font-weight: 600;
    font-size: 14px;
    color: #0f0f23;
    margin: 0 0 4px;
}

.contexa-insight .insight-desc {
    font-size: 13px;
    color: #64748b;
    margin: 0 0 4px;
}

.contexa-insight .insight-action {
    font-size: 12px;
    color: #2563eb;
    margin: 0;
}

/* Funnel */
.contexa-funnel {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
    flex-wrap: wrap;
}

.contexa-funnel-step {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 14px 24px;
    text-align: center;
    min-width: 100px;
}

.contexa-funnel-step .num {
    font-size: 24px;
    font-weight: 700;
    color: #0f0f23;
    display: block;
}

.contexa-funnel-step .label {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contexa-funnel-arrow {
    font-size: 18px;
    color: #cbd5e1;
}

.contexa-funnel-rates {
    font-size: 13px;
    color: #64748b;
    margin: 4px 0 0;
}

/* Empty state */
.contexa-empty {
    text-align: center;
    padding: 48px 24px;
    background: #f8fafc;
    border: 1px dashed #e2e8f0;
    border-radius: 12px;
    margin: 16px 0;
}

.contexa-empty p {
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

/* Loading spinner */
.contexa-loading {
    text-align: center;
    padding: 60px 24px;
}

.contexa-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: contexa-spin 0.6s linear infinite;
    margin: 0 auto 12px;
}

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

.contexa-loading p {
    color: #94a3b8;
    font-size: 14px;
    margin: 0;
}

/* Error */
.contexa-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 16px 20px;
    color: #991b1b;
    font-size: 14px;
}

/* Login form override */
.contexa-dashboard .notice-warning {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #f59e0b;
}

/* Period selector pills */
.contexa-period-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
}

.contexa-period-selector .label {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    margin-right: 4px;
}

.contexa-period-selector .pill {
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.contexa-period-selector .pill:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.contexa-period-selector .pill.active {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
}

/* Settings rows */
.contexa-setting-row {
    padding: 0;
}

.contexa-setting-label {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 10px;
}

.contexa-setting-desc {
    font-size: 12px;
    color: #94a3b8;
    margin: 4px 0 0;
}

.contexa-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.contexa-toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
}

/* Checkbox grid for post types */
.contexa-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
}

.contexa-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
    color: #1e293b;
}

.contexa-checkbox-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.contexa-checkbox-item input:checked ~ span {
    font-weight: 500;
}

.contexa-checkbox-slug {
    font-size: 11px;
    color: #94a3b8;
    margin-left: auto;
}

/* Inputs */
.contexa-input {
    width: 100%;
    max-width: 400px;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    color: #1e293b;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.contexa-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.contexa-input[type="number"] {
    max-width: 120px;
}

.contexa-input::placeholder {
    color: #94a3b8;
}

/* Buttons */
.contexa-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.contexa-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.contexa-btn-primary {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
}

.contexa-btn-primary:hover:not(:disabled) {
    background: #0f172a;
}

.contexa-btn-secondary {
    background: #f1f5f9;
    color: #1e293b;
    border-color: #e2e8f0;
}

.contexa-btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
}

/* DataTables overrides for contexa-dashboard */
.contexa-dashboard .dataTables_wrapper {
    font-family: inherit;
}

.contexa-dashboard .dataTables_filter input {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    outline: none;
}

.contexa-dashboard .dataTables_filter input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.contexa-dashboard .dataTables_length select {
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 13px;
}

.contexa-dashboard .dataTables_info {
    font-size: 13px;
    color: #64748b;
}

.contexa-dashboard .dataTables_paginate .paginate_button {
    border-radius: 6px !important;
    font-size: 13px;
}

/* Log type badges */
.contexa-log-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.contexa-log-type.error {
    background: #fef2f2;
    color: #dc2626;
}

.contexa-log-type.warning {
    background: #fffbeb;
    color: #d97706;
}

.contexa-log-type.notice,
.contexa-log-type.info {
    background: #f0f9ff;
    color: #2563eb;
}

/* Responsive */
@media (max-width: 1200px) {
    .contexa-card-grid.cols-4,
    .contexa-card-grid.cols-5 {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .contexa-card-grid {
        grid-template-columns: 1fr 1fr;
    }
    .contexa-funnel {
        flex-direction: column;
        align-items: stretch;
    }
    .contexa-funnel-arrow {
        transform: rotate(90deg);
        text-align: center;
    }
}
