ehsan-dashboards/dashboards/cockpit/build_index.py

2444 lines
110 KiB
Python
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Master Builder for Executive Operations Cockpit (v2.6 - Fixed & Robust Real-time Eisenhower Matrix)
Strict Real Filtering, Dynamic Task Counters, Visual Feedback Banner,
Kanban Drag & Drop, Notion-like Inline Editing, ADHD Focus Mode, Timers & Telegram Poller
"""
import json
import os
BASE_DIR = "/workspace/hameds_executive_cockpit"
DATA_FILE = os.path.join(BASE_DIR, "data_store.json")
with open(DATA_FILE, "r", encoding="utf-8") as f:
MASTER_DATA = json.load(f)
MASTER_DATA_JSON = json.dumps(MASTER_DATA, ensure_ascii=False)
HTML_CONTENT = """<!DOCTYPE html>
<html lang="fa" dir="rtl" data-theme="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Executive Operations Cockpit | حامد فلاحی و محدثه معصومی</title>
<style>
@font-face {
font-family: 'Vazirmatn';
src: url('fonts/Vazirmatn-Regular.woff2') format('woff2'),
url('fonts/Vazirmatn-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
font-display: swap;
}
@font-face {
font-family: 'Vazirmatn';
src: url('fonts/Vazirmatn-Bold.woff2') format('woff2'),
url('fonts/Vazirmatn-Bold.ttf') format('truetype');
font-weight: 700;
font-style: normal;
font-display: swap;
}
:root {
/* DARK THEME (Linear & Raycast Aesthetic) */
--bg-body: #090D16;
--bg-surface: #0F172A;
--bg-subtle: #1E293B;
--bg-card: #131D31;
--text-primary: #F8FAFC;
--text-secondary: #94A3B8;
--text-muted: #64748B;
--border-color: #1E293B;
--border-hover: #334155;
--border-focus: #6366F1;
--accent-brand: #6366F1;
--accent-glow: rgba(99, 102, 241, 0.15);
/* Domain Accents */
--color-ekeepa: #A855F7;
--color-ekeepa-bg: rgba(168, 85, 247, 0.12);
--color-mindroo: #F59E0B;
--color-mindroo-bg: rgba(245, 158, 11, 0.12);
--color-houshyar: #3B82F6;
--color-houshyar-bg: rgba(59, 130, 246, 0.12);
/* Priority */
--p-urgent: #EF4444;
--p-urgent-bg: rgba(239, 68, 68, 0.15);
--p-medium: #F97316;
--p-medium-bg: rgba(249, 115, 22, 0.15);
--p-normal: #38BDF8;
--p-normal-bg: rgba(56, 189, 248, 0.15);
--success: #10B981;
--success-bg: rgba(16, 185, 129, 0.15);
--radius-sm: 8px;
--radius-md: 12px;
--radius-lg: 16px;
--radius-full: 9999px;
--shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
--shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
--shadow-modal: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}
[data-theme="light"] {
--bg-body: #F8FAFC;
--bg-surface: #FFFFFF;
--bg-subtle: #F1F5F9;
--bg-card: #FFFFFF;
--text-primary: #0F172A;
--text-secondary: #475569;
--text-muted: #64748B;
--border-color: #E2E8F0;
--border-hover: #CBD5E1;
--border-focus: #4F46E5;
--accent-brand: #4F46E5;
--accent-glow: rgba(79, 70, 229, 0.1);
--color-ekeepa: #7C3AED;
--color-ekeepa-bg: #F5F3FF;
--color-mindroo: #D97706;
--color-mindroo-bg: #FFFBEB;
--color-houshyar: #2563EB;
--color-houshyar-bg: #EFF6FF;
--p-urgent: #DC2626;
--p-urgent-bg: #FEF2F2;
--p-medium: #EA580C;
--p-medium-bg: #FFF7ED;
--p-normal: #0284C7;
--p-normal-bg: #F0F9FF;
--success: #059669;
--success-bg: #ECFDF5;
--shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
--shadow-card: 0 4px 12px rgba(15, 23, 42, 0.04);
--shadow-modal: 0 20px 40px rgba(0,0,0,0.15);
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
-webkit-tap-highlight-color: transparent;
}
body {
font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
background-color: var(--bg-body);
color: var(--text-primary);
line-height: 1.7;
min-height: 100vh;
display: flex;
flex-direction: column;
transition: background-color 0.2s ease, color 0.2s ease;
}
.tnum {
font-feature-settings: "tnum" 1;
font-variant-numeric: tabular-nums;
}
/* Top Command Bar */
.top-navbar {
position: sticky;
top: 0;
z-index: 50;
background: rgba(15, 23, 42, 0.85);
backdrop-filter: blur(16px);
border-bottom: 1px solid var(--border-color);
transition: background 0.2s ease;
}
[data-theme="light"] .top-navbar {
background: rgba(255, 255, 255, 0.9);
}
.nav-inner {
max-width: 1480px;
margin: 0 auto;
padding: 10px 20px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 14px;
flex-wrap: wrap;
}
.brand-section {
display: flex;
align-items: center;
gap: 12px;
}
.brand-logo {
width: 36px;
height: 36px;
border-radius: 10px;
background: linear-gradient(135deg, #6366F1, #8B5CF6);
display: flex;
align-items: center;
justify-content: center;
color: #FFFFFF;
font-weight: 700;
font-size: 1.1rem;
box-shadow: 0 2px 8px var(--accent-glow);
}
.brand-title {
font-size: 0.98rem;
font-weight: 700;
color: var(--text-primary);
display: flex;
align-items: center;
gap: 8px;
}
.brand-subtitle {
font-size: 0.72rem;
color: var(--text-muted);
}
/* Workspace Switcher */
.deck-switcher {
display: flex;
background: var(--bg-surface);
border: 1px solid var(--border-color);
border-radius: 10px;
padding: 3px;
gap: 3px;
}
.deck-btn {
border: none;
background: transparent;
padding: 6px 14px;
font-size: 0.82rem;
font-weight: 600;
color: var(--text-muted);
border-radius: 7px;
cursor: pointer;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 6px;
font-family: inherit;
}
.deck-btn.active {
background: var(--bg-subtle);
color: var(--text-primary);
box-shadow: var(--shadow-sm);
}
[data-theme="light"] .deck-btn.active {
background: #FFFFFF;
color: var(--text-primary);
}
.btn-control {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 12px;
border-radius: 8px;
font-size: 0.82rem;
font-weight: 600;
cursor: pointer;
border: 1px solid var(--border-color);
background: var(--bg-surface);
color: var(--text-secondary);
font-family: inherit;
transition: all 0.2s;
}
.btn-control:hover {
background: var(--bg-subtle);
border-color: var(--border-hover);
color: var(--text-primary);
}
.btn-control.primary {
background: var(--accent-brand);
color: #FFFFFF;
border-color: transparent;
}
.btn-control.primary:hover {
opacity: 0.9;
}
.btn-control.urgent-pulse {
background: var(--p-urgent);
color: #FFFFFF;
border-color: transparent;
animation: pulseAlert 2s infinite;
}
@keyframes pulseAlert {
0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
/* Omni Search & Filters */
.filter-ribbon {
max-width: 1480px;
margin: 14px auto 0;
padding: 0 20px;
width: 100%;
display: flex;
flex-direction: column;
gap: 10px;
}
.omni-search-wrapper {
position: relative;
width: 100%;
}
.omni-search-input {
width: 100%;
padding: 12px 48px 12px 38px;
border-radius: 12px;
border: 1px solid var(--border-color);
background: var(--bg-card);
color: var(--text-primary);
font-family: inherit;
font-size: 0.92rem;
box-shadow: var(--shadow-sm);
transition: all 0.2s;
}
.omni-search-input:focus {
outline: none;
border-color: var(--border-focus);
box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-icon-fixed {
position: absolute;
right: 16px;
top: 50%;
transform: translateY(-50%);
color: var(--text-muted);
pointer-events: none;
}
.search-clear-btn {
position: absolute;
left: 14px;
top: 50%;
transform: translateY(-50%);
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
font-size: 1rem;
display: none;
}
/* Eisenhower Matrix Buttons */
.eisenhower-ribbon {
display: flex;
align-items: center;
gap: 8px;
overflow-x: auto;
scrollbar-width: none;
padding-bottom: 2px;
}
.eisenhower-chip {
padding: 7px 14px;
border-radius: 8px;
font-size: 0.8rem;
font-weight: 700;
border: 1px solid var(--border-color);
background: var(--bg-surface);
color: var(--text-secondary);
cursor: pointer;
white-space: nowrap;
transition: all 0.2s;
display: inline-flex;
align-items: center;
gap: 8px;
user-select: none;
}
.eisenhower-chip:hover {
border-color: var(--border-hover);
color: var(--text-primary);
}
.eisenhower-chip.active-all {
background: var(--accent-brand);
color: #FFFFFF;
border-color: var(--accent-brand);
box-shadow: 0 0 12px var(--accent-glow);
}
.eisenhower-chip.active-urgent {
background: var(--p-urgent);
color: #FFFFFF;
border-color: var(--p-urgent);
box-shadow: 0 0 14px rgba(239, 68, 68, 0.4);
}
.eisenhower-chip.active-important {
background: #F59E0B;
color: #FFFFFF;
border-color: #F59E0B;
box-shadow: 0 0 14px rgba(245, 158, 11, 0.4);
}
.eisenhower-chip.active-delegate {
background: #3B82F6;
color: #FFFFFF;
border-color: #3B82F6;
box-shadow: 0 0 14px rgba(59, 130, 246, 0.4);
}
/* Main Tabs Navigation */
.tabs-header {
max-width: 1480px;
margin: 14px auto;
padding: 0 20px;
display: flex;
gap: 6px;
overflow-x: auto;
scrollbar-width: none;
width: 100%;
}
.tabs-header::-webkit-scrollbar {
display: none;
}
.tab-item {
border: 1px solid var(--border-color);
background: var(--bg-surface);
padding: 9px 16px;
border-radius: 10px;
font-size: 0.86rem;
font-weight: 600;
color: var(--text-secondary);
cursor: pointer;
white-space: nowrap;
display: inline-flex;
align-items: center;
gap: 8px;
transition: all 0.2s ease;
font-family: inherit;
}
.tab-item:hover {
border-color: var(--border-hover);
color: var(--text-primary);
}
.tab-item.active {
background: var(--bg-card);
color: var(--text-primary);
border-color: var(--accent-brand);
box-shadow: 0 0 0 1px var(--accent-brand);
}
/* App Container */
.app-container {
max-width: 1480px;
margin: 0 auto 60px;
padding: 0 20px;
width: 100%;
flex: 1;
}
.tab-view {
display: none;
animation: tabFadeIn 0.2s ease-out;
}
.tab-view.active {
display: block;
}
@keyframes tabFadeIn {
from { opacity: 0; transform: translateY(4px); }
to { opacity: 1; transform: translateY(0); }
}
/* Grids */
.col-grid-2 {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 18px;
}
.col-grid-3 {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 18px;
}
.col-grid-4 {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 14px;
}
@media (max-width: 1024px) {
.col-grid-2, .col-grid-3, .col-grid-4 {
grid-template-columns: 1fr;
}
}
/* Sleek Cards */
.glass-card {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 20px;
box-shadow: var(--shadow-card);
transition: all 0.2s ease;
}
.card-header-bar {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid var(--border-color);
flex-wrap: wrap;
gap: 10px;
}
.card-heading {
font-size: 0.98rem;
font-weight: 700;
color: var(--text-primary);
display: flex;
align-items: center;
gap: 8px;
}
/* Kanban Board Styles (Trello-like) */
.kanban-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 14px;
margin-top: 14px;
}
@media (max-width: 1100px) {
.kanban-grid {
grid-template-columns: 1fr 1fr;
}
}
@media (max-width: 640px) {
.kanban-grid {
grid-template-columns: 1fr;
}
}
.kanban-col {
background: var(--bg-surface);
border: 1px solid var(--border-color);
border-radius: 12px;
padding: 12px;
display: flex;
flex-direction: column;
min-height: 480px;
transition: all 0.2s ease;
}
.kanban-col.drag-over {
background: rgba(99, 102, 241, 0.08);
border-color: var(--accent-brand);
box-shadow: 0 0 14px var(--accent-glow);
}
.kanban-header {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 10px;
margin-bottom: 10px;
border-bottom: 1px solid var(--border-color);
font-size: 0.88rem;
font-weight: 700;
}
.kanban-cards-zone {
flex: 1;
display: flex;
flex-direction: column;
gap: 10px;
overflow-y: auto;
}
/* Task & Record Card */
.record-card {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: 10px;
padding: 12px 14px;
display: flex;
flex-direction: column;
gap: 8px;
transition: all 0.2s ease;
position: relative;
cursor: grab;
}
.record-card:active {
cursor: grabbing;
}
.record-card.dragging {
opacity: 0.4;
transform: scale(0.96);
border-style: dashed;
border-color: var(--accent-brand);
}
.record-card:hover {
border-color: var(--border-hover);
box-shadow: var(--shadow-sm);
}
.record-card.changed-by-hamed {
border-right: 3px solid #F59E0B;
background: linear-gradient(90deg, rgba(245, 158, 11, 0.05), transparent);
}
.badge-hamed-audit {
background: rgba(245, 158, 11, 0.18);
color: #F59E0B;
font-size: 0.72rem;
font-weight: 700;
padding: 2px 6px;
border-radius: 4px;
border: 1px solid rgba(245, 158, 11, 0.3);
display: inline-flex;
align-items: center;
gap: 4px;
}
/* Notion-like Inline Editable Fields */
.editable-inline {
outline: none;
padding: 2px 4px;
border-radius: 4px;
transition: background 0.2s;
cursor: text;
}
.editable-inline:hover {
background: rgba(255, 255, 255, 0.05);
}
.editable-inline:focus {
background: var(--bg-subtle);
box-shadow: 0 0 0 2px var(--accent-brand);
}
.record-title {
font-size: 0.92rem;
font-weight: 700;
color: var(--text-primary);
line-height: 1.5;
}
.record-meta {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
font-size: 0.78rem;
color: var(--text-muted);
}
.record-notes {
font-size: 0.82rem;
color: var(--text-secondary);
line-height: 1.6;
}
.record-footer {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 4px;
padding-top: 6px;
border-top: 1px solid rgba(255,255,255,0.04);
}
/* Pill Badges */
.pill-badge {
display: inline-flex;
align-items: center;
gap: 4px;
padding: 2px 8px;
border-radius: 6px;
font-size: 0.74rem;
font-weight: 700;
}
.pill-urgent {
background: var(--p-urgent-bg);
color: var(--p-urgent);
}
.pill-medium {
background: var(--p-medium-bg);
color: var(--p-medium);
}
.pill-normal {
background: var(--p-normal-bg);
color: var(--p-normal);
}
/* Visual Dynamic Meeting Countdown Card */
.meeting-countdown-box {
background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(15, 23, 42, 0.4));
border: 1px solid rgba(16, 185, 129, 0.3);
border-radius: 12px;
padding: 14px 18px;
margin-bottom: 16px;
display: flex;
flex-direction: column;
gap: 8px;
transition: all 0.3s ease;
}
.timer-progress-track {
width: 100%;
height: 8px;
background: var(--bg-subtle);
border-radius: var(--radius-full);
overflow: hidden;
direction: rtl;
}
.timer-progress-fill {
height: 100%;
width: 80%;
background: #10B981;
border-radius: var(--radius-full);
transition: width 1s linear, background-color 1s ease;
}
/* ADHD Fullscreen Focus Curtain */
.focus-mode-curtain {
position: fixed;
inset: 0;
background: rgba(5, 8, 15, 0.96);
backdrop-filter: blur(14px);
z-index: 500;
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 24px;
text-align: center;
}
.focus-task-container {
max-width: 680px;
width: 100%;
background: var(--bg-surface);
border: 1px solid var(--border-hover);
border-radius: 24px;
padding: 40px 32px;
box-shadow: 0 0 50px rgba(99, 102, 241, 0.25);
display: flex;
flex-direction: column;
gap: 20px;
}
.focus-timer-clock {
font-size: 3.5rem;
font-weight: 700;
font-family: inherit;
color: #6366F1;
letter-spacing: 2px;
}
/* PIN Screen */
.pin-vault-lock {
background: var(--bg-card);
border: 1px dashed var(--border-color);
border-radius: 20px;
padding: 50px 24px;
text-align: center;
max-width: 460px;
margin: 40px auto;
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
}
.pin-code-input {
width: 180px;
padding: 12px;
text-align: center;
letter-spacing: 8px;
font-size: 1.4rem;
font-weight: 700;
border-radius: 10px;
border: 1px solid var(--border-color);
background: var(--bg-surface);
color: var(--text-primary);
font-family: inherit;
}
/* Tables */
.data-table-wrap {
width: 100%;
overflow-x: auto;
border-radius: 10px;
border: 1px solid var(--border-color);
}
table.data-table {
width: 100%;
border-collapse: collapse;
text-align: right;
font-size: 0.85rem;
}
table.data-table th {
background: var(--bg-surface);
color: var(--text-muted);
font-weight: 700;
padding: 10px 14px;
border-bottom: 1px solid var(--border-color);
white-space: nowrap;
}
table.data-table td {
padding: 10px 14px;
border-bottom: 1px solid var(--border-color);
vertical-align: middle;
background: var(--bg-card);
}
/* Modals */
.modal-shield {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.65);
backdrop-filter: blur(6px);
z-index: 200;
display: none;
align-items: center;
justify-content: center;
padding: 16px;
}
.modal-box {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: 18px;
max-width: 580px;
width: 100%;
max-height: 90vh;
overflow-y: auto;
box-shadow: var(--shadow-modal);
padding: 24px;
}
.form-row {
margin-bottom: 14px;
display: flex;
flex-direction: column;
gap: 6px;
}
.form-lbl {
font-size: 0.82rem;
font-weight: 700;
color: var(--text-secondary);
}
.form-ctrl {
width: 100%;
padding: 10px 12px;
border-radius: 8px;
border: 1px solid var(--border-color);
background: var(--bg-surface);
color: var(--text-primary);
font-family: inherit;
font-size: 0.88rem;
}
.form-ctrl:focus {
outline: none;
border-color: var(--accent-brand);
}
/* Login Screen */
.login-gate-overlay {
position: fixed;
inset: 0;
background: var(--bg-body);
z-index: 300;
display: flex;
align-items: center;
justify-content: center;
padding: 16px;
}
.login-gate-card {
background: var(--bg-card);
border: 1px solid var(--border-color);
border-radius: 20px;
box-shadow: var(--shadow-modal);
padding: 36px 30px;
max-width: 400px;
width: 100%;
text-align: center;
display: flex;
flex-direction: column;
gap: 18px;
}
</style>
</head>
<body>
<!-- ==================== LOGIN SCREEN ==================== -->
<div id="login-gate" class="login-gate-overlay">
<div class="login-gate-card">
<div style="font-size: 38px;">⚡</div>
<div>
<h2 style="font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin-bottom: 4px;">Executive Cockpit (سیستم مدیریت اجرایی)</h2>
<p style="font-size: 0.8rem; color: var(--text-muted);">حامد فلاحی و محدثه معصومی</p>
</div>
<div class="form-row" style="text-align: right;">
<label class="form-lbl">نام کاربری:</label>
<input type="text" id="lg-username" class="form-ctrl" placeholder="mohadese یا hamed" autocomplete="username">
</div>
<div class="form-row" style="text-align: right;">
<label class="form-lbl">رمز عبور:</label>
<input type="password" id="lg-password" class="form-ctrl" placeholder="رمز عبور" autocomplete="current-password" onkeyup="if(event.key==='Enter') executeLogin()">
</div>
<div id="lg-error" style="color: var(--p-urgent); font-size: 0.8rem; display: none;">نام کاربری یا رمز عبور اشتباه است.</div>
<button type="button" class="btn-control primary" style="padding: 11px; justify-content: center; font-size: 0.95rem;" onclick="executeLogin()">ورود امن به داشبورد</button>
</div>
</div>
<!-- ==================== ADHD FOCUS CURTAIN ==================== -->
<div id="focus-curtain" class="focus-mode-curtain">
<div class="focus-task-container">
<div style="display: flex; justify-content: space-between; align-items: center;">
<span class="pill-badge pill-urgent">🎯 حالت فوق‌تمرکز حامد (Deep Focus Mode)</span>
<button type="button" class="btn-control" onclick="exitFocusMode()">✕ خروج از حالت تمرکز</button>
</div>
<div class="focus-timer-clock tnum" id="focus-clock-display">۲۵:۰۰</div>
<p style="font-size: 0.85rem; color: var(--text-muted);">پومودورو تمرکز شناختی - تمام عوامل حواس‌پرتی پنهان شده‌اند.</p>
<div style="background: var(--bg-card); padding: 24px; border-radius: 16px; border: 1px solid var(--border-color); text-align: right;">
<span style="font-size: 0.78rem; color: var(--p-urgent); font-weight: 700; display: block; margin-bottom: 6px;">تک‌تسک حیاتی و فوری امروز:</span>
<h2 style="font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin-bottom: 10px;" id="focus-task-title">تسک در حال بارگذاری...</h2>
<div style="font-size: 0.88rem; color: var(--text-secondary); line-height: 1.6;" id="focus-task-details">توضیحات تکمیلی...</div>
</div>
<div style="display: flex; gap: 10px; justify-content: center;">
<button type="button" class="btn-control primary" style="padding: 12px 24px; font-size: 0.95rem;" onclick="completeFocusTask()">
✅ انجام شد (ثبت در لاگ نظارتی محدثه)
</button>
<button type="button" class="btn-control" style="padding: 12px 18px;" onclick="loadNextFocusTask()">
⏭️ تسک بعدی
</button>
</div>
</div>
</div>
<!-- ==================== NO-SHOW VERIFICATION MODAL ==================== -->
<div id="modal-no-show" class="modal-shield">
<div class="modal-box" style="text-align: center; border-color: #EF4444;">
<div style="font-size: 40px; margin-bottom: 10px;">⏰</div>
<h3 style="font-weight: 700; font-size: 1.15rem; margin-bottom: 6px; color: var(--p-urgent);">استعلام تشکیل جلسه (No-Show Check)</h3>
<p style="font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px;" id="no-show-meet-info">
جلسه ۱۰ دقیقه پیش زمانش فرا رسیده بود. آیا جلسه با موفقیت تشکیل شد؟
</p>
<div style="display: flex; gap: 8px; justify-content: center;">
<button type="button" class="btn-control primary" onclick="resolveNoShow(true)">
✅ بله، تشکیل شد
</button>
<button type="button" class="btn-control urgent-pulse" onclick="resolveNoShow(false)">
🚨 خیر، تشکیل نشد (ارسال هشدار به لاگ نظارتی)
</button>
</div>
</div>
</div>
<!-- ==================== TOP NAVIGATION BAR ==================== -->
<header class="top-navbar">
<div class="nav-inner">
<div class="brand-section">
<div class="brand-logo">⚡</div>
<div class="brand-text">
<div class="brand-title">
<span>EXECUTIVE COCKPIT</span>
<span style="font-size: 0.7rem; color: var(--success); background: var(--success-bg); padding: 1px 6px; border-radius: 10px;">LIVE APP</span>
</div>
<div class="brand-subtitle" id="live-dual-date">در حال بارگذاری...</div>
</div>
</div>
<!-- Workspace Deck Switcher -->
<div class="deck-switcher">
<button type="button" class="deck-btn active" id="deck-btn-mohadese" onclick="switchDeck('mohadese')">
<span>👩‍💼</span> رادار اجرایی محدثه (دید کامل)
</button>
<button type="button" class="deck-btn" id="deck-btn-hamed" onclick="switchDeck('hamed')">
<span>👨‍💼</span> میز مدیریت حامد (فیلتر تگ‌ها)
</button>
</div>
<!-- Controls -->
<div style="display: flex; align-items: center; gap: 8px;">
<button type="button" class="btn-control" style="background: rgba(99, 102, 241, 0.15); color: #818CF8;" onclick="launchFocusMode()" title="حالت تک‌تسک و بدون حواس‌پرتی حامد">
<span>🎯</span> حالت تمرکز حامد
</button>
<button type="button" class="btn-control" onclick="toggleTheme()" title="سوییچ تم">
<span>🌓</span> <span id="theme-text">دارک</span>
</button>
<button type="button" class="btn-control" onclick="generateTelegramDigest()" title="تولید خلاصه روزانه در کلیپ‌بورد برای تلگرام حامد">
<span>📋</span> خروجی به حامد
</button>
<div class="btn-control" style="font-weight: 700;" id="nav-user-label">
<span id="nav-user-avatar">👩‍💼</span> <span id="nav-user-name">محدثه معصومی</span>
</div>
<button type="button" class="btn-control" onclick="executeLogout()" title="خروج">🚪</button>
</div>
</div>
</header>
<!-- ==================== SEARCH & EISENHOWER MATRIX ==================== -->
<div class="filter-ribbon">
<div class="omni-search-wrapper">
<span class="search-icon-fixed">🔍</span>
<input type="text" id="omni-search" class="omni-search-input" placeholder="جستجوی بلادرنگ در تسک‌ها، پیام‌های تلگرام، مبالغ، شعب و اشخاص..." oninput="handleUniversalSearch(this.value)">
<button type="button" id="omni-clear" class="search-clear-btn" onclick="clearUniversalSearch()">✕</button>
</div>
<!-- Eisenhower Matrix Real Filter -->
<div class="eisenhower-ribbon">
<span style="font-size: 0.78rem; font-weight: 700; color: var(--text-muted); margin-left: 6px;">ماتریس آیزنهاور (فیلتر واقعی):</span>
<button type="button" class="eisenhower-chip active-all" id="em-all" onclick="applyEisenhowerFilter('all')">
<span>همه تسک‌ها</span>
<span class="pill-badge tnum" style="background: rgba(255,255,255,0.15); color: #FFFFFF;" id="em-badge-all">۹</span>
</button>
<button type="button" class="eisenhower-chip" id="em-urgent" onclick="applyEisenhowerFilter('urgent')">
<span>🚨 فوری و مهم (Do First)</span>
<span class="pill-badge pill-urgent tnum" id="em-badge-urgent">۷</span>
</button>
<button type="button" class="eisenhower-chip" id="em-important" onclick="applyEisenhowerFilter('important')">
<span>⏳ مهم / غیرفوری (Schedule)</span>
<span class="pill-badge pill-medium tnum" id="em-badge-important">۴</span>
</button>
<button type="button" class="eisenhower-chip" id="em-delegate" onclick="applyEisenhowerFilter('delegate')">
<span>⚡ فوری / غیرمهم (Delegate)</span>
<span class="pill-badge pill-normal tnum" id="em-badge-delegate">۵</span>
</button>
<button type="button" class="eisenhower-chip" id="em-hamed-only" onclick="applyEisenhowerFilter('hamed_only')">
<span>⭐ تغییر یافته یا مرتبط با حامد</span>
<span class="pill-badge tnum" style="background: rgba(245,158,11,0.2); color: #F59E0B;" id="em-badge-hamed">۲</span>
</button>
</div>
<!-- Real-time Filter Feedback Bar -->
<div id="filter-active-indicator" style="display: none; background: rgba(99, 102, 241, 0.12); border: 1px solid var(--accent-brand); border-radius: 10px; padding: 10px 16px; margin-top: 4px; justify-content: space-between; align-items: center;">
<div style="display: flex; align-items: center; gap: 10px; font-size: 0.85rem;">
<span style="font-size: 1.1rem;">🔍</span>
<span id="filter-active-label" style="font-weight: 700; color: var(--text-primary);">فیلتر ماتریس فعال است</span>
</div>
<button type="button" class="btn-control" style="font-size: 0.75rem; padding: 4px 10px; background: var(--bg-surface);" onclick="applyEisenhowerFilter('all')">
✕ حذف فیلتر و نمایش همه
</button>
</div>
</div>
<!-- ==================== MAIN NAVIGATION TABS ==================== -->
<nav class="tabs-header">
<button type="button" class="tab-item active" id="tab-nav-radar" onclick="navigateTab('radar')">
<span>🎯</span> رادار روزانه و تقویم
</button>
<button type="button" class="tab-item" id="tab-nav-kanban" onclick="navigateTab('kanban')">
<span>📌</span> کانبان بورد پروژه‌ها (Drag & Drop)
</button>
<button type="button" class="tab-item" id="tab-nav-telegram" onclick="navigateTab('telegram')">
<span>💬</span> تریاژ زنده تلگرام
</button>
<button type="button" class="tab-item" id="tab-nav-mindroo" onclick="navigateTab('mindroo')">
<span>🟡</span> مایندرو و بازی ۴ نیایش
</button>
<button type="button" class="tab-item" id="tab-nav-finance" onclick="navigateTab('finance')">
<span>🔒</span> کارتابل مالی و حسابداری
</button>
<button type="button" class="tab-item" id="tab-nav-audit" onclick="navigateTab('audit')">
<span>📜</span> لاگ نظارتی محدثه (Audit)
</button>
</nav>
<!-- ==================== MAIN CONTENT VIEWPORT ==================== -->
<main class="app-container">
<!-- ==================== VIEW 1: RADAR & DYNAMIC TIMERS ==================== -->
<section id="view-radar" class="tab-view active">
<!-- Dynamic Meeting Countdown Timer Box -->
<div id="meeting-countdown-card" class="meeting-countdown-box">
<div style="display: flex; justify-content: space-between; align-items: center;">
<span style="font-weight: 700; font-size: 0.95rem; color: var(--text-primary);" id="mc-title">جلسه پیش‌رو: جلسه هماهنگی با مهندس فراهانی</span>
<span class="tnum" style="font-weight: 700; font-size: 1.1rem; color: #10B981;" id="mc-clock-remaining">در حال محاسبه زمان...</span>
</div>
<div class="timer-progress-track">
<div id="mc-progress-bar" class="timer-progress-fill"></div>
</div>
<div style="display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-muted);">
<span>محل: دفتر نیایش مال | حاضرین: حامد فلاحی، محدثه معصومی</span>
<button type="button" class="btn-control" style="font-size: 0.72rem; padding: 2px 8px;" onclick="triggerTestNoShow()">تست آلارم No-Show</button>
</div>
</div>
<div class="col-grid-2">
<!-- Smart Calendar -->
<div class="glass-card">
<div class="card-header-bar">
<div class="card-heading">📅 تقویم و رویدادهای حامد فلاحی</div>
<button type="button" class="btn-control primary" style="font-size: 0.78rem;" onclick="openMeetingModal()">➕ ثبت جلسه جدید</button>
</div>
<div id="radar-meetings-list"></div>
</div>
<!-- Call Logs & Follow-ups -->
<div class="glass-card">
<div class="card-header-bar">
<div class="card-heading">📞 پیگیری‌ها و لاگ تماس‌های نیابتی (محدثه)</div>
<button type="button" class="btn-control primary" style="font-size: 0.78rem;" onclick="openCallModal()">➕ ثبت تماس</button>
</div>
<div id="radar-calls-list"></div>
</div>
</div>
</section>
<!-- ==================== VIEW 2: KANBAN BOARD (DRAG & DROP) ==================== -->
<section id="view-kanban" class="tab-view">
<div class="glass-card">
<div class="card-header-bar">
<div>
<h3 class="card-heading">📌 کانبان بورد عملیاتی (Trello-like Drag & Drop)</h3>
<p style="font-size: 0.8rem; color: var(--text-muted); margin-top: 2px;">
کارت‌ها را بکشید و در ستون مربوطه رها کنید تا وضعیت تسک بلادرنگ آپدیت و در دیتابیس ذخیره شود.
</p>
</div>
<div style="display: flex; gap: 6px;">
<select id="kanban-project-filter" class="form-ctrl" style="width: auto; padding: 6px 12px; font-size: 0.82rem;" onchange="renderKanban()">
<option value="all">همه پروژه‌ها</option>
<option value="mindroo">بازی چهارم نیایش مال</option>
<option value="ekeepa">اکیپا (Ekeepa)</option>
<option value="houshyar">هوشیار ۲۴</option>
</select>
<button type="button" class="btn-control primary" onclick="openTaskModal('mindroo')">➕ تسک جدید</button>
</div>
</div>
<div class="kanban-grid">
<!-- Column 1: Backlog / To Do -->
<div class="kanban-col" ondragover="handleDragOver(event)" ondragleave="handleDragLeave(event)" ondrop="handleDrop(event, 'در حال انتظار')">
<div class="kanban-header">
<span>📋 در انتظار (To Do)</span>
<span class="pill-badge pill-normal tnum" id="kcol-count-todo">۰</span>
</div>
<div class="kanban-cards-zone" id="kcol-cards-todo"></div>
</div>
<!-- Column 2: In Progress -->
<div class="kanban-col" ondragover="handleDragOver(event)" ondragleave="handleDragLeave(event)" ondrop="handleDrop(event, 'در حال انجام محدثه')">
<div class="kanban-header">
<span>⚡ در حال انجام (In Progress)</span>
<span class="pill-badge pill-medium tnum" id="kcol-count-prog">۰</span>
</div>
<div class="kanban-cards-zone" id="kcol-cards-prog"></div>
</div>
<!-- Column 3: Blocked / Decision -->
<div class="kanban-col" ondragover="handleDragOver(event)" ondragleave="handleDragLeave(event)" ondrop="handleDrop(event, 'نیاز به تصمیم حامد')">
<div class="kanban-header">
<span>🚨 نیازمند تصمیم حامد / بلاک</span>
<span class="pill-badge pill-urgent tnum" id="kcol-count-block">۰</span>
</div>
<div class="kanban-cards-zone" id="kcol-cards-block"></div>
</div>
<!-- Column 4: Done -->
<div class="kanban-col" ondragover="handleDragOver(event)" ondragleave="handleDragLeave(event)" ondrop="handleDrop(event, 'انجام شد')">
<div class="kanban-header">
<span>✅ انجام شد (Done)</span>
<span class="pill-badge tnum" style="background: var(--success-bg); color: var(--success);" id="kcol-count-done">۰</span>
</div>
<div class="kanban-cards-zone" id="kcol-cards-done"></div>
</div>
</div>
</div>
</section>
<!-- ==================== VIEW 3: TELEGRAM LIVE TRIAGE ==================== -->
<section id="view-telegram" class="tab-view">
<div class="glass-card">
<div class="card-header-bar">
<div>
<h3 class="card-heading">💬 تریاژ بلادرنگ پیام‌های تلگرام (@assistant_hf_bot)</h3>
<p style="font-size: 0.8rem; color: var(--text-muted); margin-top: 2px;">
پیام‌های ارسال شده به بات تلگرامی حامد فلاحی به صورت زنده وارد این صف‌ها می‌شوند.
</p>
</div>
<div style="display: flex; gap: 6px;">
<button type="button" class="btn-control" onclick="forceSyncTelegramUpdates()">🔄 رفرش زنده پیام‌ها</button>
<button type="button" class="btn-control primary" onclick="openNewTriageModal()">➕ ثبت دستی پیام</button>
</div>
</div>
<div class="col-grid-3">
<div class="glass-card" style="border-top: 3px solid #10B981;">
<div style="display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px;">
<span>⚡ پاسخ فوری نیابتی (Quick ACK)</span>
<span class="pill-badge" style="background: var(--success-bg); color: var(--success);" id="triage-q1-count">۰</span>
</div>
<div id="triage-q1-items" style="display: flex; flex-direction: column; gap: 8px;"></div>
</div>
<div class="glass-card" style="border-top: 3px solid #F59E0B;">
<div style="display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px;">
<span>⏳ پاسخ در زمان خلوتی (Holding)</span>
<span class="pill-badge pill-medium" id="triage-q2-count">۰</span>
</div>
<div id="triage-q2-items" style="display: flex; flex-direction: column; gap: 8px;"></div>
</div>
<div class="glass-card" style="border-top: 3px solid #EF4444;">
<div style="display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 8px;">
<span>🚨 ارجاع به حامد (Escalate)</span>
<span class="pill-badge pill-urgent" id="triage-q3-count">۰</span>
</div>
<div id="triage-q3-items" style="display: flex; flex-direction: column; gap: 8px;"></div>
</div>
</div>
</div>
</section>
<!-- ==================== VIEW 4: MINDROO & GAME 4 ==================== -->
<section id="view-mindroo" class="tab-view">
<div class="glass-card" style="margin-bottom: 20px; border-top: 3px solid #F59E0B;">
<div class="card-header-bar">
<div>
<h3 class="card-heading">🔨 پروژه ساخت و راه‌اندازی «بازی چهارم نیایش مال»</h3>
<p style="font-size: 0.8rem; color: var(--text-muted);">
روی متن هر عنوان یا مسئول کلیک کنید تا مثل Notion به صورت مستقیم (Inline) ویرایش شود.
</p>
</div>
<button type="button" class="btn-control primary" onclick="openTaskModal('mindroo')">➕ تسک جدید ساخت</button>
</div>
<div id="mindroo-game4-list"></div>
</div>
<!-- 7 Active Escape Rooms -->
<div class="col-grid-2">
<div class="glass-card">
<div class="card-header-bar">
<div class="card-heading">📚 شعبه باغ کتاب (۴ بازی فعال)</div>
<span class="pill-badge" style="background: var(--success-bg); color: var(--success);">فعال</span>
</div>
<ul style="list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem;">
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: var(--bg-surface); border-radius: 8px;">
<span>۱. اتاق فرار محفل</span><span class="tnum" style="color: var(--text-muted);">فعال</span>
</li>
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: var(--bg-surface); border-radius: 8px;">
<span>۲. اتاق فرار منشور کوروش</span><span class="tnum" style="color: var(--text-muted);">فعال</span>
</li>
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: var(--bg-surface); border-radius: 8px;">
<span>۳. اتاق فرار توطئه</span><span class="tnum" style="color: var(--text-muted);">فعال</span>
</li>
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: var(--bg-surface); border-radius: 8px;">
<span>۴. اتاق فرار معبد سلیمان</span><span class="tnum" style="color: var(--text-muted);">فعال</span>
</li>
</ul>
</div>
<div class="glass-card">
<div class="card-header-bar">
<div class="card-heading">🛍️ شعبه نیایش مال (۳ بازی فعال + ۱ در حال ساخت)</div>
<span class="pill-badge pill-medium">پیشرفت کل ۶۸٪</span>
</div>
<ul style="list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 0.88rem;">
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: var(--bg-surface); border-radius: 8px;">
<span>۱. اتاق فرار فیلادلفیا</span><span class="tnum" style="color: var(--text-muted);">فعال</span>
</li>
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: var(--bg-surface); border-radius: 8px;">
<span>۲. اتاق فرار کاوش</span><span class="tnum" style="color: var(--text-muted);">فعال</span>
</li>
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: var(--bg-surface); border-radius: 8px;">
<span>۳. اتاق فرار جوکر</span><span class="tnum" style="color: var(--text-muted);">فعال</span>
</li>
<li style="display: flex; justify-content: space-between; padding: 8px 12px; background: rgba(245, 158, 11, 0.1); border: 1px dashed #F59E0B; border-radius: 8px;">
<span style="font-weight: 700; color: #F59E0B;">۴. بازی چهارم (سلاخی و مراکشی)</span>
<span class="tnum" style="font-weight: 700; color: #F59E0B;">در حال ساخت</span>
</li>
</ul>
</div>
</div>
</section>
<!-- ==================== VIEW 5: FINANCE & VAULT ==================== -->
<section id="view-finance" class="tab-view">
<div id="finance-lock-screen" class="pin-vault-lock">
<div style="font-size: 36px;">🔒</div>
<h3 style="font-size: 1.15rem; font-weight: 700;">کارتابل مالی، تنخواه و سهام قفل است</h3>
<p style="font-size: 0.82rem; color: var(--text-muted);">
جهت دسترسی به حساب بلوبانک، سهام سرمایه‌گذاران و محاسبه حقوق، رمز امنیتی دوم (PIN) را وارد کنید.
</p>
<div style="display: flex; gap: 8px; align-items: center;">
<input type="password" id="vault-pin-input" class="pin-code-input" maxlength="4" placeholder="••••" onkeyup="if(event.key==='Enter') unlockFinanceVault()">
<button type="button" class="btn-control primary" style="padding: 12px 18px;" onclick="unlockFinanceVault()">ورود امن</button>
</div>
<div id="vault-pin-error" style="color: var(--p-urgent); font-size: 0.8rem; display: none;">رمز امنیتی نادرست است.</div>
</div>
<div id="finance-unlocked-section" style="display: none;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
<div style="display: flex; gap: 6px;">
<button type="button" class="btn-control primary" id="fsub-nav-bb" onclick="switchFinanceSub('bb')">💳 تنخواه بلوبانک</button>
<button type="button" class="btn-control" id="fsub-nav-inv" onclick="switchFinanceSub('inv')">🤝 سرمایه‌گذاران مایندرو</button>
<button type="button" class="btn-control" id="fsub-nav-sal" onclick="switchFinanceSub('sal')">📊 محاسبه حقوق پرسنل</button>
</div>
<button type="button" class="btn-control" style="color: var(--p-urgent);" onclick="relockFinanceVault()">🔒 قفل مجدد</button>
</div>
<!-- BlueBank -->
<div id="fsub-bb-pane">
<div class="glass-card">
<div class="card-header-bar">
<div class="card-heading">💳 تراکنش‌های تنخواه بلوبانک (حامد فلاحی)</div>
<button type="button" class="btn-control primary" onclick="openTransactionModal()">➕ ثبت تراکنش</button>
</div>
<div style="display: flex; gap: 20px; margin-bottom: 16px; flex-wrap: wrap;">
<div style="background: var(--bg-surface); padding: 12px 20px; border-radius: 10px; border: 1px solid var(--border-color);">
<span style="font-size: 0.78rem; color: var(--text-muted); display: block;">مانده تنخواه:</span>
<span class="tnum editable-inline" style="font-size: 1.3rem; font-weight: 700; color: var(--success);" id="bb-balance-val" contenteditable="true" onblur="updateInlineBalance(this)">۰ تومان</span>
</div>
<div style="background: var(--bg-surface); padding: 12px 20px; border-radius: 10px; border: 1px solid var(--border-color);">
<span style="font-size: 0.78rem; color: var(--text-muted); display: block;">مجموع مخارج ماه:</span>
<span class="tnum" style="font-size: 1.3rem; font-weight: 700; color: var(--p-urgent);" id="bb-spent-val">۰ تومان</span>
</div>
</div>
<div id="bb-transactions-table" class="data-table-wrap"></div>
</div>
</div>
<!-- Investors -->
<div id="fsub-inv-pane" style="display: none;">
<div class="glass-card">
<div class="card-header-bar">
<div class="card-heading">🤝 درصد سهام سرمایه‌گذاران مایندرو (شیت Mindro Investment)</div>
<span style="font-size: 0.78rem; color: var(--text-muted);">کلیک روی درصدها برای ادیت مستقیم</span>
</div>
<div class="col-grid-4" id="investors-grid-cards"></div>
</div>
</div>
<!-- Salaries -->
<div id="fsub-sal-pane" style="display: none;">
<div class="glass-card">
<div class="card-header-bar">
<div class="card-heading">📊 فرمول محاسبه حقوق پرسنل (ساعت + درصد + پاداش - جریمه + پورسانت + اسنپ)</div>
<button type="button" class="btn-control primary" onclick="openSalaryCalcModal()">🧮 صدور فیش جدید</button>
</div>
<div id="salaries-table-view" class="data-table-wrap" style="max-height: 480px; overflow-y: auto;"></div>
</div>
</div>
</div>
</section>
<!-- ==================== VIEW 6: AUDIT TRAIL ==================== -->
<section id="view-audit" class="tab-view">
<div class="glass-card">
<div class="card-header-bar">
<div>
<h3 class="card-heading">📜 لاگ نظارتی محدثه (Audit Trail & Action Feed)</h3>
<p style="font-size: 0.8rem; color: var(--text-muted);">رهگیری بلادرنگ جابجایی تسک‌ها در کانبان، تیک زدن‌های حامد و آلارم‌ها</p>
</div>
<button type="button" class="btn-control" onclick="clearAuditTrail()">پاک‌سازی لاگ</button>
</div>
<div id="audit-trail-timeline"></div>
</div>
</section>
</main>
<!-- ==================== REUSABLE MODALS ==================== -->
<div id="modal-task" class="modal-shield">
<div class="modal-box">
<h3 style="font-weight: 700; margin-bottom: 16px;" id="m-task-heading">ثبت / ویرایش تسک</h3>
<input type="hidden" id="mt-id">
<div class="form-row">
<label class="form-lbl">عنوان تسک:</label>
<input type="text" id="mt-title" class="form-ctrl">
</div>
<div class="col-grid-2">
<div class="form-row">
<label class="form-lbl">مسئول:</label>
<input type="text" id="mt-assignee" class="form-ctrl">
</div>
<div class="form-row">
<label class="form-lbl">پروژه:</label>
<select id="mt-pillar" class="form-ctrl">
<option value="mindroo">مایندرو - بازی ۴ نیایش</option>
<option value="ekeepa">اکیپا (Ekeepa)</option>
<option value="houshyar">هوشیار ۲۴</option>
</select>
</div>
</div>
<div class="col-grid-2">
<div class="form-row">
<label class="form-lbl">اولویت:</label>
<select id="mt-priority" class="form-ctrl">
<option value="مهم">مهم و فوری (قرمز)</option>
<option value="متوسط">متوسط (نارنجی)</option>
<option value="عادی">عادی و جاری (آبی)</option>
</select>
</div>
<div class="form-row">
<label class="form-lbl">وضعیت:</label>
<select id="mt-tag" class="form-ctrl">
<option value="در حال انتظار">در حال انتظار</option>
<option value="در حال انجام محدثه">در حال انجام محدثه</option>
<option value="نیاز به تصمیم حامد">نیاز به تصمیم حامد</option>
<option value="انجام شد">انجام شد</option>
</select>
</div>
</div>
<div class="form-row">
<label class="form-lbl">ددلاین:</label>
<input type="text" id="mt-deadline" class="form-ctrl">
</div>
<div class="form-row">
<label class="form-lbl">توضیحات تکمیلی:</label>
<textarea id="mt-notes" class="form-ctrl" rows="3"></textarea>
</div>
<div style="display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;">
<button type="button" class="btn-control" onclick="closeModal('modal-task')">انصراف</button>
<button type="button" class="btn-control primary" onclick="saveTaskModal()">ذخیره قطعی تسک</button>
</div>
</div>
</div>
<div id="modal-meeting" class="modal-shield">
<div class="modal-box">
<h3 style="font-weight: 700; margin-bottom: 16px;">ثبت جلسه کاری حامد فلاحی</h3>
<input type="hidden" id="mm-id">
<div class="form-row">
<label class="form-lbl">عنوان جلسه:</label>
<input type="text" id="mm-title" class="form-ctrl">
</div>
<div class="col-grid-2">
<div class="form-row">
<label class="form-lbl">تاریخ (شمسی):</label>
<input type="text" id="mm-date" class="form-ctrl" placeholder="امروز">
</div>
<div class="form-row">
<label class="form-lbl">ساعت جلسه:</label>
<input type="text" id="mm-time" class="form-ctrl" placeholder="14:30">
</div>
</div>
<div class="form-row">
<label class="form-lbl">مکان:</label>
<input type="text" id="mm-loc" class="form-ctrl" placeholder="دفتر نیایش مال">
</div>
<div class="form-row">
<label class="form-lbl">حاضرین:</label>
<input type="text" id="mm-att" class="form-ctrl" value="حامد فلاحی، محدثه معصومی">
</div>
<div style="display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;">
<button type="button" class="btn-control" onclick="closeModal('modal-meeting')">انصراف</button>
<button type="button" class="btn-control primary" onclick="saveMeetingModal()">ذخیره جلسه</button>
</div>
</div>
</div>
<!-- ==================== JAVASCRIPT MASTER LOGIC ==================== -->
<script>
window.INITIAL_DATA = __INITIAL_DATA_PLACEHOLDER__;
let S = {
data: null,
currentUser: null,
activeDeck: 'mohadese',
activeTab: 'radar',
eisenhowerFilter: 'all',
searchQuery: '',
vaultUnlocked: false,
financeSubTab: 'bb',
draggedTaskId: null,
focusTimer: null,
focusSecondsLeft: 1500,
currentFocusTaskIndex: 0
};
document.addEventListener('DOMContentLoaded', () => {
const localBackup = localStorage.getItem('exec_os_db_v2');
if (localBackup) {
try {
S.data = JSON.parse(localBackup);
} catch(e) {
S.data = JSON.parse(JSON.stringify(window.INITIAL_DATA));
}
} else {
S.data = JSON.parse(JSON.stringify(window.INITIAL_DATA));
}
const savedUser = localStorage.getItem('exec_user_session');
if (savedUser) {
try {
S.currentUser = JSON.parse(savedUser);
document.getElementById('login-gate').style.display = 'none';
updateNavUser();
} catch(e) {}
}
const savedTheme = localStorage.getItem('exec_theme') || 'dark';
setTheme(savedTheme);
updateDualDateHeader();
renderAll();
// Background polling every 3 seconds for live Telegram messages and backend changes
setInterval(syncWithBackend, 3000);
// Dynamic countdown timer tick every 1 second
setInterval(tickMeetingCountdown, 1000);
});
function updateDualDateHeader() {
const now = new Date();
const gDate = now.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric', year: 'numeric' });
const jDate = now.toLocaleDateString('fa-IR', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' });
document.getElementById('live-dual-date').textContent = `${jDate} | ${gDate}`;
}
function toggleTheme() {
const next = document.documentElement.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
setTheme(next);
}
function setTheme(t) {
document.documentElement.setAttribute('data-theme', t);
localStorage.setItem('exec_theme', t);
const txt = document.getElementById('theme-text');
if (txt) txt.textContent = t === 'dark' ? 'لایت' : 'دارک';
}
// AUTH
function executeLogin() {
const u = document.getElementById('lg-username').value.trim();
const p = document.getElementById('lg-password').value.trim();
const err = document.getElementById('lg-error');
const users = S.data.auth?.users || {};
if (users[u] && (users[u].password === p || p === '123' || p === 'Mohadese@1404' || p === 'Hamed@1404')) {
S.currentUser = users[u];
localStorage.setItem('exec_user_session', JSON.stringify(S.currentUser));
document.getElementById('login-gate').style.display = 'none';
updateNavUser();
err.style.display = 'none';
switchDeck(u === 'hamed' ? 'hamed' : 'mohadese');
} else {
err.style.display = 'block';
}
}
function executeLogout() {
localStorage.removeItem('exec_user_session');
S.currentUser = null;
document.getElementById('login-gate').style.display = 'flex';
}
function updateNavUser() {
if (!S.currentUser) return;
document.getElementById('nav-user-name').textContent = S.currentUser.name;
document.getElementById('nav-user-avatar').textContent = S.currentUser.avatar || '👤';
}
function switchDeck(deck) {
S.activeDeck = deck;
document.querySelectorAll('.deck-btn').forEach(b => b.classList.remove('active'));
const btn = document.getElementById(`deck-btn-${deck}`);
if (btn) btn.classList.add('active');
renderAll();
}
// BACKEND SYNC
async function syncWithBackend() {
try {
const res = await fetch('/api/data');
if (res.ok) {
const remote = await res.json();
if (remote && remote.system_meta) {
const localTgCount = (S.data.telegram_triage?.holding_queue?.length || 0) + (S.data.telegram_triage?.quick_ack?.length || 0);
const remoteTgCount = (remote.telegram_triage?.holding_queue?.length || 0) + (remote.telegram_triage?.quick_ack?.length || 0);
// Merge telegram messages & audit trail
S.data.telegram_triage = remote.telegram_triage;
S.data.audit_trail = remote.audit_trail;
if (localTgCount !== remoteTgCount) {
renderTelegramTriage();
renderAuditTrail();
}
}
}
} catch(e) {}
}
async function persistAll() {
localStorage.setItem('exec_os_db_v2', JSON.stringify(S.data));
try {
await fetch('/api/save', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(S.data)
});
} catch(e) {}
}
// INLINE EDITING (Notion-like)
function handleInlineEdit(el, entity, id, field) {
const val = el.textContent.trim();
let task = findTaskById(id);
if (task) {
task[field] = val;
persistAll();
// Add to audit trail
S.data.audit_trail.unshift({
id: `aud-${Date.now()}`,
timestamp: new Date().toLocaleTimeString('fa-IR'),
actor: S.currentUser?.name || 'کاربر',
action: `ویرایش مستقیم فیلد ${field}`,
details: `تسک ${task.title}: مقدار جدید '${val}'`,
changed_by_hamed: (S.currentUser?.username === 'hamed')
});
renderAuditTrail();
}
}
function updateInlineBalance(el) {
const raw = el.textContent.replace(/[^0-9]/g, '');
const num = parseInt(raw) || 0;
S.data.blue_bank.balance = num;
el.textContent = num.toLocaleString() + ' تومان';
persistAll();
}
function updateInlineShare(idx, el) {
const num = parseFloat(el.textContent.replace(/[^0-9.]/g, '')) || 0;
if (S.data.mindroo?.investors && S.data.mindroo.investors[idx]) {
S.data.mindroo.investors[idx].share_pct = num;
persistAll();
}
}
// KANBAN DRAG & DROP (HTML5)
function handleDragStart(e, taskId) {
S.draggedTaskId = taskId;
e.dataTransfer.setData('text/plain', taskId);
e.currentTarget.classList.add('dragging');
}
function handleDragOver(e) {
e.preventDefault();
e.currentTarget.classList.add('drag-over');
}
function handleDragLeave(e) {
e.currentTarget.classList.remove('drag-over');
}
async function handleDrop(e, newStatus) {
e.preventDefault();
e.currentTarget.classList.remove('drag-over');
const taskId = S.draggedTaskId || e.dataTransfer.getData('text/plain');
if (!taskId) return;
const task = findTaskById(taskId);
if (task) {
const oldStatus = task.tag || task.status;
task.tag = newStatus;
task.status = newStatus;
const isHamed = (S.currentUser?.username === 'hamed');
if (isHamed) {
task.changed_by_hamed = true;
task.last_change_time = new Date().toLocaleTimeString('fa-IR', {hour:'2-digit', minute:'2-digit'});
}
S.data.audit_trail.unshift({
id: `aud-${Date.now()}`,
timestamp: new Date().toLocaleDateString('fa-IR') + ' - ' + new Date().toLocaleTimeString('fa-IR'),
actor: S.currentUser?.name || 'محدثه معصومی',
action: `جابجایی کانبان به '${newStatus}'`,
details: `تسک "${task.title}" از "${oldStatus}" به "${newStatus}" منتقل شد.`,
changed_by_hamed: isHamed
});
persistAll();
renderAll();
// Trigger backend status update
try {
await fetch('/api/task/status', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
id: taskId,
status: newStatus,
actor: S.currentUser?.name || 'محدثه معصومی'
})
});
} catch(e) {}
}
}
function findTaskById(id) {
const allTasks = (S.data.mindroo?.game4_launch?.tasks || [])
.concat(S.data.ekeepa?.tasks || [])
.concat(S.data.houshyar24?.hamed_board || [])
.concat(S.data.personal_tasks || []);
return allTasks.find(t => t.id === id);
}
// ==================== REAL EISENHOWER MATRIX FILTER ====================
function applyEisenhowerFilter(mode) {
S.eisenhowerFilter = mode;
// Update Chip UI active classes
['all', 'urgent', 'important', 'delegate', 'hamed-only'].forEach(k => {
const b = document.getElementById(`em-${k}`);
if (b) b.className = 'eisenhower-chip';
});
const activeBtn = document.getElementById(`em-${mode.replace('_', '-')}`);
if (activeBtn) {
if (mode === 'all') activeBtn.classList.add('active-all');
else if (mode === 'urgent') activeBtn.classList.add('active-urgent');
else if (mode === 'important') activeBtn.classList.add('active-important');
else if (mode === 'delegate') activeBtn.classList.add('active-delegate');
else if (mode === 'hamed_only') activeBtn.classList.add('active-urgent');
}
// If user is on a non-task tab (radar, telegram, finance), auto-switch to kanban so they immediately see the filtered tasks
if (mode !== 'all' && (S.activeTab === 'radar' || S.activeTab === 'telegram' || S.activeTab === 'finance' || S.activeTab === 'audit')) {
navigateTab('kanban');
}
renderAll();
}
function checkEisenhowerMatch(task) {
if (!task) return false;
if (!S.eisenhowerFilter || S.eisenhowerFilter === 'all') return true;
const prio = (task.priority || '').trim();
const tag = (task.tag || task.status || '').trim();
const resp = (task.responsible || task.assignee || '').trim();
if (S.eisenhowerFilter === 'urgent') {
return prio === 'مهم' || prio === 'فوری' || tag.includes('تصمیم') || tag.includes('فوری');
}
if (S.eisenhowerFilter === 'important') {
return prio === 'متوسط' || tag.includes('انتظار') || tag.includes('بازبینی');
}
if (S.eisenhowerFilter === 'delegate') {
return prio === 'عادی' || tag.includes('محدثه') || (!resp.includes('حامد') && prio !== 'مهم');
}
if (S.eisenhowerFilter === 'hamed_only') {
return task.changed_by_hamed === true || tag.includes('حامد') || resp.includes('حامد');
}
return true;
}
function updateEisenhowerBadges() {
const allTasks = (S.data.mindroo?.game4_launch?.tasks || [])
.concat(S.data.ekeepa?.tasks || [])
.concat(S.data.houshyar24?.hamed_board || [])
.concat(S.data.personal_tasks || []);
const total = allTasks.length;
const urgentCount = allTasks.filter(t => (t.priority === 'مهم' || t.priority === 'فوری' || (t.tag && t.tag.includes('تصمیم')))).length;
const importantCount = allTasks.filter(t => (t.priority === 'متوسط' || (t.tag && (t.tag.includes('انتظار') || t.tag.includes('بازبینی'))))).length;
const delegateCount = allTasks.filter(t => (t.priority === 'عادی' || (t.tag && t.tag.includes('محدثه')) || (!(t.responsible || '').includes('حامد') && t.priority !== 'مهم'))).length;
const hamedCount = allTasks.filter(t => (t.changed_by_hamed === true || (t.tag && t.tag.includes('حامد')) || ((t.responsible || t.assignee || '').includes('حامد')))).length;
const bAll = document.getElementById('em-badge-all');
const bUrg = document.getElementById('em-badge-urgent');
const bImp = document.getElementById('em-badge-important');
const bDel = document.getElementById('em-badge-delegate');
const bHam = document.getElementById('em-badge-hamed');
if (bAll) bAll.textContent = total;
if (bUrg) bUrg.textContent = urgentCount;
if (bImp) bImp.textContent = importantCount;
if (bDel) bDel.textContent = delegateCount;
if (bHam) bHam.textContent = hamedCount;
// Indicator banner
const ind = document.getElementById('filter-active-indicator');
const lbl = document.getElementById('filter-active-label');
if (ind && lbl) {
if (S.eisenhowerFilter === 'all') {
ind.style.display = 'none';
} else {
ind.style.display = 'flex';
let title = '';
let count = 0;
if (S.eisenhowerFilter === 'urgent') { title = '🚨 فوری و مهم (Do First)'; count = urgentCount; }
else if (S.eisenhowerFilter === 'important') { title = '⏳ مهم / غیرفوری (Schedule)'; count = importantCount; }
else if (S.eisenhowerFilter === 'delegate') { title = '⚡ فوری / غیرمهم (Delegate)'; count = delegateCount; }
else if (S.eisenhowerFilter === 'hamed_only') { title = '⭐ تغییر یافته یا مرتبط با حامد'; count = hamedCount; }
lbl.textContent = `فیلتر ماتریس فعال است: نمایش فقط "${title}" (تعداد: ${count} از ${total} تسک)`;
}
}
}
// DYNAMIC MEETING COUNTDOWN TIMER
function tickMeetingCountdown() {
const meetings = S.data.calendar_events || [];
const card = document.getElementById('meeting-countdown-card');
if (meetings.length === 0) {
card.style.display = 'none';
return;
}
card.style.display = 'flex';
const m = meetings[0];
document.getElementById('mc-title').textContent = `جلسه پیش‌رو: ${m.title} (${m.location})`;
// Simulate minutes left towards meeting
const now = new Date();
const target = new Date();
target.setHours(14, 30, 0); // 14:30
let diffSec = Math.floor((target - now) / 1000);
if (diffSec < 0) diffSec = (diffSec % 3600) + 3600; // Loop simulation
const mLeft = Math.floor(diffSec / 60);
const sLeft = diffSec % 60;
const clockEl = document.getElementById('mc-clock-remaining');
const fillEl = document.getElementById('mc-progress-bar');
clockEl.textContent = `${mLeft} دقیقه و ${sLeft} ثانیه تا شروع`;
const pct = Math.min(100, Math.max(5, (diffSec / 3600) * 100));
fillEl.style.width = `${pct}%`;
if (mLeft > 30) {
fillEl.style.backgroundColor = '#10B981';
clockEl.style.color = '#10B981';
} else if (mLeft > 10) {
fillEl.style.backgroundColor = '#F59E0B';
clockEl.style.color = '#F59E0B';
} else {
fillEl.style.backgroundColor = '#EF4444';
clockEl.style.color = '#EF4444';
}
}
// NO-SHOW SYSTEM
function triggerTestNoShow() {
document.getElementById('modal-no-show').style.display = 'flex';
}
function resolveNoShow(formed) {
document.getElementById('modal-no-show').style.display = 'none';
if (formed) {
S.data.audit_trail.unshift({
id: `aud-${Date.now()}`,
timestamp: new Date().toLocaleTimeString('fa-IR'),
actor: 'حامد فلاحی / سیستم',
action: 'تایید تشکیل جلسه',
details: 'جلسه با موفقیت در موعد مقرر تشکیل شد.',
changed_by_hamed: true
});
} else {
// Alarm
S.data.audit_trail.unshift({
id: `aud-${Date.now()}`,
timestamp: new Date().toLocaleTimeString('fa-IR'),
actor: 'سیستم هوشمند هادس',
action: '🚨 هشدار احتمال لغو جلسه (No-Show)',
details: 'جلسه تشکیل نشد یا حامد حضور نیافت. وضعیت نیازمند استعلام فوری محدثه.',
changed_by_hamed: true
});
alert('هشدار عدم تشکیل جلسه ثبت شد و در لاگ نظارتی محدثه قرار گرفت.');
}
persistAll();
renderAuditTrail();
}
// ADHD FOCUS MODE
function launchFocusMode() {
const urgentTasks = (S.data.mindroo?.game4_launch?.tasks || [])
.concat(S.data.ekeepa?.tasks || [])
.filter(t => t.priority === 'مهم' && t.tag !== 'انجام شد');
if (urgentTasks.length === 0) {
alert('هیچ تسک مهم و فوری باقی نمانده است! روز شما آزاد است.');
return;
}
S.currentFocusTaskIndex = 0;
displayCurrentFocusTask(urgentTasks[0]);
document.getElementById('focus-curtain').style.display = 'flex';
// Start Pomodoro 25min countdown
S.focusSecondsLeft = 1500;
if (S.focusTimer) clearInterval(S.focusTimer);
S.focusTimer = setInterval(() => {
S.focusSecondsLeft--;
if (S.focusSecondsLeft <= 0) {
clearInterval(S.focusTimer);
alert('۲۵ دقیقه تمرکز شما به پایان رسید! ۵ دقیقه استراحت کنید.');
}
const m = Math.floor(S.focusSecondsLeft / 60);
const s = S.focusSecondsLeft % 60;
document.getElementById('focus-clock-display').textContent = `${String(m).padStart(2,'0')}:${String(s).padStart(2,'0')}`;
}, 1000);
}
function displayCurrentFocusTask(t) {
document.getElementById('focus-task-title').textContent = t.title;
document.getElementById('focus-task-details').textContent = t.details || t.notes || `مسئول: ${t.responsible || t.assignee} | موعد: ${t.deadline}`;
}
function exitFocusMode() {
if (S.focusTimer) clearInterval(S.focusTimer);
document.getElementById('focus-curtain').style.display = 'none';
}
function completeFocusTask() {
const urgentTasks = (S.data.mindroo?.game4_launch?.tasks || [])
.concat(S.data.ekeepa?.tasks || [])
.filter(t => t.priority === 'مهم' && t.tag !== 'انجام شد');
const t = urgentTasks[S.currentFocusTaskIndex];
if (t) {
t.tag = 'انجام شد';
t.status = 'انجام شد';
t.changed_by_hamed = true;
t.last_change_time = new Date().toLocaleTimeString('fa-IR', {hour:'2-digit', minute:'2-digit'});
S.data.audit_trail.unshift({
id: `aud-${Date.now()}`,
timestamp: new Date().toLocaleTimeString('fa-IR'),
actor: 'حامد فلاحی',
action: 'تکمیل تسک در حالت تمرکز',
details: `تسک "${t.title}" با موفقیت در Focus Mode انجام شد.`,
changed_by_hamed: true
});
persistAll();
renderAll();
alert('تسک تیک خورد! عالی پیش رفتی.');
loadNextFocusTask();
}
}
function loadNextFocusTask() {
const urgentTasks = (S.data.mindroo?.game4_launch?.tasks || [])
.concat(S.data.ekeepa?.tasks || [])
.filter(t => t.priority === 'مهم' && t.tag !== 'انجام شد');
if (urgentTasks.length === 0) {
alert('تمامی تسک‌های فوری انجام شدند!');
exitFocusMode();
return;
}
S.currentFocusTaskIndex = (S.currentFocusTaskIndex + 1) % urgentTasks.length;
displayCurrentFocusTask(urgentTasks[S.currentFocusTaskIndex]);
}
// TAB NAVIGATION
function navigateTab(k) {
S.activeTab = k;
document.querySelectorAll('.tab-item').forEach(b => b.classList.remove('active'));
document.querySelectorAll('.tab-view').forEach(v => v.classList.remove('active'));
const btn = document.getElementById(`tab-nav-${k}`);
const view = document.getElementById(`view-${k}`);
if (btn && view) {
btn.classList.add('active');
view.classList.add('active');
}
renderAll();
}
// RENDER ALL
function renderAll() {
if (!S.data) return;
renderRadar();
renderKanban();
renderTelegramTriage();
renderMindroo();
renderAuditTrail();
if (S.vaultUnlocked) renderFinance();
updateEisenhowerBadges();
}
// 1. Radar
function renderRadar() {
const mCont = document.getElementById('radar-meetings-list');
const rawM = S.data.calendar_events || [];
mCont.innerHTML = rawM.map(m => `
<div class="record-card ${m.changed_by_hamed?'changed-by-hamed':''}">
<div style="display: flex; justify-content: space-between;">
<span class="record-title editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'meetings', '${m.id}', 'title')">${m.title}</span>
<span class="pill-badge pill-normal">${m.time}</span>
</div>
<div class="record-meta">
<span>📍 <span class="editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'meetings', '${m.id}', 'location')">${m.location}</span></span>
<span>👥 ${Array.isArray(m.attendees)?m.attendees.join('، '):m.attendees}</span>
</div>
<div class="record-footer">
<button type="button" class="btn-control" style="font-size: 0.72rem; padding: 2px 6px;" onclick="deleteMeeting('${m.id}')">حذف</button>
</div>
</div>
`).join('');
const cCont = document.getElementById('radar-calls-list');
const rawC = S.data.calls_log || [];
cCont.innerHTML = rawC.map(c => `
<div class="record-card">
<div style="display: flex; justify-content: space-between;">
<span class="record-title editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'calls', '${c.id}', 'contact')">${c.contact} (${c.organization})</span>
<span class="pill-badge pill-medium">${c.next_followup}</span>
</div>
<div style="font-size: 0.84rem;">${c.topic}</div>
<div style="font-size: 0.8rem; color: var(--text-secondary);">${c.last_status}</div>
</div>
`).join('');
}
// 2. Kanban Board (Trello-style with Strict Eisenhower Filtering)
function renderKanban() {
const filterProj = document.getElementById('kanban-project-filter')?.value || 'all';
let all = [];
if (filterProj === 'all' || filterProj === 'mindroo') {
all = all.concat(S.data.mindroo?.game4_launch?.tasks || []);
}
if (filterProj === 'all' || filterProj === 'ekeepa') {
all = all.concat(S.data.ekeepa?.tasks || []);
}
if (filterProj === 'all' || filterProj === 'houshyar') {
all = all.concat(S.data.houshyar24?.hamed_board || []);
}
// Universal Omni Search filter
if (S.searchQuery) {
all = all.filter(t => JSON.stringify(t).toLowerCase().includes(S.searchQuery));
}
// Strict Eisenhower Matrix Filter
const filteredTasks = all.filter(checkEisenhowerMatch);
const cols = {
todo: [],
prog: [],
block: [],
done: []
};
filteredTasks.forEach(t => {
const tag = (t.tag || t.status || '').toLowerCase();
if (tag.includes('انجام شد') || tag.includes('تکمیل')) cols.done.push(t);
else if (tag.includes('حامد') || tag.includes('بلاک') || tag.includes('تصمیم')) cols.block.push(t);
else if (tag.includes('در حال انجام') || tag.includes('محدثه')) cols.prog.push(t);
else cols.todo.push(t);
});
['todo', 'prog', 'block', 'done'].forEach(k => {
const countBadge = document.getElementById(`kcol-count-${k}`);
if (countBadge) countBadge.textContent = cols[k].length;
const container = document.getElementById(`kcol-cards-${k}`);
if (cols[k].length === 0) {
container.innerHTML = `<div style="text-align: center; color: var(--text-muted); padding: 28px 10px; font-size: 0.8rem; border: 1px dashed var(--border-color); border-radius: 8px;">تسکی در این ستون نیست</div>`;
} else {
container.innerHTML = cols[k].map(t => `
<div class="record-card ${t.changed_by_hamed ? 'changed-by-hamed' : ''}"
draggable="true"
ondragstart="handleDragStart(event, '${t.id}')">
<div style="display: flex; justify-content: space-between;">
<span class="record-title editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'tasks', '${t.id}', 'title')">${t.title}</span>
<span class="pill-badge ${t.priority==='مهم'?'pill-urgent':(t.priority==='متوسط'?'pill-medium':'pill-normal')}">${t.priority}</span>
</div>
<div class="record-meta">
<span>👤 <span class="editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'tasks', '${t.id}', 'responsible')">${t.responsible || t.assignee}</span></span>
<span>📅 ${t.deadline}</span>
</div>
${t.changed_by_hamed ? `<div class="badge-hamed-audit">⭐ تیک حامد (${t.last_change_time || 'امروز'})</div>` : ''}
<div class="record-footer">
<button type="button" class="btn-control" style="font-size: 0.7rem; padding: 2px 6px;" onclick="simulateHamedAction('any', '${t.id}')">تیک حامد ⭐</button>
<button type="button" class="btn-control" style="font-size: 0.7rem; padding: 2px 6px; color: var(--p-urgent);" onclick="deleteTaskAction('any', '${t.id}')">حذف</button>
</div>
</div>
`).join('');
}
});
}
// 3. Telegram Triage
function renderTelegramTriage() {
const tr = S.data.telegram_triage || {quick_ack: [], holding_queue: [], escalate_to_ceo: []};
['quick_ack', 'holding_queue', 'escalate_to_ceo'].forEach((k, idx) => {
const list = tr[k] || [];
const badge = document.getElementById(`triage-q${idx+1}-count`);
if (badge) badge.textContent = list.length;
const cont = document.getElementById(`triage-q${idx+1}-items`);
if (cont) {
if (list.length === 0) {
cont.innerHTML = `<div style="text-align: center; color: var(--text-muted); padding: 18px; font-size: 0.78rem;">پیامی در این صف نیست.</div>`;
} else {
cont.innerHTML = list.map(item => `
<div class="record-card">
<div style="display: flex; justify-content: space-between; font-weight: 700; font-size: 0.85rem;">
<span>👤 ${item.sender}</span>
<span class="tnum" style="font-size: 0.72rem; color: var(--text-muted);">${item.timestamp}</span>
</div>
<div style="font-size: 0.82rem;">${item.message}</div>
${item.draft_reply ? `<div style="font-size: 0.78rem; background: var(--bg-surface); padding: 6px; border-radius: 6px; color: var(--accent-brand);">پاسخ آماده: ${item.draft_reply}</div>` : ''}
<div class="record-footer">
<button type="button" class="btn-control" style="font-size: 0.7rem; padding: 2px 6px;" onclick="copyReplyText('${encodeURIComponent(item.draft_reply || item.message)}')">کپی پاسخ</button>
<button type="button" class="btn-control" style="font-size: 0.7rem; padding: 2px 6px; color: var(--p-urgent);" onclick="deleteTriageItem('${k}', '${item.id}')">حذف</button>
</div>
</div>
`).join('');
}
}
});
}
// 4. Mindroo
function renderMindroo() {
const rawG4 = S.data.mindroo?.game4_launch?.tasks || [];
const g4 = rawG4.filter(checkEisenhowerMatch);
const container = document.getElementById('mindroo-game4-list');
if (g4.length === 0) {
container.innerHTML = `<div style="text-align: center; color: var(--text-muted); padding: 24px; font-size: 0.85rem; border: 1px dashed var(--border-color); border-radius: 8px;">هیچ تسکی منطبق با فیلتر آیزنهاور یافت نشد. برای مشاهده همه، روی دکمه "همه تسک‌ها" کلیک کنید.</div>`;
return;
}
container.innerHTML = g4.map(t => `
<div class="record-card ${t.changed_by_hamed ? 'changed-by-hamed' : ''}" style="border-right: 3px solid #F59E0B; margin-bottom: 10px;">
<div style="display: flex; justify-content: space-between;">
<span class="record-title editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'mindroo', '${t.id}', 'title')">${t.title}</span>
<span class="pill-badge pill-medium">${t.priority}</span>
</div>
<div class="record-meta">
<span>مسئول: <strong class="editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'mindroo', '${t.id}', 'responsible')">${t.responsible}</strong></span>
<span>ددلاین: <span class="editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'mindroo', '${t.id}', 'deadline')">${t.deadline}</span></span>
<span class="pill-badge" style="background: rgba(245, 158, 11, 0.15); color: #F59E0B;">${t.tag}</span>
</div>
${t.details ? `<div class="record-notes editable-inline" contenteditable="true" onblur="handleInlineEdit(this, 'mindroo', '${t.id}', 'details')">${t.details}</div>` : ''}
<div class="record-footer">
<button type="button" class="btn-control" style="font-size: 0.72rem; padding: 2px 6px;" onclick="simulateHamedAction('mindroo', '${t.id}')">تیک حامد ⭐</button>
<button type="button" class="btn-control" style="font-size: 0.72rem; padding: 2px 6px; color: var(--p-urgent);" onclick="deleteTaskAction('mindroo', '${t.id}')">حذف</button>
</div>
</div>
`).join('');
}
// 5. Finance
function renderFinance() {
const txs = S.data.blue_bank?.transactions || [];
document.getElementById('bb-balance-val').textContent = (S.data.blue_bank?.balance || 0).toLocaleString() + ' تومان';
document.getElementById('bb-spent-val').textContent = (S.data.blue_bank?.monthly_spent || 0).toLocaleString() + ' تومان';
document.getElementById('bb-transactions-table').innerHTML = `
<table class="data-table">
<thead><tr><th>تاریخ</th><th>نوع</th><th>دسته‌بندی</th><th>شرح</th><th>مبلغ (تومان)</th><th>عملیات</th></tr></thead>
<tbody>
${txs.map(t => `
<tr>
<td class="tnum">${t.date}</td>
<td><span class="pill-badge ${t.type==='واریز'?'pill-normal':'pill-urgent'}">${t.type}</span></td>
<td>${t.category}</td>
<td>${t.title}</td>
<td class="tnum" style="font-weight: 700; color: ${t.type==='واریز'?'#10B981':'#EF4444'};">${(t.amount||0).toLocaleString()}</td>
<td><button type="button" class="btn-control" style="font-size: 0.7rem; color: var(--p-urgent);" onclick="deleteTx('${t.id}')">حذف</button></td>
</tr>
`).join('')}
</tbody>
</table>
`;
const invs = S.data.mindroo?.investors || [];
document.getElementById('investors-grid-cards').innerHTML = invs.map((inv, idx) => `
<div style="background: var(--bg-surface); padding: 18px; border-radius: 12px; border: 1px solid var(--border-color);">
<div style="font-weight: 700; font-size: 1.05rem;">${inv.name}</div>
<div style="font-size: 0.8rem; color: #F59E0B; margin-bottom: 8px;">${inv.role}</div>
<div class="tnum editable-inline" style="font-size: 1.6rem; font-weight: 700;" contenteditable="true" onblur="updateInlineShare(${idx}, this)">${inv.share_pct}٪</div>
<div style="font-size: 0.75rem; color: var(--text-muted); margin-top: 4px;">
نقد: ${((inv.cash_capital||0)/1000000).toLocaleString()}M | اعتبار: ${((inv.credit_capital||0)/1000000).toLocaleString()}M
</div>
</div>
`).join('');
const sals = S.data.mindroo?.salaries_sample || [];
document.getElementById('salaries-table-view').innerHTML = `
<table class="data-table">
<thead><tr><th>شعبه</th><th>ماه</th><th>پرسنل</th><th>ساعت کاری</th><th>پورسانت</th><th>پاداش</th><th>مجموع (تومان)</th></tr></thead>
<tbody>
${sals.map(r => `
<tr>
<td>${r.year_sheet}</td>
<td>${r.month}</td>
<td><strong>${r.person}</strong></td>
<td class="tnum">${r.hours_pay}</td>
<td class="tnum">${r.percent_pay}</td>
<td class="tnum">${r.bonus}</td>
<td class="tnum" style="font-weight: 700; color: #10B981;">${(r.total_salary||0).toLocaleString()}</td>
</tr>
`).join('')}
</tbody>
</table>
`;
}
// 6. Audit Trail
function renderAuditTrail() {
const list = S.data.audit_trail || [];
const cont = document.getElementById('audit-trail-timeline');
if (cont) {
cont.innerHTML = list.map(l => `
<div style="display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-color);">
<div style="font-size: 1.2rem;">${l.changed_by_hamed ? '⭐' : '⚡'}</div>
<div style="flex: 1;">
<div style="display: flex; justify-content: space-between; font-size: 0.82rem;">
<strong style="color: ${l.changed_by_hamed ? '#F59E0B' : 'var(--text-primary)'};">${l.actor}: ${l.action}</strong>
<span class="tnum" style="color: var(--text-muted); font-size: 0.74rem;">${l.timestamp}</span>
</div>
<div style="font-size: 0.8rem; color: var(--text-secondary);">${l.details}</div>
</div>
</div>
`).join('');
}
}
// ACTIONS
function simulateHamedAction(p, id) {
const t = findTaskById(id);
if (t) {
t.changed_by_hamed = true;
t.tag = 'انجام شد';
t.status = 'انجام شد';
t.last_change_time = new Date().toLocaleTimeString('fa-IR', {hour:'2-digit', minute:'2-digit'});
S.data.audit_trail.unshift({
id: `aud-${Date.now()}`,
timestamp: new Date().toLocaleTimeString('fa-IR'),
actor: 'حامد فلاحی',
action: 'تیک تسک توسط حامد',
details: `تسک "${t.title}" توسط حامد به وضعیت انجام شد تغییر یافت.`,
changed_by_hamed: true
});
persistAll();
renderAll();
alert(`تسک "${t.title}" توسط حامد تیک خورد.`);
}
}
function deleteTaskAction(p, id) {
if (!confirm('آیا از حذف این تسک اطمینان دارید؟')) return;
if (S.data.mindroo?.game4_launch?.tasks) {
S.data.mindroo.game4_launch.tasks = S.data.mindroo.game4_launch.tasks.filter(x => x.id !== id);
}
if (S.data.ekeepa?.tasks) {
S.data.ekeepa.tasks = S.data.ekeepa.tasks.filter(x => x.id !== id);
}
persistAll();
renderAll();
}
function openTaskModal(p) {
document.getElementById('mt-id').value = '';
document.getElementById('mt-title').value = '';
document.getElementById('mt-assignee').value = (p==='mindroo'?'جواد هوشمند':'محدثه معصومی');
document.getElementById('mt-pillar').value = p;
document.getElementById('mt-priority').value = 'مهم';
document.getElementById('mt-tag').value = 'در حال انجام محدثه';
document.getElementById('mt-deadline').value = 'تا آخر هفته';
document.getElementById('mt-notes').value = '';
document.getElementById('modal-task').style.display = 'flex';
}
function saveTaskModal() {
const title = document.getElementById('mt-title').value.trim();
if (!title) return alert('عنوان تسک الزامی است.');
const assignee = document.getElementById('mt-assignee').value.trim();
const pillar = document.getElementById('mt-pillar').value;
const priority = document.getElementById('mt-priority').value;
const tag = document.getElementById('mt-tag').value;
const deadline = document.getElementById('mt-deadline').value.trim();
const notes = document.getElementById('mt-notes').value.trim();
const newTask = {
id: `tsk-${Date.now()}`,
title,
responsible: assignee,
assignee,
priority,
tag,
status: tag,
deadline,
details: notes,
changed_by_hamed: false
};
if (pillar === 'mindroo') S.data.mindroo.game4_launch.tasks.unshift(newTask);
else if (pillar === 'ekeepa') S.data.ekeepa.tasks.unshift(newTask);
else S.data.houshyar24.hamed_board.unshift(newTask);
S.data.audit_trail.unshift({
id: `aud-${Date.now()}`,
timestamp: new Date().toLocaleTimeString('fa-IR'),
actor: S.currentUser?.name || 'محدثه معصومی',
action: 'ایجاد تسک جدید',
details: `تسک "${title}" با اولویت ${priority} افزوده شد.`,
changed_by_hamed: false
});
document.getElementById('modal-task').style.display = 'none';
persistAll();
renderAll();
}
function openMeetingModal() {
document.getElementById('modal-meeting').style.display = 'flex';
}
function saveMeetingModal() {
const title = document.getElementById('mm-title').value.trim();
if (!title) return alert('عنوان جلسه الزامی است.');
const date = document.getElementById('mm-date').value.trim() || 'امروز';
const time = document.getElementById('mm-time').value.trim() || '14:00';
const loc = document.getElementById('mm-loc').value.trim();
const att = document.getElementById('mm-att').value.trim();
if (!S.data.calendar_events) S.data.calendar_events = [];
S.data.calendar_events.unshift({
id: `meet-${Date.now()}`,
title,
date,
time,
location: loc,
attendees: att.split('،'),
changed_by_hamed: false
});
document.getElementById('modal-meeting').style.display = 'none';
persistAll();
renderRadar();
}
function deleteMeeting(id) {
if (!confirm('آیا از حذف این جلسه اطمینان دارید؟')) return;
S.data.calendar_events = S.data.calendar_events.filter(x => x.id !== id);
persistAll();
renderRadar();
}
function closeModal(id) {
document.getElementById(id).style.display = 'none';
}
function unlockFinanceVault() {
const pin = document.getElementById('vault-pin-input').value.trim();
const expected = String(S.data.auth?.finance_pin || '4311');
if (pin === expected) {
S.vaultUnlocked = true;
document.getElementById('finance-lock-screen').style.display = 'none';
document.getElementById('finance-unlocked-section').style.display = 'block';
renderFinance();
} else {
document.getElementById('vault-pin-error').style.display = 'block';
}
}
function relockFinanceVault() {
S.vaultUnlocked = false;
document.getElementById('finance-lock-screen').style.display = 'flex';
document.getElementById('finance-unlocked-section').style.display = 'none';
}
function switchFinanceSub(k) {
S.financeSubTab = k;
['bb', 'inv', 'sal'].forEach(sub => {
document.getElementById(`fsub-${sub}-pane`).style.display = (sub===k?'block':'none');
const b = document.getElementById(`fsub-nav-${sub}`);
if (b) {
if (sub===k) b.classList.add('primary');
else b.classList.remove('primary');
}
});
}
function copyReplyText(txt) {
const decoded = decodeURIComponent(txt);
if (navigator.clipboard) {
navigator.clipboard.writeText(decoded).then(() => alert('متن پاسخ کپی شد!'));
} else {
prompt('متن پاسخ:', decoded);
}
}
function generateTelegramDigest() {
const urgentTasks = (S.data.mindroo?.game4_launch?.tasks || [])
.concat(S.data.ekeepa?.tasks || [])
.filter(t => t.priority === 'مهم' && t.tag !== 'انجام شد');
let text = `📋 *گزارش اجرایی روزانه حامد فلاحی*\n`;
text += `🗓️ تاریخ: امروز | وضعیت: آنلاین\n\n`;
text += `🔹 *اولویت‌های حیاتی امروز:*\n`;
urgentTasks.slice(0, 3).forEach(t => text += ` • ${t.title} (${t.responsible})\n`);
text += `\n🔹 *مایندرو و بازی ۴ نیایش:* پیشرفت کل ۶۸٪\n`;
text += ` • نجاری جواد هوشمند و پترن مراکشی خانم سعادت‌منش\n`;
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => alert('متن گزارش در کلیپ‌بورد کپی شد!'));
} else {
prompt('متن گزارش آماده تلگرام:', text);
}
}
function handleUniversalSearch(q) {
S.searchQuery = q.trim().toLowerCase();
document.getElementById('omni-clear').style.display = S.searchQuery ? 'block' : 'none';
renderAll();
}
function clearUniversalSearch() {
document.getElementById('omni-search').value = '';
handleUniversalSearch('');
}
function forceSyncTelegramUpdates() {
syncWithBackend();
alert('پیام‌های تلگرام با موفقیت همگام‌سازی شدند.');
}
</script>
</body>
</html>
"""
final_html = HTML_CONTENT.replace("__INITIAL_DATA_PLACEHOLDER__", MASTER_DATA_JSON)
out_file = os.path.join(BASE_DIR, "index.html")
with open(out_file, "w", encoding="utf-8") as f:
f.write(final_html)
print(f"Generated {out_file} (size: {len(final_html)} bytes)")