/* ============================================================
   SMA Analytics Dashboard
   ============================================================ */

.sma-ad-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0 48px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: #1a1e2e;
}

/* ── Header ── */
.sma-ad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e1e6ef;
}

.sma-ad-title {
    font-size: 22px !important;
    font-weight: 700 !important;
    color: #003087 !important;
    margin: 0 !important;
}

.sma-ad-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sma-ad-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

.sma-ad-select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

.sma-ad-refresh-btn {
    background: #003087;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.sma-ad-refresh-btn:hover {
    background: #00205f;
}

.sma-ad-refresh-btn.is-loading {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ── Custom date range picker ── */
.sma-ad-custom-range {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sma-ad-date-input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    background: #fff;
    color: #1a1e2e;
    cursor: pointer;
    transition: border-color 0.15s;
}

.sma-ad-date-input:focus {
    outline: none;
    border-color: #003087;
    box-shadow: 0 0 0 2px rgba(0, 48, 135, 0.12);
}

.sma-ad-date-sep {
    color: #9ca3af;
    font-size: 13px;
    flex-shrink: 0;
}

.sma-ad-apply-btn {
    background: #0e7490;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.sma-ad-apply-btn:hover {
    background: #0c5f74;
}

/* ── Live bar ── */
.sma-ad-live-bar {
    background: #fff;
    border: 1px solid #e1e6ef;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 20px;
    position: relative;
}

.sma-ad-live-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.sma-ad-live-dot {
    width: 9px;
    height: 9px;
    background: #16a34a;
    border-radius: 50%;
    flex-shrink: 0;
    animation: sma-pulse 1.8s infinite;
}

@keyframes sma-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.85); }
}

.sma-ad-live-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #16a34a;
}

.sma-ad-live-count {
    font-size: 20px;
    font-weight: 800;
    color: #1a1e2e;
    line-height: 1;
}

.sma-ad-live-sub {
    font-size: 13px;
    color: #6b7280;
}

.sma-ad-live-updated {
    position: absolute;
    top: 14px;
    right: 20px;
    font-size: 11px;
    color: #9ca3af;
}

.sma-ad-live-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sma-ad-live-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 5px 10px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 13px;
}

.sma-ad-live-page {
    flex: 1;
    font-weight: 500;
    color: #1a1e2e;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sma-ad-live-who {
    color: #6b7280;
    font-size: 12px;
    white-space: nowrap;
}

.sma-ad-live-users {
    font-size: 12px;
    font-weight: 600;
    color: #003087;
    white-space: nowrap;
}

.sma-ad-live-loading,
.sma-ad-live-empty {
    font-size: 13px;
    color: #9ca3af;
    font-style: italic;
}

.sma-ad-live-error {
    font-size: 13px;
    color: #b91c1c;
}

/* ── Tabs ── */
.sma-ad-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e1e6ef;
    margin-bottom: 0;
}

.sma-ad-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s, border-color 0.15s;
}

.sma-ad-tab:hover {
    color: #003087;
    background: #f5f7fa;
}

.sma-ad-tab.is-active {
    color: #003087;
    border-bottom-color: #003087;
    background: #fff;
}

/* ── Panels ── */
.sma-ad-panels {
    background: #fff;
    border: 1px solid #e1e6ef;
    border-top: none;
    border-radius: 0 0 10px 10px;
    min-height: 200px;
}

.sma-ad-panel {
    display: none;
    padding: 24px;
}

.sma-ad-panel.is-active {
    display: block;
}

.sma-ad-lazy-msg {
    color: #9ca3af;
    font-style: italic;
    padding: 32px 0;
    text-align: center;
}

/* ── 50/50 Promotion tab (native render) ── */
.sma-ad-promo-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.sma-promo-table code {
    font-size: 12px;
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
}

.sma-promo-table th.num,
.sma-promo-table td.num {
    text-align: right;
}

.sma-promo-table td.total strong {
    color: #003087;
}

/* ── Summary cards ── */
.sma-ad-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 700px) {
    .sma-ad-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

.sma-ad-card {
    background: #fff;
    border: 1px solid #e1e6ef;
    border-top: 3px solid #e1e6ef;
    border-radius: 10px;
    padding: 20px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sma-ad-card--partners  { border-top-color: #003087; }
.sma-ad-card--sessions  { border-top-color: #16a34a; }
.sma-ad-card--pageviews { border-top-color: #7c3aed; }
.sma-ad-card--logins    { border-top-color: #d97706; }

.sma-ad-card-value {
    font-size: 30px;
    font-weight: 800;
    color: #1a1e2e;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

.sma-ad-card-label {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* ── Table ── */
.sma-ad-table-wrap {
    overflow-x: auto;
}

.sma-ad-count {
    font-size: 12px;
    color: #9ca3af;
    margin: 0 0 12px;
}

.sma-ad-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sma-ad-table thead tr {
    background: #f8fafc;
}

.sma-ad-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    border-bottom: 2px solid #e1e6ef;
    white-space: nowrap;
}

.sma-ad-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f2f7;
    vertical-align: middle;
}

.sma-ad-table tbody tr:last-child td {
    border-bottom: none;
}

.sma-ad-table tbody tr:hover td {
    background: #f9fafb;
}

.sma-ad-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: #374151;
}

.sma-ad-date {
    white-space: nowrap;
    color: #6b7280;
}

.sma-ad-path a {
    color: #003087;
    text-decoration: none;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 12px;
}

.sma-ad-path a:hover {
    text-decoration: underline;
}

.sma-ad-file {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Badges ── */
.sma-ad-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: #eff6ff;
    color: #1d4ed8;
    white-space: nowrap;
}

.sma-ad-badge--resource { background: #dcfce7; color: #15803d; }
.sma-ad-badge--course   { background: #ede9fe; color: #6d28d9; }
.sma-ad-badge--video    { background: #fef3c7; color: #92400e; }
.sma-ad-badge--support  { background: #fee2e2; color: #b91c1c; }

.sma-ad-event-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'SF Mono', Consolas, monospace;
    background: #f3f4f6;
    color: #374151;
}

/* ── Expandable rows ── */
.sma-ad-hint {
    color: #9ca3af;
    font-style: italic;
}

.sma-ad-table--expandable .sma-ad-user-row {
    cursor: pointer;
}

.sma-ad-table--expandable .sma-ad-user-row:hover td {
    background: #eff6ff;
}

.sma-ad-table--expandable .sma-ad-user-row.is-expanded td {
    background: #eff6ff;
    font-weight: 600;
}

.sma-ad-toggle-cell {
    width: 28px;
    text-align: center;
    color: #9ca3af;
    font-size: 10px;
}

.sma-ad-toggle-icon {
    display: inline-block;
    transition: transform 0.15s;
}

.sma-ad-detail-row td {
    padding: 0 !important;
    border-bottom: 2px solid #e1e6ef !important;
}

.sma-ad-detail-cell {
    background: #f8fafc !important;
}

.sma-ad-detail-inner {
    padding: 16px 24px 20px 48px;
}

.sma-ad-detail-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    color: #374151;
}

.sma-ad-detail-sub {
    color: #9ca3af;
    font-weight: 400;
    font-size: 12px;
}

.sma-ad-table--detail {
    font-size: 12px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e1e6ef;
    overflow: hidden;
}

.sma-ad-table--detail th {
    font-size: 10px;
    padding: 7px 10px;
    background: #f1f5f9;
}

.sma-ad-table--detail td {
    padding: 7px 10px;
}

.sma-ad-detail-loading {
    color: #9ca3af;
    font-style: italic;
    font-size: 13px;
}

.sma-ad-detail-error {
    color: #b91c1c;
    font-size: 13px;
}

.sma-ad-detail-empty {
    color: #9ca3af;
    font-style: italic;
    font-size: 13px;
}

/* ── Multi-company expandable cell ── */
.sma-ad-multi-toggle {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #003087;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    line-height: 1.4;
}

.sma-ad-multi-toggle:hover {
    text-decoration: underline;
}

.sma-ad-multi-caret {
    font-size: 10px;
    display: inline-block;
    transition: transform 0.15s;
}

.sma-ad-multi-toggle[aria-expanded="true"] .sma-ad-multi-caret {
    transform: rotate(180deg);
}

.sma-ad-multi-list {
    display: none;
    list-style: none;
    margin: 6px 0 0;
    padding: 6px 0 0;
    border-top: 1px solid #e1e6ef;
    flex-direction: column;
    gap: 5px;
}

.sma-ad-multi-list.is-open {
    display: flex;
}

.sma-ad-multi-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
}

.sma-ad-multi-name {
    color: #374151;
    font-weight: 500;
}

.sma-ad-multi-dl {
    color: #9ca3af;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

/* ── States ── */
.sma-ad-error {
    padding: 14px 18px;
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    border-radius: 0 6px 6px 0;
    color: #7f1d1d;
    font-size: 13px;
    margin-bottom: 16px;
}

.sma-ad-empty {
    text-align: center;
    color: #9ca3af;
    padding: 40px 0;
    font-style: italic;
}

.sma-ad-spinner {
    text-align: center;
    padding: 48px;
    color: #9ca3af;
    font-size: 24px;
}
