/* ==========================================================
 * SMART DASHBOARD CSS
 * ==========================================================
 * Styles for the admin Smart Dashboard area.
 * Follows tk-* naming convention. RTL-aware.
 */

/* Dashboard container */
.tk-area-dashboard {
    padding: 24px;
    overflow-y: auto;
    height: 100%;
    box-sizing: border-box;
    background: #f8f9fb;
}

.tk-rtl .tk-area-dashboard {
    direction: rtl;
}

/* ---- Unanswered Alert Banner ---- */
.tk-dash-alert-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff0f0;
    border: 1px solid #fca5a5;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.tk-dash-alert-banner.tk-hidden {
    display: none;
}

.tk-dash-alert-banner-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #b91c1c;
    font-weight: 600;
}

.tk-dash-alert-banner-left i {
    font-size: 18px;
}

.tk-dash-alert-banner-left .tk-dash-urgent {
    color: #991b1b;
    margin-inline-start: 12px;
    padding-inline-start: 12px;
    border-inline-start: 1px solid #fca5a5;
}

.tk-dash-alert-banner-right a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #dc2626;
    color: #fff;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}

.tk-dash-alert-banner-right a:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.35);
}

.tk-dash-alert-banner-right a i {
    font-size: 15px;
}

/* ---- Stat Cards Grid ---- */
.tk-dash-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.tk-dash-stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tk-dash-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
}

.tk-dash-stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.tk-dash-stat-sub {
    font-size: 12px;
    font-weight: 500;
}

.tk-dash-stat-sub.tk-positive {
    color: #16a34a;
}

.tk-dash-stat-sub.tk-negative {
    color: #dc2626;
}

.tk-dash-stat-sub.tk-neutral {
    color: #94a3b8;
}

/* ---- Charts Row ---- */
.tk-dash-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.tk-dash-chart-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tk-dash-chart-card h3 {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin: 0 0 16px 0;
}

.tk-dash-chart-container {
    position: relative;
    width: 100%;
    max-height: 260px;
}

.tk-dash-chart-container canvas {
    width: 100% !important;
    max-height: 240px;
}

/* Channel legend under doughnut */
.tk-dash-channel-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    justify-content: center;
}

.tk-dash-channel-legend span {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #475569;
}

.tk-dash-channel-legend i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

/* ---- Alerts Section ---- */
.tk-dash-alerts {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.tk-dash-alerts h3 {
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    margin: 0 0 12px 0;
}

.tk-dash-alerts ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tk-dash-alerts li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: #475569;
}

.tk-dash-alerts li:last-child {
    border-bottom: none;
}

.tk-dash-alerts li i {
    color: #f59e0b;
    font-size: 14px;
}

.tk-dash-alerts li.tk-alert-urgent i {
    color: #dc2626;
}

.tk-dash-no-alerts {
    color: #94a3b8;
    font-size: 13px;
}

/* ---- Unanswered Slide-Over Panel ---- */
.tk-dash-unanswered-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.12);
    z-index: 99999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.tk-rtl .tk-dash-unanswered-panel {
    right: auto;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.12);
}

.tk-dash-unanswered-panel.tk-active {
    transform: translateX(0);
}

.tk-dash-unanswered-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.tk-dash-unanswered-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.tk-dash-unanswered-header .tk-close {
    cursor: pointer;
    font-size: 18px;
    color: #64748b;
    background: none;
    border: none;
    padding: 4px;
}

.tk-dash-unanswered-header .tk-close:hover {
    color: #1e293b;
}

.tk-dash-unanswered-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    list-style: none;
}

.tk-dash-unanswered-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s;
}

.tk-dash-unanswered-item:hover {
    background: #f8fafc;
}

.tk-dash-unanswered-item.tk-urgent {
    background: #fff7ed;
}

.tk-dash-unanswered-item.tk-urgent:hover {
    background: #fff2e2;
}

.tk-dash-unanswered-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    flex-shrink: 0;
    object-fit: cover;
}

.tk-dash-unanswered-info {
    flex: 1;
    min-width: 0;
}

.tk-dash-unanswered-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 3px;
}

.tk-dash-unanswered-name img.tk-channel-icon {
    width: 14px;
    height: 14px;
}

.tk-dash-unanswered-preview {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 280px;
}

.tk-dash-unanswered-time {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    flex-shrink: 0;
    margin-top: 2px;
}

.tk-dash-unanswered-time.tk-urgent-time {
    color: #dc2626;
    font-weight: 600;
}

.tk-dash-unanswered-empty {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 14px;
}

/* Panel backdrop */
.tk-dash-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.tk-dash-panel-backdrop.tk-active {
    opacity: 1;
    pointer-events: auto;
}

/* ---- Nav badge ---- */
.tk-dash-nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    margin-inline-start: 6px;
    line-height: 1;
}

.tk-dash-nav-badge.tk-hidden {
    display: none;
}

/* ---- Stat card icon ---- */
.tk-dash-stat-icon {
    font-size: 22px;
    color: #94a3b8;
    margin-bottom: 4px;
    opacity: 0.5;
}

/* ---- Loading spinner ---- */
.tk-dash-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: #64748b;
    font-size: 14px;
    gap: 14px;
}

.tk-dash-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: tk-dash-spin 0.7s linear infinite;
}

.tk-dash-spinner.tk-small {
    width: 18px;
    height: 18px;
    border-width: 2px;
    display: inline-block;
    vertical-align: middle;
}

@keyframes tk-dash-spin {
    to { transform: rotate(360deg); }
}

/* ---- Responsive ---- */
@media (max-width: 1200px) {
    .tk-dash-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tk-area-dashboard {
        padding: 16px;
    }

    .tk-dash-stats {
        grid-template-columns: 1fr;
    }

    .tk-dash-charts {
        grid-template-columns: 1fr;
    }

    .tk-dash-unanswered-panel {
        width: 100vw;
    }

    .tk-dash-alert-banner {
        flex-direction: column;
        align-items: flex-start;
    }
}
