/**
 * Tespondo Connect – Admin Dashboard Styles
 *
 * @package Tespondo_Connect
 * @since   1.0.0
 */

/* ── Brand tokens ── */
:root {
    --tc-blue:       #0066FF;
    --tc-blue-dark:  #0052CC;
    --tc-blue-light: #E8F0FE;
    --tc-blue-50:    #F0F6FF;
    --tc-green:      #22C55E;
    --tc-green-bg:   #F0FDF4;
    --tc-amber:      #F59E0B;
    --tc-red:        #EF4444;
    --tc-red-bg:     #FEF2F2;
    --tc-text:       #111827;
    --tc-text-sec:   #6B7280;
    --tc-border:     #E5E7EB;
    --tc-bg:         #F9FAFB;
    --tc-card:       #FFFFFF;
    --tc-radius:     12px;
}

/* ── Reset WP admin styles ── */
#tespondo-wrap *,
#tespondo-wrap *::before,
#tespondo-wrap *::after {
    box-sizing: border-box;
}

/* ── Layout ── */
#tespondo-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    max-width: 1180px;
    padding: 28px 0 60px;
    color: var(--tc-text);
    -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.tc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}
.tc-header-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
}
.tc-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--tc-text);
    margin: 0;
    padding: 0;
    letter-spacing: -0.02em;
}
.tc-header .tc-badge {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 99px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.tc-badge.connected {
    background: var(--tc-green-bg);
    color: #15803D;
    border: 1px solid #BBF7D0;
}
.tc-badge.disconnected {
    background: var(--tc-red-bg);
    color: #DC2626;
    border: 1px solid #FECACA;
}
.tc-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.tc-badge.connected .tc-badge-dot { background: var(--tc-green); }
.tc-badge.disconnected .tc-badge-dot { background: var(--tc-red); }

/* ── Cards ── */
.tc-card {
    background: var(--tc-card);
    border-radius: var(--tc-radius);
    padding: 20px 24px;
    border: 1px solid var(--tc-border);
}
.tc-card h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--tc-text-sec);
    margin: 0 0 16px;
    padding: 0;
    border: none;
}

/* ── Stat grid ── */
.tc-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.tc-stat {
    background: var(--tc-card);
    border-radius: var(--tc-radius);
    border: 1px solid var(--tc-border);
    padding: 18px 20px;
    position: relative;
}
.tc-stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.tc-stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--tc-text-sec);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tc-stat-icon-wrap {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tc-stat-icon-wrap svg {
    width: 16px;
    height: 16px;
}
.tc-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--tc-text);
    line-height: 1;
    margin-bottom: 4px;
}
.tc-stat-sub {
    font-size: 12px;
    color: var(--tc-text-sec);
}

/* ── Two-column grid ── */
.tc-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 22px;
}
@media (max-width: 800px) {
    .tc-grid-2 { grid-template-columns: 1fr; }
}

/* ── Traffic source bars ── */
.tc-source-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.tc-source-label {
    font-size: 13px;
    font-weight: 500;
    min-width: 110px;
    color: var(--tc-text);
}
.tc-source-bar-wrap {
    flex: 1;
    background: var(--tc-blue-50);
    border-radius: 99px;
    height: 6px;
    overflow: hidden;
}
.tc-source-bar {
    height: 100%;
    border-radius: 99px;
    background: var(--tc-blue);
    transition: width 0.5s ease;
}
.tc-source-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--tc-text-sec);
    min-width: 32px;
    text-align: right;
}
.tc-source-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Recent chats ── */
.tc-chat-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 22px;
}
.tc-chat-item {
    background: var(--tc-card);
    border-radius: var(--tc-radius);
    border: 1px solid var(--tc-border);
    overflow: hidden;
}
.tc-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.tc-chat-header:hover { background: var(--tc-bg); }
.tc-chat-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--tc-blue);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tc-chat-avatar.call { background: #3B82F6; }
.tc-chat-meta { flex: 1; min-width: 0; }
.tc-chat-name { font-size: 13px; font-weight: 600; color: var(--tc-text); }
.tc-chat-preview {
    font-size: 12px;
    color: var(--tc-text-sec);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 380px;
}
.tc-chat-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.tc-chat-time { font-size: 11px; color: var(--tc-text-sec); }
.tc-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tc-pill.active  { background: #DCFCE7; color: #15803D; }
.tc-pill.call    { background: #DBEAFE; color: #1E40AF; }
.tc-pill.chat    { background: var(--tc-blue-light); color: var(--tc-blue-dark); }

/* ── Expandable chat bubble thread ── */
.tc-chat-thread {
    display: none;
    padding: 4px 16px 14px 60px;
    border-top: 1px solid var(--tc-border);
    background: var(--tc-bg);
}
.tc-chat-item.open .tc-chat-thread { display: block; }
.tc-bubble-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 10px;
}
.tc-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12.5px;
    line-height: 1.5;
}
.tc-bubble.user {
    background: var(--tc-blue-light);
    color: var(--tc-blue-dark);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.tc-bubble.agent {
    background: #F3F4F6;
    color: var(--tc-text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.tc-bubble-sender {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 3px;
    color: var(--tc-text-sec);
}

/* ── Top pages ── */
.tc-page-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--tc-border);
    font-size: 13px;
}
.tc-page-row:last-child { border-bottom: none; }
.tc-page-title {
    flex: 1;
    color: var(--tc-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tc-page-views {
    font-size: 12px;
    font-weight: 600;
    color: var(--tc-text-sec);
    white-space: nowrap;
}

/* ── KB status ── */
.tc-kb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.tc-kb-info { flex: 1; }
.tc-kb-info p { margin: 0; font-size: 13px; color: var(--tc-text-sec); }
.tc-kb-info strong { color: var(--tc-text); }

/* ── Buttons ── */
.tc-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    border: none;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
}
.tc-btn:hover { opacity: 0.9; }
.tc-btn:active { opacity: 0.8; }
.tc-btn-primary {
    background: var(--tc-blue);
    color: #fff;
}
.tc-btn-primary:hover {
    background: var(--tc-blue-dark);
    color: #fff;
    opacity: 1;
}
.tc-btn-outline {
    background: #fff;
    color: var(--tc-blue);
    border: 1.5px solid var(--tc-blue);
}
.tc-btn-outline:hover {
    background: var(--tc-blue-50);
    color: var(--tc-blue-dark);
    opacity: 1;
}
.tc-btn-danger {
    background: #fff;
    color: var(--tc-red);
    border: 1.5px solid var(--tc-red);
}
.tc-btn-danger:hover {
    background: var(--tc-red-bg);
    opacity: 1;
}
.tc-btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Connect panel ── */
.tc-connect-panel {
    text-align: center;
    padding: 56px 24px;
}
.tc-connect-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--tc-blue-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}
.tc-connect-icon svg {
    color: var(--tc-blue);
}
.tc-connect-panel h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--tc-text);
    margin: 0 0 8px;
    text-transform: none;
    letter-spacing: -0.01em;
}
.tc-connect-panel p {
    font-size: 14px;
    color: var(--tc-text-sec);
    max-width: 400px;
    margin: 0 auto 28px;
    line-height: 1.5;
}

/* ── Loading skeleton ── */
.tc-skeleton {
    background: #F3F4F6;
    border-radius: 6px;
    height: 20px;
    animation: tc-pulse 1.5s ease-in-out infinite;
}
@keyframes tc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Section heading ── */
.tc-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--tc-text);
    margin: 24px 0 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tc-section-title svg {
    color: var(--tc-blue);
    width: 18px;
    height: 18px;
}

/* ── Footer/disconnect row ── */
.tc-footer-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--tc-border);
    flex-wrap: wrap;
}
.tc-footer-row p {
    font-size: 12px;
    color: var(--tc-text-sec);
    margin: 0;
    flex: 1;
}

/* ── Spinner ── */
.tc-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: tc-spin 0.6s linear infinite;
    vertical-align: middle;
}
@keyframes tc-spin { to { transform: rotate(360deg); } }

/* ── Toast ── */
#tc-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    font-size: 13px;
    font-weight: 500;
    padding: 12px 20px;
    border-radius: 10px;
    color: #fff;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.3s;
    z-index: 9999;
    pointer-events: none;
}
#tc-toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ── Empty state ── */
.tc-empty {
    color: var(--tc-text-sec);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}
