sls/resources/views/client_calls/index.blade.php

938 lines
38 KiB
PHP

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Client Calls & Projects Hub | SingleLogin</title>
<!-- Google Fonts: Outfit & Inter -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;600;700;800&display=swap" rel="stylesheet">
<script>
(function () {
const savedTheme = localStorage.getItem('theme') || 'dark';
if (savedTheme === 'light') {
document.documentElement.classList.add('light-mode');
} else {
document.documentElement.classList.remove('light-mode');
}
})();
</script>
<style>
:root {
--bg-color: #0b0f19;
--card-bg: rgba(17, 24, 39, 0.55);
--card-border: rgba(255, 255, 255, 0.12);
--accent-primary: #4f46e5;
--accent-secondary: #06b6d4;
--text-main: #f3f4f6;
--text-muted: #9ca3af;
--success-color: #10b981;
--warning-color: #f59e0b;
--danger-color: #ef4444;
--input-bg: rgba(255, 255, 255, 0.04);
--modal-bg: #131b2e;
--modal-overlay: rgba(11, 15, 25, 0.85);
}
:root.light-mode {
--bg-color: #f3f4f6;
--card-bg: rgba(255, 255, 255, 0.85);
--card-border: rgba(0, 0, 0, 0.08);
--accent-primary: #4f46e5;
--accent-secondary: #0284c7;
--text-main: #1f2937;
--text-muted: #4b5563;
--success-color: #059669;
--warning-color: #d97706;
--danger-color: #dc2626;
--input-bg: rgba(0, 0, 0, 0.03);
--modal-bg: #ffffff;
--modal-overlay: rgba(243, 244, 246, 0.85);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Inter', sans-serif;
background-color: var(--bg-color);
color: var(--text-main);
min-height: 100vh;
background-image:
radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 45%),
radial-gradient(circle at 15% 85%, rgba(6, 182, 212, 0.1) 0%, transparent 45%);
background-attachment: fixed;
}
/* Navbar */
.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 2rem;
background: rgba(10, 15, 26, 0.6);
backdrop-filter: blur(12px);
border-bottom: 1px solid var(--card-border);
position: sticky;
top: 0;
z-index: 50;
}
:root.light-mode .navbar {
background: rgba(255, 255, 255, 0.8);
}
.brand-logo {
display: flex;
align-items: center;
gap: 12px;
text-decoration: none;
color: var(--text-main);
font-family: 'Outfit', sans-serif;
font-size: 1.25rem;
font-weight: 700;
}
.brand-badge {
background: linear-gradient(135deg, #4f46e5, #06b6d4);
color: white;
font-size: 0.7rem;
padding: 2px 8px;
border-radius: 999px;
font-weight: 700;
text-transform: uppercase;
}
.nav-actions {
display: flex;
align-items: center;
gap: 12px;
}
.nav-btn {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 0.5rem 1rem;
border-radius: 8px;
font-size: 0.875rem;
font-weight: 600;
text-decoration: none;
cursor: pointer;
transition: all 0.2s ease;
border: 1px solid var(--card-border);
background: var(--card-bg);
color: var(--text-main);
}
.nav-btn:hover {
transform: translateY(-1px);
border-color: rgba(99, 102, 241, 0.5);
}
.nav-btn-primary {
background: linear-gradient(135deg, #4f46e5, #6366f1);
color: white !important;
border: none;
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}
.nav-btn-primary:hover {
box-shadow: 0 6px 16px rgba(79, 70, 229, 0.5);
}
/* Container */
.main-container {
max-width: 1300px;
margin: 2rem auto;
padding: 0 1.5rem;
}
/* Alert Banners */
.alert {
padding: 1rem 1.25rem;
border-radius: 10px;
margin-bottom: 1.5rem;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 0.9rem;
}
.alert-success {
background: rgba(16, 185, 129, 0.15);
border: 1px solid rgba(16, 185, 129, 0.35);
color: #34d399;
}
/* Stats Grid */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 1.25rem;
margin-bottom: 2rem;
}
.stat-card {
background: var(--card-bg);
backdrop-filter: blur(12px);
border: 1px solid var(--card-border);
border-radius: 14px;
padding: 1.25rem;
display: flex;
align-items: center;
gap: 1rem;
transition: all 0.2s ease;
}
.stat-card:hover {
border-color: rgba(99, 102, 241, 0.4);
transform: translateY(-2px);
}
.stat-icon {
width: 48px;
height: 48px;
border-radius: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.5rem;
background: rgba(99, 102, 241, 0.12);
color: #818cf8;
}
.stat-icon.danger {
background: rgba(239, 68, 68, 0.15);
color: #f87171;
}
.stat-icon.success {
background: rgba(16, 185, 129, 0.15);
color: #34d399;
}
.stat-val {
font-size: 1.6rem;
font-weight: 800;
font-family: 'Outfit', sans-serif;
color: var(--text-main);
}
.stat-label {
font-size: 0.8rem;
color: var(--text-muted);
text-transform: uppercase;
font-weight: 600;
letter-spacing: 0.5px;
}
/* Section Header */
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
flex-wrap: wrap;
gap: 1rem;
}
.section-title {
font-family: 'Outfit', sans-serif;
font-size: 1.5rem;
font-weight: 700;
color: var(--text-main);
}
.section-desc {
font-size: 0.875rem;
color: var(--text-muted);
margin-top: 4px;
}
/* Search & Filter Bar */
.filter-bar {
display: flex;
gap: 1rem;
margin-bottom: 1.5rem;
flex-wrap: wrap;
}
.search-input {
flex: 1;
min-width: 250px;
padding: 0.65rem 1rem;
background: var(--input-bg);
border: 1px solid var(--card-border);
border-radius: 8px;
color: var(--text-main);
font-size: 0.875rem;
outline: none;
}
.search-input:focus {
border-color: #6366f1;
}
.filter-select {
padding: 0.65rem 1rem;
background: var(--input-bg);
border: 1px solid var(--card-border);
border-radius: 8px;
color: var(--text-main);
font-size: 0.875rem;
outline: none;
cursor: pointer;
}
/* Client Cards Grid */
.clients-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
gap: 1.5rem;
}
.client-card {
background: var(--card-bg);
backdrop-filter: blur(12px);
border: 1px solid var(--card-border);
border-radius: 16px;
padding: 1.5rem;
display: flex;
flex-direction: column;
justify-content: space-between;
transition: all 0.25s ease;
position: relative;
overflow: hidden;
}
.client-card:hover {
border-color: rgba(99, 102, 241, 0.4);
transform: translateY(-3px);
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}
.client-card-header {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 1rem;
}
.project-title {
font-family: 'Outfit', sans-serif;
font-size: 1.2rem;
font-weight: 700;
color: var(--text-main);
margin-bottom: 4px;
}
.client-company {
font-size: 0.85rem;
color: var(--text-muted);
display: flex;
align-items: center;
gap: 6px;
}
/* Sentiment Badges */
.sentiment-badge {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 4px 10px;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 700;
text-transform: uppercase;
}
.sentiment-happy {
background: rgba(16, 185, 129, 0.15);
color: #34d399;
border: 1px solid rgba(16, 185, 129, 0.35);
}
.sentiment-neutral {
background: rgba(59, 130, 246, 0.15);
color: #60a5fa;
border: 1px solid rgba(59, 130, 246, 0.35);
}
.sentiment-sad {
background: rgba(245, 158, 11, 0.15);
color: #fbbf24;
border: 1px solid rgba(245, 158, 11, 0.35);
}
.sentiment-angry {
background: rgba(239, 68, 68, 0.2);
color: #f87171;
border: 1px solid rgba(239, 68, 68, 0.45);
animation: pulse-border 2s infinite;
}
@keyframes pulse-border {
0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
.client-info-list {
margin: 1rem 0;
display: flex;
flex-direction: column;
gap: 8px;
font-size: 0.85rem;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: center;
color: var(--text-muted);
}
.info-row span:last-child {
color: var(--text-main);
font-weight: 500;
}
.responsible-badge {
background: rgba(99, 102, 241, 0.15);
color: #818cf8;
padding: 3px 8px;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 600;
}
.angry-alert-box {
background: rgba(239, 68, 68, 0.12);
border: 1px solid rgba(239, 68, 68, 0.3);
border-radius: 8px;
padding: 10px 12px;
margin: 12px 0;
display: flex;
justify-content: space-between;
align-items: center;
}
.angry-alert-text {
font-size: 0.8rem;
color: #fca5a5;
font-weight: 600;
}
.btn-why-angry {
background: #ef4444;
color: white;
border: none;
padding: 4px 10px;
border-radius: 6px;
font-size: 0.75rem;
font-weight: 700;
cursor: pointer;
transition: all 0.2s ease;
}
.btn-why-angry:hover {
background: #dc2626;
transform: scale(1.03);
}
.card-actions {
display: flex;
gap: 8px;
margin-top: 1rem;
padding-top: 1rem;
border-top: 1px solid var(--card-border);
}
.btn-hub {
flex: 1;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
padding: 0.6rem 1rem;
border-radius: 8px;
font-size: 0.875rem;
font-weight: 600;
text-decoration: none;
background: rgba(99, 102, 241, 0.15);
color: #818cf8;
border: 1px solid rgba(99, 102, 241, 0.3);
transition: all 0.2s ease;
}
.btn-hub:hover {
background: #4f46e5;
color: white;
border-color: #4f46e5;
}
/* Modal styling */
.modal-overlay {
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: var(--modal-overlay);
backdrop-filter: blur(6px);
display: none;
justify-content: center;
align-items: center;
z-index: 100;
padding: 1rem;
}
.modal-card {
background: var(--modal-bg);
border: 1px solid var(--card-border);
border-radius: 16px;
width: 100%;
max-width: 600px;
max-height: 90vh;
overflow-y: auto;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
padding: 2rem;
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.5rem;
}
.modal-title {
font-family: 'Outfit', sans-serif;
font-size: 1.35rem;
font-weight: 700;
}
.modal-close {
background: transparent;
border: none;
color: var(--text-muted);
font-size: 1.5rem;
cursor: pointer;
}
.modal-close:hover { color: var(--text-main); }
.form-group {
margin-bottom: 1.25rem;
}
.form-label {
display: block;
font-size: 0.85rem;
font-weight: 600;
color: var(--text-muted);
margin-bottom: 6px;
}
.form-control {
width: 100%;
padding: 0.7rem 1rem;
background: var(--input-bg);
border: 1px solid var(--card-border);
border-radius: 8px;
color: var(--text-main);
font-size: 0.9rem;
outline: none;
}
.form-control:focus {
border-color: #6366f1;
}
.form-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.team-members-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
gap: 8px;
max-height: 140px;
overflow-y: auto;
background: var(--input-bg);
border: 1px solid var(--card-border);
border-radius: 8px;
padding: 10px;
}
.member-checkbox-label {
display: flex;
align-items: center;
gap: 8px;
font-size: 0.8rem;
cursor: pointer;
color: var(--text-main);
}
.empty-state {
text-align: center;
padding: 4rem 2rem;
background: var(--card-bg);
border: 1px dashed var(--card-border);
border-radius: 16px;
}
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar">
<a href="{{ route('dashboard') }}" class="brand-logo">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="color: #6366f1;">
<path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"/>
</svg>
SingleLogin <span class="brand-badge">Client Calls</span>
</a>
<div class="nav-actions">
<!-- Theme Toggle -->
<button class="theme-toggle-btn" id="themeToggleBtn" onclick="toggleTheme()" title="Switch Light / Dark Theme" style="background: var(--card-bg); border: 1px solid var(--card-border); color: var(--text-main); width: 38px; height: 38px; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 1rem;">
🌙
</button>
<a href="{{ route('client-calls.logs') }}" class="nav-btn" style="border-color: #22d3ee; color: #22d3ee;">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>
Date-wise Call Logs
</a>
<button class="nav-btn-primary nav-btn" onclick="openAddClientModal()">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
Add Client & Project
</button>
<a href="{{ route('dashboard') }}" class="nav-btn">
Back to Dashboard
</a>
</div>
</nav>
<!-- Main Content -->
<main class="main-container">
@if(session('success'))
<div class="alert alert-success">
<span>{{ session('success') }}</span>
<button style="background:transparent;border:none;color:inherit;cursor:pointer;" onclick="this.parentElement.remove()"></button>
</div>
@endif
<!-- Stats Overview -->
<div class="stats-grid">
<div class="stat-card">
<div class="stat-icon">📁</div>
<div>
<div class="stat-val">{{ $totalClients }}</div>
<div class="stat-label">Active Client Projects</div>
</div>
</div>
<div class="stat-card">
<div class="stat-icon success">📞</div>
<div>
<div class="stat-val">{{ $totalMeetings }}</div>
<div class="stat-label">Total Meetings Held</div>
</div>
</div>
<div class="stat-card">
<div class="stat-icon {{ $angryClientsCount > 0 ? 'danger' : '' }}">
{{ $angryClientsCount > 0 ? '⚠️' : '✨' }}
</div>
<div>
<div class="stat-val" style="{{ $angryClientsCount > 0 ? 'color: #f87171;' : '' }}">
{{ $angryClientsCount }}
</div>
<div class="stat-label">Client Attention Alerts</div>
</div>
</div>
</div>
<!-- Section Header -->
<div class="section-header">
<div>
<h1 class="section-title">Client Projects & Meeting Hub</h1>
<p class="section-desc">Manage clients, schedule future calls, start instant meetings with AI transcription, and review automated MoMs.</p>
</div>
</div>
<!-- Filter Bar -->
<div class="filter-bar">
<input type="text" id="searchInput" class="search-input" placeholder="Search by client name, project, company, or lead..." onkeyup="filterCards()">
<select id="sentimentFilter" class="filter-select" onchange="filterCards()">
<option value="all">All Sentiments</option>
<option value="happy">Happy 😊</option>
<option value="neutral">Neutral 😐</option>
<option value="sad">Sad / Concerned 😟</option>
<option value="angry">Angry / Frustrated 😡</option>
</select>
</div>
<!-- Clients Grid -->
@if($clients->isEmpty())
<div class="empty-state">
<div style="font-size: 3rem; margin-bottom: 1rem;">💼</div>
<h3 style="font-size: 1.25rem; font-weight: 700; margin-bottom: 6px;">No Client Projects Found</h3>
<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem;">Get started by adding your first client and project details.</p>
<button class="nav-btn-primary nav-btn" onclick="openAddClientModal()">
+ Add New Client & Project
</button>
</div>
@else
<div class="clients-grid" id="clientsGrid">
@foreach($clients as $client)
@php
$sentiment = strtolower($client->latest_sentiment ?? 'neutral');
$badgeClass = match($sentiment) {
'happy' => 'sentiment-happy',
'sad' => 'sentiment-sad',
'angry' => 'sentiment-angry',
default => 'sentiment-neutral',
};
$sentimentEmoji = match($sentiment) {
'happy' => '😊 Happy',
'sad' => '😟 Concerned',
'angry' => '😡 Frustrated',
default => '😐 Neutral',
};
$meetingsCount = $client->meetings->count();
$latestNote = $client->callNotes->first();
$canViewAngry = $client->canViewAngryAnalysis(Auth::user());
@endphp
<div class="client-card"
data-name="{{ strtolower($client->client_name) }}"
data-project="{{ strtolower($client->project_name) }}"
data-company="{{ strtolower($client->company_name ?? '') }}"
data-lead="{{ strtolower($client->responsibleUser->name ?? '') }}"
data-sentiment="{{ $sentiment }}">
<div>
<div class="client-card-header">
<div>
<div class="project-title">{{ $client->project_name }}</div>
<div class="client-company">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>
{{ $client->client_name }} {{ $client->company_name ? "" . $client->company_name : "" }}
</div>
</div>
<span class="sentiment-badge {{ $badgeClass }}">
{{ $sentimentEmoji }}
</span>
</div>
<div class="client-info-list">
<div class="info-row">
<span>Client Email:</span>
<span>{{ $client->client_email }}</span>
</div>
<div class="info-row">
<span>Responsible Lead:</span>
<span class="responsible-badge">{{ $client->responsibleUser->name ?? 'Unassigned' }}</span>
</div>
<div class="info-row">
<span>Total Meetings:</span>
<span>{{ $meetingsCount }} calls</span>
</div>
@if($latestNote)
<div class="info-row">
<span>Last Call Date:</span>
<span>{{ $latestNote->created_at->format('M d, Y') }}</span>
</div>
@endif
</div>
<!-- Angry Escalation Alert (Strictly visible only to Admin & Responsible Person) -->
@if($sentiment === 'angry' && $latestNote && $canViewAngry)
<div class="angry-alert-box">
<span class="angry-alert-text">⚠️ Client Dissatisfaction Detected</span>
<button class="btn-why-angry" onclick="openWhyAngryModal({{ $latestNote->id }})">
Why is he angry?
</button>
</div>
@endif
</div>
<div class="card-actions">
<a href="{{ route('client-calls.show', $client->id) }}" target="_blank" class="btn-hub" title="Open Client Hub in new tab">
<span>Open Client Hub</span>
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>
</a>
</div>
</div>
@endforeach
</div>
@endif
</main>
<!-- Add Client & Project Modal -->
<div id="addClientModal" class="modal-overlay">
<div class="modal-card">
<div class="modal-header">
<h2 class="modal-title">Add New Client & Project</h2>
<button class="modal-close" onclick="closeAddClientModal()">&times;</button>
</div>
<form action="{{ route('client-calls.store') }}" method="POST">
@csrf
<div class="form-row">
<div class="form-group">
<label class="form-label">Client / Contact Name *</label>
<input type="text" name="client_name" class="form-control" placeholder="e.g. Robert Miller" required>
</div>
<div class="form-group">
<label class="form-label">Client Email Address *</label>
<input type="email" name="client_email" class="form-control" placeholder="e.g. robert@acmecorp.com" required>
</div>
</div>
<div class="form-row">
<div class="form-group">
<label class="form-label">Company / Organization</label>
<input type="text" name="company_name" class="form-control" placeholder="e.g. Acme Corp">
</div>
<div class="form-group">
<label class="form-label">Phone Number</label>
<input type="text" name="client_phone" class="form-control" placeholder="e.g. +1 555 019 283">
</div>
</div>
<div class="form-group">
<label class="form-label">Project Name *</label>
<input type="text" name="project_name" class="form-control" placeholder="e.g. Enterprise Cloud ERP Migration" required>
</div>
<div class="form-group">
<label class="form-label">Project Details / Scope</label>
<textarea name="project_details" class="form-control" rows="3" placeholder="Brief description of the deliverables, milestones, and client requirements..."></textarea>
</div>
<div class="form-group">
<label class="form-label">Responsible Person (PM / TL / Director in charge) *</label>
<select name="responsible_user_id" class="form-control" required>
@foreach($managersAndLeads as $manager)
<option value="{{ $manager->id }}" {{ Auth::id() === $manager->id ? 'selected' : '' }}>
{{ $manager->name }} ({{ $manager->role }})
</option>
@endforeach
</select>
</div>
<div class="form-group">
<label class="form-label">Assign Team Members (Optional)</label>
<div class="team-members-grid">
@foreach($allUsers as $userItem)
<label class="member-checkbox-label">
<input type="checkbox" name="assigned_team_members[]" value="{{ $userItem->id }}">
<span>{{ $userItem->name }}</span>
</label>
@endforeach
</div>
</div>
<div style="display: flex; justify-content: flex-end; gap: 10px; margin-top: 1.5rem;">
<button type="button" class="nav-btn" onclick="closeAddClientModal()">Cancel</button>
<button type="submit" class="nav-btn-primary nav-btn">Create Client Profile</button>
</div>
</form>
</div>
</div>
<!-- Why Is He Angry Modal (Confidential to Admin & Responsible Person) -->
<div id="whyAngryModal" class="modal-overlay">
<div class="modal-card" style="max-width: 650px; border-color: rgba(239, 68, 68, 0.4);">
<div class="modal-header">
<div>
<h2 class="modal-title" style="color: #f87171; display: flex; align-items: center; gap: 8px;">
<span>😡</span> AI Root-Cause Analysis: Why is the client angry?
</h2>
<p style="font-size: 0.75rem; color: #fca5a5; margin-top: 4px;">Strictly Confidential &bull; Restricted to Admin and Assigned Lead</p>
</div>
<button class="modal-close" onclick="closeWhyAngryModal()">&times;</button>
</div>
<div id="whyAngryContent">
<div style="text-align: center; padding: 2rem; color: var(--text-muted);">
Loading AI Analysis...
</div>
</div>
<div style="display: flex; justify-content: flex-end; margin-top: 1.5rem;">
<button type="button" class="nav-btn" onclick="closeWhyAngryModal()">Close</button>
</div>
</div>
</div>
<script>
function openAddClientModal() {
document.getElementById('addClientModal').style.display = 'flex';
}
function closeAddClientModal() {
document.getElementById('addClientModal').style.display = 'none';
}
function filterCards() {
const query = document.getElementById('searchInput').value.toLowerCase();
const sentiment = document.getElementById('sentimentFilter').value;
const cards = document.querySelectorAll('.client-card');
cards.forEach(card => {
const name = card.dataset.name || '';
const project = card.dataset.project || '';
const company = card.dataset.company || '';
const lead = card.dataset.lead || '';
const cardSentiment = card.dataset.sentiment || '';
const matchesQuery = name.includes(query) || project.includes(query) || company.includes(query) || lead.includes(query);
const matchesSentiment = (sentiment === 'all') || (cardSentiment === sentiment);
if (matchesQuery && matchesSentiment) {
card.style.display = 'flex';
} else {
card.style.display = 'none';
}
});
}
async function openWhyAngryModal(noteId) {
const modal = document.getElementById('whyAngryModal');
const content = document.getElementById('whyAngryContent');
modal.style.display = 'flex';
content.innerHTML = '<div style="text-align:center;padding:2rem;color:var(--text-muted);">Analyzing transcript and emotion triggers...</div>';
try {
const res = await fetch(`/client-calls/notes/${noteId}/angry-analysis`, {
headers: { 'Accept': 'application/json', 'X-Requested-With': 'XMLHttpRequest' }
});
const data = await res.json();
if (!res.ok) {
content.innerHTML = `<div style="color:#f87171;padding:1rem;background:rgba(239,68,68,0.1);border-radius:8px;">${data.error || 'Access Denied.'}</div>`;
return;
}
const analysis = data.angry_analysis || {};
const triggers = analysis.trigger_words || [];
const grievances = analysis.grievances || [];
content.innerHTML = `
<div style="margin-bottom: 1.25rem;">
<div style="font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px;">Client & Project</div>
<div style="font-weight: 700; font-size: 1.1rem; color: var(--text-main);">${data.client_name} &bull; ${data.project_name}</div>
</div>
<div style="background: rgba(239,68,68,0.1); border-left: 4px solid #ef4444; padding: 14px; border-radius: 0 8px 8px 0; margin-bottom: 1.25rem;">
<div style="font-weight: 700; font-size: 0.85rem; color: #fca5a5; margin-bottom: 6px; text-transform: uppercase;">AI Executive Breakdown</div>
<p style="font-size: 0.9rem; color: #fee2e2; line-height: 1.5;">${analysis.summary_why_angry || 'Client showed frustration during the meeting.'}</p>
</div>
${triggers.length > 0 ? `
<div style="margin-bottom: 1.25rem;">
<div style="font-weight: 600; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px;">Identified Angry / Negative Keywords:</div>
<div style="display: flex; flex-wrap: wrap; gap: 6px;">
${triggers.map(t => `<span style="background: rgba(239,68,68,0.25); color: #fca5a5; font-size: 0.75rem; padding: 3px 8px; border-radius: 4px; border: 1px solid rgba(239,68,68,0.4); font-weight: 600;">"${t}"</span>`).join('')}
</div>
</div>
` : ''}
${grievances.length > 0 ? `
<div style="margin-bottom: 1.25rem;">
<div style="font-weight: 600; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px;">Key Complaints / Pain Points:</div>
<ul style="padding-left: 20px; font-size: 0.85rem; color: #cbd5e1; line-height: 1.6;">
${grievances.map(g => `<li>${g}</li>`).join('')}
</ul>
</div>
` : ''}
${analysis.suggested_remedy ? `
<div style="background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); border-radius: 8px; padding: 12px;">
<div style="font-weight: 700; font-size: 0.8rem; color: #34d399; margin-bottom: 4px; text-transform: uppercase;">💡 Recommended Action for PM & Director:</div>
<p style="font-size: 0.85rem; color: #d1fae5; line-height: 1.5;">${analysis.suggested_remedy}</p>
</div>
` : ''}
`;
} catch (err) {
content.innerHTML = `<div style="color:#f87171;padding:1rem;">Failed to load analysis. Please try again.</div>`;
}
}
function toggleTheme() {
const isLight = document.documentElement.classList.toggle('light-mode');
localStorage.setItem('theme', isLight ? 'light' : 'dark');
const btn = document.getElementById('themeToggleBtn');
if (btn) btn.innerText = isLight ? '☀️' : '🌙';
}
document.addEventListener('DOMContentLoaded', () => {
const isLight = document.documentElement.classList.contains('light-mode');
const btn = document.getElementById('themeToggleBtn');
if (btn) btn.innerText = isLight ? '☀️' : '🌙';
});
function closeWhyAngryModal() {
document.getElementById('whyAngryModal').style.display = 'none';
}
</script>
</body>
</html>