/* Toomics CS Dashboard — Light mode only */

:root {
    --brand: #3B1F8E;
    --brand-light: #5E3FBF;
    --brand-bg: #F3F0FF;
    --accent: #7C4DFF;
    --bg: #F5F6FA;
    --surface: #FFFFFF;
    --text: #1A1A2E;
    --text-secondary: #6B7280;
    --border: #E5E7EB;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #3B82F6;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* ---- Login ---- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
}

.login-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    width: 360px;
    text-align: center;
}

.login-logo {
    font-size: 28px;
    font-weight: 800;
    color: var(--brand);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.login-card h2 {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 24px;
}

.login-card input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 14px;
}

.login-card input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-bg);
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 8px;
}

/* ---- Header ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 20px; font-weight: 800; color: var(--brand); letter-spacing: 1px; }
.header-title { color: var(--text-secondary); font-size: 15px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.user-badge { font-weight: 600; color: var(--brand); }

/* ---- KPI Strip ---- */
.kpi-strip {
    display: flex;
    gap: 16px;
    padding: 16px 24px;
}

.kpi-card {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    border-left: 4px solid transparent;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.kpi-card[data-status="new"] { border-left-color: var(--info); }
.kpi-card[data-status="in_progress"] { border-left-color: #F97316; }
.kpi-card[data-status="open"] { border-left-color: var(--warning); }
.kpi-card[data-status="pending"] { border-left-color: var(--accent); }
.kpi-card[data-status="solved"] { border-left-color: var(--success); }

.kpi-value { font-size: 28px; font-weight: 700; color: var(--text); }
.kpi-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* ---- Filters ---- */
.filters {
    display: flex;
    gap: 10px;
    padding: 12px 24px;
    align-items: center;
    flex-wrap: wrap;
}

.filters select, .filters input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--surface);
}

.filters input { flex: 1; min-width: 200px; }
.filters select:focus, .filters input:focus { outline: none; border-color: var(--brand); }

/* ---- Main Layout ---- */
.main-content {
    display: flex;
    gap: 0;
    padding: 0 24px 24px;
    height: calc(100vh - 200px);
}

.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-list { flex: 0 0 35%; min-width: 280px; overflow: hidden; }
.panel-detail { flex: 1 1 0; min-width: 400px; overflow: hidden; }

/* ---- Panel Resizer ---- */
.panel-resizer {
    flex: 0 0 6px;
    cursor: col-resize;
    background: transparent;
    position: relative;
    z-index: 10;
    transition: background 0.15s;
}

.panel-resizer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 32px;
    background: var(--border);
    border-radius: 1px;
    transition: height 0.15s, background 0.15s;
}

.panel-resizer:hover { background: var(--brand-bg); }
.panel-resizer:hover::after { height: 48px; background: var(--brand); }
.panel-resizer.dragging { background: var(--brand-bg); }
.panel-resizer.dragging::after { height: 64px; background: var(--brand); }

/* ---- Ticket List ---- */
.ticket-list {
    flex: 1;
    overflow-y: auto;
}

.ticket-item {
    padding: 6px 10px;
    margin: 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
}

.ticket-item:hover { background: var(--brand-bg); }
.ticket-item.active { background: var(--brand-bg); border-left: 3px solid var(--brand); }

.ticket-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.ticket-id { font-weight: 600; color: var(--brand); font-size: 12px; }
.ticket-subject { font-weight: 500; margin-bottom: 2px; font-size: 12px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.ticket-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size: 11px;
    color: var(--text-secondary);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-new { background: #DBEAFE; color: #1D4ED8; }
.badge-in-progress { background: #FFF7ED; color: #C2410C; }
.badge-open { background: #FEF3C7; color: #92400E; }
.badge-pending { background: #EDE9FE; color: #5B21B6; }
.badge-solved { background: #D1FAE5; color: #065F46; }
.badge-market { background: #E5E7EB; color: #374151; }
.badge-category { background: #FCE7F3; color: #9D174D; }

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.pagination button {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 12px;
}

.pagination button.active { background: var(--brand); color: white; border-color: var(--brand); }

/* ---- Chart Overview (right panel, no ticket selected) ---- */
.chart-overview {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

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

.chart-overview-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.chart-total-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-bg);
    padding: 4px 12px;
    border-radius: 12px;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 16px;
    border: 1px solid var(--border);
}

.chart-card h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.chart-card-wide {
    grid-column: 1 / -1;
}

.chart-canvas-wrap {
    position: relative;
    height: 240px;
}

.chart-canvas-bar {
    height: 180px;
}

/* ---- Timeline ---- */
.timeline {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 10px 0;
    margin-bottom: 8px;
    overflow-x: auto;
}

.timeline-step {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    border: 2px solid var(--border);
}

.timeline-dot.status-created { background: var(--info); border-color: var(--info); }
.timeline-dot.status-new { background: var(--info); border-color: var(--info); }
.timeline-dot.status-open { background: var(--warning); border-color: var(--warning); }
.timeline-dot.status-pending { background: var(--accent); border-color: var(--accent); }
.timeline-dot.status-solved { background: var(--success); border-color: var(--success); }
.timeline-dot.status-closed { background: var(--text-secondary); border-color: var(--text-secondary); }
.timeline-dot.status-hold { background: #F97316; border-color: #F97316; }

.timeline-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text);
    white-space: nowrap;
}

.timeline-time {
    font-size: 9px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.timeline-line {
    width: 24px;
    height: 2px;
    background: var(--border);
    flex-shrink: 0;
}

/* ---- Detail Panel ---- */
.placeholder-text {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    font-size: 15px;
}

#ticket-detail {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.detail-header h2 { font-size: 16px; margin-bottom: 8px; }

.detail-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

.detail-actions-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
    font-size: 13px;
}

.detail-actions-bar select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

/* ---- Conversation ---- */
.conversation {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.comment {
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.6;
}

.comment-customer {
    background: #F0F4FF;
    border-left: 3px solid var(--info);
}

.comment-agent {
    background: #F0FDF4;
    border-left: 3px solid var(--success);
}

.comment-internal {
    background: #FFFBEB;
    border-left: 3px solid var(--warning);
    font-style: italic;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.comment-author { font-weight: 600; }

/* ---- Draft Section ---- */
/* ---- Compose Section (shared textarea for reply/note/escalate) ---- */
.compose-section {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.compose-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

#compose-text {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    box-sizing: border-box;
}

#compose-text:focus { outline: none; border-color: var(--brand); }

.quality-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s, background 0.3s;
}

.draft-sections {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.compose-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

.compose-actions-left,
.compose-actions-right {
    display: flex;
    gap: 8px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-light); }

.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #6D3FE0; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

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

/* ---- Spam Banner ---- */
.spam-banner {
    margin-top: 12px;
    padding: 16px;
    background: #FEF2F2;
    border: 1px solid #FECACA;
    border-left: 4px solid var(--danger);
    border-radius: var(--radius);
}

.spam-banner-header {
    font-weight: 700;
    font-size: 14px;
    color: var(--danger);
    margin-bottom: 8px;
}

.spam-banner-body { font-size: 13px; color: #991B1B; margin-bottom: 12px; }
.spam-banner-body ul { margin: 6px 0 0 18px; }
.spam-banner-body li { margin-bottom: 2px; }

.no-match-banner {
    margin-top: 12px;
    padding: 16px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-left: 4px solid #F59E0B;
    border-radius: var(--radius);
}
.no-match-banner-header {
    font-weight: 700;
    font-size: 14px;
    color: #92400E;
    margin-bottom: 8px;
}
.no-match-banner-body { font-size: 13px; color: #78350F; }
.no-match-banner-body p { margin: 4px 0; }

/* ---- Verification banner ---- */
.verification-banner {
    margin-top: 12px;
    margin-bottom: 12px;
    padding: 14px 16px;
    background: #EFF6FF;
    border: 1px solid #BFDBFE;
    border-left: 4px solid var(--info);
    border-radius: var(--radius);
}
.verification-banner-header {
    font-weight: 700;
    font-size: 14px;
    color: #1E40AF;
    margin-bottom: 10px;
}
.verification-banner-body { font-size: 13px; }
.verification-item {
    padding: 8px 0;
    border-bottom: 1px solid #DBEAFE;
}
.verification-item:last-child { border-bottom: none; }
.verification-tag {
    display: inline-block;
    background: #DBEAFE;
    color: #1E40AF;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    margin-right: 6px;
}
.verification-label {
    font-weight: 600;
    color: #1E3A5F;
    font-size: 13px;
}
.verification-detail {
    margin: 4px 0 0;
    color: #374151;
    font-size: 13px;
    line-height: 1.5;
}

/* ---- Loading spinner ---- */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .main-content { flex-direction: column; height: auto; }
    .panel-list, .panel-detail { width: 100%; }
    .kpi-strip { flex-wrap: wrap; }
    .kpi-card { min-width: 120px; }
}

/* ---- Print ---- */
@media print {
    .header, .filters, .kpi-strip, .compose-section { display: none; }
    .main-content { display: block; }
    .panel { box-shadow: none; }
}
