/* CFA Agra CRM — Phase 1 base styles.
   Full dashboard/table/chart styling arrives with each module's
   phase. This file only covers Auth pages + the app shell used by
   the Phase 1 dashboard/profile placeholders. */

:root {
	--cfa-navy: #10182b;
	--cfa-navy-2: #0c1322;
	--cfa-blue: #2f6fed;
	--cfa-blue-dark: #1f4fc4;
	--cfa-green: #1fa971;
	--cfa-red: #e5484d;
	--cfa-orange: #f39c12;
	--cfa-border: #e5e8ef;
	--cfa-text: #1a2233;
	--cfa-text-muted: #667085;
	--cfa-bg: #f5f7fb;
	--cfa-radius: 12px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--cfa-text); background: var(--cfa-bg); }

/* ====================================================================
   CRITICAL FIX: the native `hidden` HTML attribute must always win.
   Without this, any class below that sets `display: flex/grid/block`
   directly (e.g. .cfa-modal-overlay, .cfa-bulk-bar) has the SAME CSS
   specificity as the browser's built-in `[hidden] { display: none }`
   rule — and because our stylesheet loads after the browser's own,
   ours wins the tie-break, silently cancelling `hidden` everywhere.
   That was the real cause of modals staying visible/stacked even
   after JavaScript correctly set `element.hidden = true`. This single
   `!important` rule guarantees `hidden` always actually hides the
   element, throughout the entire CRM, regardless of what any other
   class on it declares.
   ==================================================================== */
[hidden] {
	display: none !important;
}

/* ---------- Auth pages ---------- */
.cfa-auth-body {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: radial-gradient(circle at top left, #16224a, var(--cfa-navy) 60%);
	padding: 24px;
}
.cfa-auth-wrap { width: 100%; max-width: 420px; }
.cfa-auth-card {
	background: #fff;
	border-radius: var(--cfa-radius);
	padding: 36px 32px;
	box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.cfa-auth-brand { text-align: center; margin-bottom: 24px; display: flex; flex-direction: column; gap: 2px; }
.cfa-auth-brand-name { font-weight: 800; font-size: 20px; color: var(--cfa-navy); letter-spacing: .3px; }
.cfa-auth-tagline { font-size: 12px; color: var(--cfa-text-muted); }
.cfa-auth-title { font-size: 22px; margin: 0 0 6px; text-align: center; }
.cfa-auth-subtitle { font-size: 13px; color: var(--cfa-text-muted); text-align: center; margin: 0 0 20px; }

.cfa-auth-form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.cfa-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--cfa-text); }
.cfa-field input[type=text], .cfa-field input[type=email], .cfa-field input[type=password] {
	font: inherit; font-weight: 400; padding: 11px 12px; border: 1px solid var(--cfa-border);
	border-radius: 8px; outline: none; transition: border-color .15s;
}
.cfa-field input:focus { border-color: var(--cfa-blue); }
.cfa-password-wrap { position: relative; display: flex; align-items: center; }
.cfa-password-wrap input { flex: 1; padding-right: 40px; }
.cfa-toggle-password {
	position: absolute; right: 8px; background: none; border: none; cursor: pointer;
	font-size: 16px; opacity: .6;
}
.cfa-field-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.cfa-checkbox { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.cfa-link { color: var(--cfa-blue); text-decoration: none; font-weight: 600; }
.cfa-link:hover { text-decoration: underline; }
.cfa-back-link { display: block; text-align: center; margin-top: 20px; font-size: 13px; }

.cfa-btn {
	font: inherit; font-weight: 700; padding: 12px 16px; border-radius: 8px; border: none;
	cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.cfa-btn-primary { background: var(--cfa-blue); color: #fff; }
.cfa-btn-primary:hover { background: var(--cfa-blue-dark); }
.cfa-btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.cfa-btn-spinner {
	width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
	border-radius: 50%; animation: cfa-spin .7s linear infinite;
}
@keyframes cfa-spin { to { transform: rotate(360deg); } }

.cfa-alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.cfa-alert-error { background: #fdecec; color: var(--cfa-red); border: 1px solid #f6c6c8; }
.cfa-alert-success { background: #e9f9f1; color: var(--cfa-green); border: 1px solid #b9edd3; }

.cfa-strength-meter { height: 5px; border-radius: 4px; background: #eee; overflow: hidden; }
.cfa-strength-meter span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.cfa-hint { color: var(--cfa-text-muted); }

/* ---------- App shell (dashboard / profile) ---------- */
.cfa-app-body { margin: 0; }
.cfa-app-shell { display: flex; min-height: 100vh; }

.cfa-sidebar { width: 230px; background: var(--cfa-navy); color: #cfd6e6; flex-shrink: 0; }
.cfa-sidebar-brand { padding: 20px; font-weight: 800; color: #fff; font-size: 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.cfa-sidebar-nav { display: flex; flex-direction: column; padding: 12px 0; }
.cfa-sidebar-nav a {
	color: #cfd6e6; text-decoration: none; padding: 10px 20px; font-size: 14px; font-weight: 500;
}
.cfa-sidebar-nav a.active, .cfa-sidebar-nav a:hover:not(.cfa-disabled) { background: rgba(255,255,255,.08); color: #fff; }
.cfa-sidebar-nav a.cfa-disabled { opacity: .35; cursor: not-allowed; }

.cfa-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cfa-topbar {
	display: flex; align-items: center; justify-content: space-between; background: #fff;
	border-bottom: 1px solid var(--cfa-border); padding: 16px 24px;
}
.cfa-topbar h1 { font-size: 18px; margin: 0; }
.cfa-topbar-user { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.cfa-role-badge { background: var(--cfa-blue); color: #fff; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }

.cfa-content { padding: 24px; display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.cfa-content-wide { max-width: 1200px; }
.cfa-card { background: #fff; border: 1px solid var(--cfa-border); border-radius: var(--cfa-radius); padding: 20px; }
.cfa-card h2 { font-size: 15px; margin: 0 0 12px; }
.cfa-card p { margin: 4px 0; font-size: 14px; }
.cfa-card-muted { background: #fafbfd; color: var(--cfa-text-muted); font-size: 13px; }

/* ---------- Phase 2: KPI cards ---------- */
.cfa-kpi-grid {
	display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px;
}
.cfa-kpi-card {
	background: #fff; border: 1px solid var(--cfa-border); border-radius: var(--cfa-radius);
	padding: 16px 18px;
}
.cfa-kpi-value { font-size: 26px; font-weight: 800; color: var(--cfa-navy); }
.cfa-kpi-label { font-size: 12.5px; color: var(--cfa-text-muted); margin-top: 2px; font-weight: 600; }
.cfa-kpi-pending .cfa-kpi-value { color: #b7bcc9; }
.cfa-kpi-note { font-size: 11px; color: var(--cfa-orange); margin-top: 6px; font-weight: 600; }

/* ---------- Phase 2: Quick actions ---------- */
.cfa-quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cfa-btn-outline {
	background: #fff; border: 1px solid var(--cfa-border); color: var(--cfa-text);
	font-size: 13px; padding: 9px 14px;
}
.cfa-btn-outline:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Phase 15: small utility classes (Pool/EMI/Attendance) ---------- */
.cfa-muted { color: var(--cfa-text-muted); font-size: 13px; }
.cfa-btn-sm { font-size: 12px; padding: 5px 10px; }
#cfa-pool-count-badge { font-weight: 700; color: var(--cfa-orange); }

/* ---------- Phase 2: Grid + Table ---------- */
.cfa-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .cfa-grid-2 { grid-template-columns: 1fr; } }

.cfa-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cfa-table th { text-align: left; color: var(--cfa-text-muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--cfa-border); }
.cfa-table td { padding: 8px 6px; border-bottom: 1px solid #f0f1f5; }
.cfa-empty-state { color: var(--cfa-text-muted); font-size: 13px; padding: 12px 0; }

.cfa-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.cfa-status-online { background: var(--cfa-green); }
.cfa-status-offline { background: #cfd4dd; }

.cfa-nav-badge {
	background: var(--cfa-red); color: #fff; font-size: 10px; font-weight: 700;
	padding: 1px 6px; border-radius: 10px; margin-left: 6px;
}

/* ---------- Phase 2: Topbar right side ---------- */
.cfa-topbar-right { display: flex; align-items: center; gap: 14px; }
.cfa-topbar-search input {
	font: inherit; font-size: 13px; padding: 7px 10px; border: 1px solid var(--cfa-border);
	border-radius: 8px; width: 220px; background: #fafbfd;
}
.cfa-topbar-bell { background: none; border: 1px solid var(--cfa-border); border-radius: 8px; padding: 6px 9px; cursor: pointer; position: relative; }
.cfa-notif-badge {
	position: absolute; top: -6px; right: -6px; background: var(--cfa-red); color: #fff;
	font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 10px; min-width: 16px; text-align: center;
}
.cfa-notif-dropdown {
	position: absolute; top: 54px; right: 24px; width: 320px; max-height: 420px; overflow-y: auto;
	background: #fff; border: 1px solid var(--cfa-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.14); z-index: 200;
}
.cfa-notif-dropdown-header {
	display: flex; justify-content: space-between; align-items: center; padding: 12px 14px;
	border-bottom: 1px solid var(--cfa-border); font-size: 13px;
}
.cfa-notif-item {
	display: block; padding: 10px 14px; border-bottom: 1px solid #f2f3f7; text-decoration: none; color: var(--cfa-text);
}
.cfa-notif-item:hover { background: #f7f9fc; }
.cfa-notif-unread { background: #f4f7ff; }
.cfa-notif-title { font-size: 12.5px; font-weight: 700; }
.cfa-notif-message { font-size: 12px; color: var(--cfa-text-muted); margin-top: 2px; }
.cfa-notif-time { font-size: 10.5px; color: var(--cfa-text-muted); margin-top: 4px; }

/* ---------- Phase 3: Filters bar ---------- */
.cfa-filters-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.cfa-filter-input, .cfa-filter-select {
	font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--cfa-border);
	border-radius: 8px; background: #fff;
}
.cfa-filter-input { min-width: 220px; flex: 1; }
.cfa-filters-spacer { flex: 1; }

/* ---------- Phase 3: Bulk bar ---------- */
.cfa-bulk-bar { display: flex; align-items: center; gap: 12px; background: #eef3fe; border-color: #c9dafc; font-size: 13px; font-weight: 600; }

/* ---------- Phase 3: Table row actions / pagination ---------- */
.cfa-row-actions { display: flex; gap: 10px; }
.cfa-icon-link, .cfa-icon-btn {
	font-size: 12px; font-weight: 600; color: var(--cfa-blue); background: none; border: none;
	cursor: pointer; text-decoration: none; padding: 0;
}
.cfa-icon-btn.cfa-delete-btn { color: var(--cfa-red); }

/* Click-to-call phone number shown on every follow-up row */
.cfa-phone-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cfa-phone-link {
	color: var(--cfa-blue-dark); text-decoration: none; font-weight: 600; font-size: 13px;
	white-space: nowrap;
}
.cfa-phone-link:hover { text-decoration: underline; }
.cfa-whatsapp-link { text-decoration: none; font-size: 14px; line-height: 1; }
.cfa-timeline-meta.cfa-phone-cell { font-size: 11.5px; color: var(--cfa-text-muted); }
.cfa-timeline-meta.cfa-phone-cell .cfa-phone-link { font-size: 11.5px; }
.cfa-pagination { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.cfa-page-btn {
	border: 1px solid var(--cfa-border); background: #fff; border-radius: 6px; padding: 5px 10px;
	font-size: 12px; cursor: pointer;
}
.cfa-page-btn.active { background: var(--cfa-blue); color: #fff; border-color: var(--cfa-blue); }

/* ---------- Phase 3: Badges ---------- */
.cfa-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.cfa-badge-blue { background: #e6eeff; color: var(--cfa-blue-dark); }
.cfa-badge-orange { background: #fef3e3; color: #b7791f; }
.cfa-badge-green { background: #e6f9ef; color: var(--cfa-green); }
.cfa-badge-red { background: #fdecec; color: var(--cfa-red); }

/* ---------- Phase 3: Modals ---------- */
.cfa-modal-overlay {
	position: fixed; inset: 0; background: rgba(16,24,43,.55); display: flex; align-items: center;
	justify-content: center; z-index: 100; padding: 20px;
}
.cfa-modal { background: #fff; border-radius: var(--cfa-radius); padding: 26px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; }
.cfa-modal-sm { max-width: 380px; }
.cfa-modal h2 { margin: 0 0 16px; font-size: 17px; }
.cfa-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.cfa-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin-bottom: 12px; }
@media (max-width: 560px) { .cfa-form-grid { grid-template-columns: 1fr; } }
.cfa-field select, .cfa-field textarea {
	font: inherit; font-weight: 400; padding: 9px 10px; border: 1px solid var(--cfa-border);
	border-radius: 8px; outline: none; width: 100%;
}
.cfa-btn-danger { background: var(--cfa-red); color: #fff; }
.cfa-btn-danger:hover { background: #c9302c; }

/* ---------- Phase 3: Lead detail page ---------- */
.cfa-lead-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.cfa-lead-header h2 { margin: 0 0 6px; font-size: 19px; }
.cfa-lead-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cfa-lead-actions a, .cfa-lead-actions button { font-size: 13px; text-decoration: none; }
.cfa-btn-disabled-visual { opacity: .4; pointer-events: none; }

.cfa-detail-rows { display: flex; flex-direction: column; gap: 8px; }
.cfa-detail-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 6px 0; border-bottom: 1px solid #f2f3f7; gap: 12px; }
.cfa-detail-label { color: var(--cfa-text-muted); font-weight: 600; flex-shrink: 0; }

.cfa-timeline-item { padding: 10px 0; border-bottom: 1px solid #f2f3f7; font-size: 13px; }
.cfa-timeline-item:last-child { border-bottom: none; }
.cfa-timeline-meta { color: var(--cfa-text-muted); font-size: 11.5px; margin-top: 2px; }

#cfa-ld-note-input { width: 100%; font: inherit; padding: 9px 10px; border: 1px solid var(--cfa-border); border-radius: 8px; resize: vertical; }

/* ---------- Phase 4: Tabs, autocomplete, hints ---------- */
.cfa-tab-group { display: flex; gap: 4px; background: #f1f3f8; padding: 4px; border-radius: 10px; }
.cfa-tab {
	border: none; background: none; padding: 7px 14px; font-size: 12.5px; font-weight: 600;
	color: var(--cfa-text-muted); border-radius: 7px; cursor: pointer;
}
.cfa-tab.active { background: #fff; color: var(--cfa-navy); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.cfa-hint { font-size: 12px; color: var(--cfa-text-muted); margin: 6px 0; }

.cfa-autocomplete-results {
	position: relative; max-height: 160px; overflow-y: auto; border: 1px solid var(--cfa-border);
	border-radius: 8px; margin-top: 4px; background: #fff;
}
.cfa-autocomplete-results:empty { border: none; }
.cfa-autocomplete-item { padding: 8px 10px; font-size: 13px; cursor: pointer; }
.cfa-autocomplete-item:hover { background: #f5f7fb; }

/* ---------- Phase 6: Receipt ---------- */
.cfa-receipt { border: 1px dashed var(--cfa-border); border-radius: 10px; padding: 18px; }
.cfa-receipt-header { text-align: center; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--cfa-border); }
.cfa-receipt-header strong { font-size: 16px; display: block; }
.cfa-receipt-header div { font-size: 12px; color: var(--cfa-text-muted); margin-top: 2px; }
.cfa-receipt-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; }
.cfa-receipt-row span:first-child { color: var(--cfa-text-muted); }
.cfa-receipt-row span:last-child { font-weight: 600; }

@media print {
	.cfa-sidebar, .cfa-topbar, .cfa-no-print, .cfa-modal-overlay > .cfa-modal > .cfa-modal-actions { display: none !important; }
	.cfa-modal-overlay { position: static !important; background: none !important; }
	.cfa-modal { box-shadow: none !important; max-width: 100% !important; }
}

/* ---------- Phase 7: Calendar ---------- */
.cfa-cal-grid { font-size: 12.5px; }
.cfa-cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-weight: 700; color: var(--cfa-text-muted); padding-bottom: 8px; }
.cfa-cal-days { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 90px; gap: 4px; }
.cfa-cal-day {
	border: 1px solid var(--cfa-border); border-radius: 8px; padding: 6px; cursor: pointer;
	overflow: hidden; display: flex; flex-direction: column; gap: 2px; transition: background .1s;
}
.cfa-cal-day:hover { background: #f7f9fc; }
.cfa-cal-day-muted { opacity: .35; }
.cfa-cal-day-today { border-color: var(--cfa-blue); border-width: 2px; }
.cfa-cal-day-num { font-weight: 700; font-size: 12px; }
.cfa-cal-event {
	font-size: 10.5px; padding: 1px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cfa-cal-event-followup { background: #e6eeff; color: var(--cfa-blue-dark); }
.cfa-cal-event-task { background: #fef3e3; color: #b7791f; }
.cfa-cal-more { font-size: 10px; color: var(--cfa-text-muted); }

.cfa-cal-agenda-day { margin-bottom: 18px; }
.cfa-cal-agenda-day h3 { font-size: 13px; margin: 0 0 8px; color: var(--cfa-navy); }
.cfa-cal-agenda-item {
	display: block; padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 13px;
	text-decoration: none; color: var(--cfa-text);
}
.cfa-cal-agenda-item.cfa-cal-event-followup { background: #f4f7ff; border-left: 3px solid var(--cfa-blue); }
.cfa-cal-agenda-item.cfa-cal-event-task { background: #fff8ec; border-left: 3px solid var(--cfa-orange); }

/* ---------- Phase 8: Reports bar list + bar chart ---------- */
.cfa-bar-list { display: flex; flex-direction: column; gap: 10px; }
.cfa-bar-row { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 10px; font-size: 12.5px; }
.cfa-bar-row-label { color: var(--cfa-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cfa-bar-row-track { background: #f1f3f8; border-radius: 6px; height: 10px; overflow: hidden; }
.cfa-bar-row-fill { background: var(--cfa-blue); height: 100%; border-radius: 6px; transition: width .3s; }
.cfa-bar-row-value { text-align: right; font-weight: 700; }

.cfa-bar-chart { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 10px; }
.cfa-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.cfa-chart-value { font-size: 11px; font-weight: 700; margin-bottom: 4px; }
.cfa-chart-bar { width: 60%; background: var(--cfa-blue); border-radius: 6px 6px 0 0; min-height: 4px; transition: height .3s; }
.cfa-chart-label { font-size: 10.5px; color: var(--cfa-text-muted); margin-top: 6px; text-align: center; }
