/* ============================================
   CS Bot Monitor Dashboard — Style
   Light gray bg, white cards, centered layout
   ============================================ */

:root {
    --bg-primary: #f0f2f5;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --border-card: rgba(0, 0, 0, 0.08);
    --border-input: #d1d5db;
    --blue-dark: #1e3a5f;
    --blue-mid: #2563eb;
    --blue-bg: #eff6ff;
    --blue-border: #bfdbfe;
    --accent-gradient: linear-gradient(135deg, #3b82f6, #1d4ed8);
    --green: #34d399;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: #1f2937;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---- App Container ---- */
.app {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 36px;
}

/* ---- Filters ---- */
/* ---- Page Header ---- */
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #1e40af;
    margin: 0 0 18px;
    padding-left: 14px;
    border-left: 4px solid #2563eb;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.filters {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 10px;
    padding: 22px 26px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.04);
    position: sticky;
    top: 32px;
    z-index: 100;
}

.filters--trend {
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.filter-group label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.filter-group input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: #374151;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    padding: 0 14px;
    height: 40px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    cursor: pointer;
    width: 100%;
    min-width: 140px;
}

.filter-group:has(input[type="date"]) + .filter-group:has(input[type="date"]),
.filter-group:has(input[type="date"]) + .filter-group--shortcuts,
.filter-group:has(input[type="date"]) + .filter-group:has(.custom-select) {
    margin-left: 16px;
}

.filter-group input[type="date"]:focus {
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ---- Custom Select ---- */
.custom-select {
    position: relative;
    width: 100%;
}

.custom-select__trigger {
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: #374151;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    padding: 0 32px 0 14px;
    height: 40px;
    line-height: 40px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select.open .custom-select__trigger {
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.custom-select__dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    z-index: 50;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
}

.custom-select.open .custom-select__dropdown {
    display: block;
}

.custom-select__option {
    padding: 8px 12px;
    font-size: 0.85rem;
    color: #374151;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.custom-select__option:hover {
    background: #f3f4f6;
}

.custom-select__option--selected {
    color: var(--blue-mid);
    font-weight: 600;
    background: var(--blue-bg);
}

.filter-group input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

.filter-divider {
    width: 1px;
    height: 40px;
    background: #d1d5db;
    align-self: flex-end;
    margin-bottom: 4px;
}

.btn-search {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 22px;
    height: 40px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-search:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

.btn-search:active {
    transform: translateY(0);
}

/* ---- Shortcut Buttons ---- */
.filter-group--shortcuts {
    flex: 0 0 auto;
}

.shortcut-btns {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    overflow: hidden;
    height: 40px;
}

.btn-shortcut {
    padding: 0 14px;
    border: none;
    border-right: 1px solid var(--border-input);
    background: transparent;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 38px;
}

.btn-shortcut:last-child {
    border-right: none;
}

.btn-shortcut:hover {
    background: #eef1f6;
    color: #374151;
}

.btn-shortcut.active {
    background: #e2e6ed;
    color: #1f2937;
    font-weight: 600;
}

/* ---- Stats Main (3 big cards) ---- */
.stats-main {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 36px 28px;
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: visible;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.stat-card__icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-bg);
    border-radius: var(--radius-md);
    color: var(--blue-mid);
    flex-shrink: 0;
}

.stat-card__content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-card__label {
    font-size: 0.78rem;
    font-weight: 500;
    color: #9ca3af;
    letter-spacing: 0.01em;
}

.stat-card__value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    color: var(--blue-dark);
}

/* ---- Dual Card ---- */
.stat-card--dual .stat-card__content {
    gap: 8px;
}

.stat-card__row {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.stat-card__row-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #9ca3af;
    min-width: 56px;
}

.stat-card__row-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--blue-dark);
}

/* ---- Info Icon ---- */
.stat-card__info {
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 0.85rem;
    color: #b0b8c9;
    cursor: help;
    z-index: 2;
}

.stat-card--dual {
    position: relative;
}

.stat-card__info:hover::after {
    content: attr(title);
    position: absolute;
    right: 0;
    top: 110%;
    background: #1f2937;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    pointer-events: none;
}

/* ---- Stats Detail (4 small cards) ---- */
.stats-detail {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card--small {
    padding: 22px 24px;
    display: block;
}

.stat-card--small .stat-card__label {
    margin-bottom: 8px;
    font-size: 0.78rem;
}

.stat-card--small .stat-card__value {
    font-size: 2rem;
    margin-bottom: 6px;
    color: #1f2937;
}

.stat-card__sub {
    font-size: 0.75rem;
    color: #9ca3af;
}

.stat-card__pct {
    color: #00c5c5;
    font-weight: 700;
}

/* ---- Chart ---- */
.chart-section {
    margin-bottom: 20px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 14px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.06);
}

.chart-card__header {
    font-size: 0.9rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 20px;
}

.chart-card__subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: -16px;
    margin-bottom: 16px;
}

.chart-card__body {
    position: relative;
    height: 320px;
}

/* ---- Loading ---- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(240, 242, 245, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.08);
    border-top-color: var(--blue-mid);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ---- Value Animation ---- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card__value.loaded {
    animation: fadeInUp 0.4s ease-out;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
    .stats-main {
        grid-template-columns: repeat(2, 1fr);
    }
    .stats-detail {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---- Consultant Table ---- */
.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 320px;
    padding: 0 24px 24px;
}

.consultant-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.consultant-table th {
    text-align: center;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 0.75rem;
    color: #6b7280;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.consultant-table td {
    text-align: center;
    padding: 14px 14px;
    color: #374151;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.consultant-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: #1f2937;
}

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

.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    color: var(--blue);
}

.sort-icon {
    font-size: 0.75rem;
    opacity: 0.5;
}

/* ---- Trend Select (Floating Label) ---- */
.trend-select-wrap {
    position: relative;
}

.trend-select-label {
    position: absolute;
    top: -8px;
    left: 10px;
    background: #fff;
    padding: 0 5px;
    font-size: 0.7rem;
    font-weight: 400;
    color: #6b7280;
    z-index: 1;
    line-height: 1;
}

.trend-select-wrap .custom-select {
    min-width: 100px;
}

.chart-card__header .trend-select-wrap {
    margin-right: 42px;
}

.trend-date-range {
    font-size: 0.78rem;
    font-weight: 500;
    color: #6b7280;
    background: #f3f4f6;
    padding: 3px 12px;
    border-radius: 12px;
    white-space: nowrap;
}

/* ---- Heatmap Table ---- */
.table-wrap--heatmap {
    max-height: none;
}

.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    table-layout: fixed;
}

.heatmap-table th {
    text-align: center;
    padding: 10px 8px;
    font-weight: 600;
    font-size: 0.78rem;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
}

.heatmap-table td {
    text-align: right;
    padding: 8px 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #1f2937;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    transition: all 0.15s ease;
    cursor: default;
    position: relative;
}

.heatmap-table td.has-value:hover {
    transform: scale(1.07);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    z-index: 2;
}

.heatmap-table td:first-child {
    text-align: center;
    font-weight: 600;
    color: #374151;
    background: transparent !important;
    width: 50px;
}

@media (max-width: 768px) {
    .app {
        padding: 16px;
    }
    .stats-main {
        grid-template-columns: 1fr;
    }
    .stats-detail {
        grid-template-columns: repeat(2, 1fr);
    }
    .filters {
        padding: 16px;
    }
    .filter-divider {
        display: none;
    }
}

@media (max-width: 480px) {
    .stats-detail {
        grid-template-columns: 1fr;
    }
}

/* ---- Info Tooltip ---- */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    font-size: 0.75rem;
    color: #9ca3af;
    cursor: help;
    vertical-align: middle;
    margin-left: 2px;
}

.info-tip:hover {
    color: #6b7280;
}

.tip-popup {
    position: fixed;
    background: #1f2937;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.6;
    white-space: pre-line;
    max-width: 400px;
    min-width: 200px;
    z-index: 99999;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    pointer-events: auto;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.tip-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1f2937;
}

.tip-popup--below::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #1f2937;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.45);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #fff;
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    width: 94%;
    max-width: 1100px;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-card);
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    white-space: nowrap;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.15s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.modal-content .table-wrap {
    overflow-y: auto;
    padding: 0 24px 20px;
}

/* ---- Noreply Card Modal ---- */
.noreply-modal {
    max-width: 1000px;
}

.modal-header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #0891b2;
    background: #ecfeff;
    border: 1px solid #a5f3fc;
    border-radius: 20px;
    white-space: nowrap;
}

.noreply-cards-wrap {
    overflow-y: auto;
    padding: 20px 28px;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.noreply-card {
    border: 1px solid #e5e7eb;
    border-left: 4px solid #93c5fd;
    border-radius: 10px;
    padding: 16px 20px;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
    background: #fff;
}

.noreply-card:hover {
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    border-left-color: #3b82f6;
}

.noreply-card__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 8px;
    line-height: 1.4;
}

.noreply-card__message {
    font-size: 0.82rem;
    color: #4b5563;
    line-height: 1.5;
    margin-bottom: 10px;
    white-space: pre-line;
    word-break: break-word;
}

.noreply-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.noreply-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 4px;
    white-space: nowrap;
}

.noreply-tag--time {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.noreply-tag--user {
    background: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.noreply-empty {
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    font-size: 0.9rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 14px 24px;
    border-top: 1px solid var(--border-card);
}

.modal-footer__close-btn {
    padding: 7px 28px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.modal-footer__close-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}
