/*
Theme Name: Bytes Webworks CRM
Theme URI: https://bytesweb.works
Author: Bytes Webworks
Author URI: https://bytesweb.works
Description: A private, login-only client & task management dashboard theme built for Bytes Webworks (bytesweb.works). Not intended for public/search-engine visibility.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: bw-crm
*/

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: hidden; }
body {
	margin: 0;
	overflow-x: hidden;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background: #f4f6f9;
	color: #1f2733;
	line-height: 1.5;
}
a { color: #2457c1; text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---------- Layout ---------- */
.bw-wrap {
	max-width: 1100px;
	margin: 0 auto;
	padding: 0 20px;
}

/* ---------- Header ---------- */
.bw-header {
	background: #101826;
	color: #fff;
	padding: 18px 0;
	border-bottom: 3px solid #2457c1;
}
.bw-header .bw-wrap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 10px;
}
.bw-logo {
	font-weight: 700;
	font-size: 1.3rem;
	color: #fff;
	letter-spacing: 0.3px;
}
.bw-logo span { color: #4d8dff; }
.bw-nav a {
	color: #cfd8e6;
	margin-left: 18px;
	font-size: 0.95rem;
}
.bw-nav a:hover { color: #fff; }
.bw-user-bar {
	font-size: 0.85rem;
	color: #9aa7bb;
}
.bw-user-bar a { color: #ff8a8a; margin-left: 10px; }

/* ---------- Main ---------- */
.bw-main { padding: 32px 0 60px; }
.bw-page-title {
	font-size: 1.6rem;
	margin: 0 0 6px;
	color: #101826;
}
.bw-page-subtitle {
	color: #6b7686;
	margin: 0 0 28px;
}

/* ---------- Cards / Stats ---------- */
.bw-stats {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 16px;
	margin-bottom: 32px;
}
.bw-stat-card {
	background: #fff;
	border-radius: 10px;
	padding: 18px 20px;
	box-shadow: 0 1px 3px rgba(16,24,38,0.08);
	border-left: 4px solid #2457c1;
}
.bw-stat-card-money {
	border-left-color: #1e7e34;
}
.bw-stat-card-money h3 {
	color: #1e7e34;
}
.bw-stat-card-loss {
	border-left-color: #c0392b;
}
.bw-stat-card-loss h3 {
	color: #c0392b;
}
.bw-stat-card h3 {
	margin: 0;
	font-size: 1.8rem;
	color: #101826;
}
.bw-stat-card p {
	margin: 4px 0 0;
	color: #6b7686;
	font-size: 0.85rem;
	text-transform: uppercase;
	letter-spacing: 0.4px;
}

/* ---------- Section ---------- */
.bw-section {
	background: #fff;
	border-radius: 10px;
	box-shadow: 0 1px 3px rgba(16,24,38,0.08);
	margin-bottom: 28px;
	overflow: hidden;
}
.bw-section-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #e9edf3;
}
.bw-section-header h2 { margin: 0; font-size: 1.1rem; }
.bw-btn {
	display: inline-block;
	background: #2457c1;
	color: #fff;
	padding: 8px 16px;
	border-radius: 6px;
	font-size: 0.85rem;
	font-weight: 600;
	border: none;
	cursor: pointer;
	font-family: inherit;
	line-height: 1.4;
}
.bw-btn:hover { background: #1d47a0; color: #fff; text-decoration: none; }
.bw-btn-secondary {
	background: #eef1f6;
	color: #364154;
}
.bw-btn-secondary:hover { background: #e1e6ee; color: #364154; }
.bw-btn-small {
	padding: 4px 10px;
	font-size: 0.75rem;
	vertical-align: middle;
	margin-left: 8px;
}

/* ---------- Client blocks (Tasks page, grouped by business) ---------- */
.bw-client-block {
	background: #fff;
	border-radius: 10px;
	box-shadow: 0 1px 3px rgba(16,24,38,0.08);
	margin-bottom: 18px;
	overflow: hidden;
}
.bw-client-block-summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 20px;
	cursor: pointer;
	list-style: none;
	font-size: 1rem;
	user-select: none;
}
.bw-client-block-summary::-webkit-details-marker { display: none; }
.bw-client-block-summary::before {
	content: '\25B8';
	margin-right: 10px;
	color: #6b7686;
	transition: transform 0.15s ease;
	display: inline-block;
}
.bw-client-block[open] > .bw-client-block-summary::before {
	transform: rotate(90deg);
}
.bw-client-block-name {
	font-weight: 700;
	color: #101826;
	flex: 1;
	min-width: 0;
	overflow-wrap: break-word;
}
.bw-client-block-body {
	padding: 4px 20px 20px;
	border-top: 1px solid #e9edf3;
}
.bw-client-block-body h3 {
	margin: 20px 0 8px;
	font-size: 0.95rem;
	color: #364154;
}
.bw-client-block-body h3:first-child { margin-top: 16px; }

/* ---------- Banners ---------- */
.bw-banner {
	margin: 0 0 20px;
	padding: 12px 16px;
	border-radius: 8px;
	font-size: 0.9rem;
}
.bw-banner-ok { background: #e4f7e9; color: #1e7e34; }
.bw-banner-error { background: #fdecea; color: #c0392b; }
.bw-banner-warn { background: #fff4d9; color: #8a5a00; }
.bw-banner a { color: inherit; text-decoration: underline; }

/* ---------- Forms ---------- */
.bw-form { padding: 20px; }
.bw-form-row { margin-bottom: 18px; }
.bw-form-row:last-of-type { margin-bottom: 0; }
.bw-form-row label {
	display: block;
	font-size: 0.8rem;
	font-weight: 600;
	color: #4a5468;
	margin-bottom: 6px;
}
.bw-form-row input[type="text"],
.bw-form-row input[type="email"],
.bw-form-row input[type="password"],
.bw-form-row input[type="date"],
.bw-form-row select,
.bw-form-row textarea {
	width: 100%;
	padding: 11px 13px;
	font-size: 1rem;
	font-family: inherit;
	border: 1px solid #d8dee8;
	border-radius: 8px;
	background: #f9fafc;
	color: #1f2733;
}
.bw-form-row input:focus,
.bw-form-row select:focus,
.bw-form-row textarea:focus {
	outline: none;
	border-color: #2457c1;
	background: #fff;
}
.bw-form-row textarea { resize: vertical; min-height: 90px; }
.bw-form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0 16px;
}
.bw-form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.bw-form-grid .bw-form-row { margin-bottom: 18px; }
.bw-checkbox-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px 16px;
}
.bw-checkbox-item {
	display: flex !important;
	align-items: flex-start;
	gap: 8px;
	font-weight: 400 !important;
	font-size: 0.9rem !important;
	color: #1f2733 !important;
}
.bw-checkbox-item input { width: 17px; height: 17px; margin-top: 2px; flex-shrink: 0; }
.bw-hint { color: #97a2b3; font-size: 0.78rem; margin: 8px 0 0; }
.bw-form-actions {
	display: flex;
	gap: 10px;
	margin-top: 24px;
	padding-top: 20px;
	border-top: 1px solid #eef1f6;
}

/* ---------- Row actions (edit/delete links in tables) ---------- */
.bw-row-actions {
	white-space: nowrap;
	display: flex;
	gap: 12px;
	align-items: center;
}
.bw-inline-form { display: inline; margin: 0; }
.bw-link-btn {
	background: none;
	border: none;
	padding: 0;
	font-family: inherit;
	font-size: 0.85rem;
	color: #2457c1;
	cursor: pointer;
	text-decoration: underline;
}
.bw-link-btn-danger { color: #c0392b; }

/* ---------- Table ---------- */
.bw-table-wrap {
	width: 100%;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}
table.bw-table {
	width: 100%;
	min-width: 480px;
	border-collapse: collapse;
}
.bw-table th, .bw-table td {
	text-align: left;
	padding: 12px 20px;
	border-bottom: 1px solid #eef1f6;
	font-size: 0.92rem;
	vertical-align: top;
}
.bw-table th {
	background: #f9fafc;
	color: #6b7686;
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.4px;
}
.bw-table tr:last-child td { border-bottom: none; }
.bw-empty { padding: 30px 20px; color: #8891a1; text-align: center; }

/* ---------- Badges ---------- */
.bw-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 600;
}
.bw-badge-todo { background: #fdecea; color: #c0392b; }
.bw-badge-progress { background: #fff4d9; color: #9c6f00; }
.bw-badge-done { background: #e4f7e9; color: #1e7e34; }
.bw-badge-priority-high { background: #ffe3e3; color: #b30000; }
.bw-badge-priority-medium { background: #fff0d6; color: #8a5a00; }
.bw-badge-priority-low { background: #e6f0ff; color: #1d4fa3; }

/* ---------- Login screen ---------- */
.bwcrm-login-body {
	margin: 0;
	min-height: 100vh;
	min-height: 100dvh;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(160deg, #101826 0%, #17233a 60%, #1d3057 100%);
	padding: 20px;
}
.bw-login-gate {
	width: 100%;
	max-width: 400px;
	margin: 0 auto;
	background: #fff;
	border-radius: 14px;
	box-shadow: 0 10px 40px rgba(0,0,0,0.25);
	padding: 36px 28px;
	text-align: center;
}
.bw-login-logo {
	font-weight: 700;
	font-size: 1.2rem;
	color: #101826;
	margin-bottom: 18px;
}
.bw-login-logo span { color: #2457c1; }
.bw-login-gate h1 { font-size: 1.4rem; margin: 0 0 8px; }
.bw-login-gate p { color: #6b7686; margin: 0 0 20px; font-size: 0.9rem; }
.bw-login-error {
	background: #fdecea;
	color: #c0392b;
	border-radius: 8px;
	padding: 10px 14px;
	font-size: 0.85rem;
	margin-bottom: 18px !important;
}
.bw-login-form { text-align: left; }
.bw-login-form label {
	display: block;
	font-size: 0.8rem;
	font-weight: 600;
	color: #4a5468;
	margin: 14px 0 6px;
}
.bw-login-form input[type="text"],
.bw-login-form input[type="password"] {
	width: 100%;
	padding: 12px 14px;
	font-size: 1rem;
	border: 1px solid #d8dee8;
	border-radius: 8px;
	background: #f9fafc;
	color: #1f2733;
}
.bw-login-form input[type="text"]:focus,
.bw-login-form input[type="password"]:focus {
	outline: none;
	border-color: #2457c1;
	background: #fff;
}
.bw-login-remember {
	display: flex !important;
	align-items: center;
	gap: 8px;
	font-weight: 400 !important;
	font-size: 0.85rem !important;
	color: #4a5468 !important;
	margin: 16px 0 !important;
}
.bw-login-remember input { width: 17px; height: 17px; }
.bw-login-btn {
	width: 100%;
	padding: 13px;
	font-size: 0.95rem;
	border: none;
	cursor: pointer;
	margin-top: 4px;
}
.bw-login-footer {
	margin: 22px 0 0 !important;
	font-size: 0.75rem !important;
	color: #97a2b3 !important;
}

@media (max-width: 480px) {
	.bw-login-gate { padding: 28px 20px; border-radius: 10px; }
}

/* ---------- Footer ---------- */
.bw-footer {
	text-align: center;
	padding: 24px 0;
	color: #97a2b3;
	font-size: 0.8rem;
}

/* ---------- Checklists ---------- */
.bwcrm-checklist .bwcrm-check {
	width: 18px;
	height: 18px;
	cursor: pointer;
}
tr.bwcrm-done td {
	color: #9aa4b2;
	text-decoration: line-through;
	text-decoration-color: #c7d0dc;
}
tr.bwcrm-done { background: #fafbfc; }
.bwcrm-guide {
	margin-top: 4px;
}
.bwcrm-guide summary {
	cursor: pointer;
	font-size: 0.78rem;
	color: #2457c1;
	font-weight: 600;
	list-style: none;
	display: inline-block;
}
.bwcrm-guide summary::-webkit-details-marker { display: none; }
.bwcrm-guide summary::before {
	content: "▸ ";
}
.bwcrm-guide[open] summary::before {
	content: "▾ ";
}
.bwcrm-guide-body {
	margin-top: 8px;
	padding: 10px 14px;
	background: #f5f7fb;
	border-radius: 6px;
	font-size: 0.85rem;
	line-height: 1.55;
	color: #364154;
	max-width: 640px;
	overflow-wrap: break-word;
}
.bwcrm-guide-body p { margin: 0 0 8px; }
.bwcrm-guide-body p:last-child { margin-bottom: 0; }
.bwcrm-guide-body ul { margin: 6px 0 8px 18px; padding: 0; }
.bwcrm-guide-body li { margin-bottom: 4px; }
.bw-tabs-hint {
	font-size: 0.8rem;
	color: #8891a1;
	margin: -18px 0 20px;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
	.bw-wrap { padding: 0 14px; }
	.bw-header { padding: 14px 0; }
	.bw-header .bw-wrap { flex-direction: column; align-items: flex-start; gap: 12px; }
	.bw-nav { display: flex; flex-wrap: wrap; gap: 4px 0; width: 100%; }
	.bw-nav a { margin-left: 0; margin-right: 18px; padding: 4px 0; }
	.bw-user-bar { width: 100%; display: flex; justify-content: space-between; align-items: center; }
	.bw-main { padding: 22px 0 40px; }
	.bw-page-title { font-size: 1.35rem; }
	.bw-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
	.bw-stat-card { padding: 14px 16px; }
	.bw-stat-card h3 { font-size: 1.5rem; }
	.bw-section-header { flex-wrap: wrap; gap: 10px; padding: 14px 16px; }
	.bw-table th, .bw-table td { padding: 12px 14px; }
	.bw-btn { width: 100%; text-align: center; }
	.bw-btn-small { width: auto; }
	.bw-client-block-summary { padding: 14px 16px; }
	.bw-client-block-body { padding: 4px 16px 16px; }
	.bw-client-block-body h3 { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
}

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

/* ---------- Responsive tables (stack into cards instead of scrolling) ---------- */
@media (max-width: 640px) {
	.bw-table-wrap { overflow-x: visible; }
	table.bw-table { min-width: 0; width: 100%; }
	.bw-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
		border: 0;
		padding: 0;
		margin: -1px;
	}
	.bw-table tbody, .bw-table tr, .bw-table td { display: block; width: 100%; }
	.bw-table tr {
		border-bottom: 1px solid #e9edf3;
		padding: 12px 16px;
	}
	.bw-table tr:last-child { border-bottom: none; }
	.bw-table td {
		border-bottom: none;
		padding: 5px 0;
		display: flex;
		justify-content: space-between;
		align-items: center;
		gap: 12px;
		text-align: right;
		word-break: break-word;
	}
	.bw-table td[data-label]::before {
		content: attr(data-label);
		font-weight: 600;
		font-size: 0.72rem;
		text-transform: uppercase;
		letter-spacing: 0.3px;
		color: #97a2b3;
		text-align: left;
		flex-shrink: 0;
	}
	.bw-table td:not([data-label]) { justify-content: flex-start; }
	.bw-table td.bw-row-actions { justify-content: flex-start !important; padding-top: 8px; }
	.bw-table td.bw-td-stack {
		display: block;
		text-align: left;
	}
	.bw-table td.bw-td-stack::before {
		display: block;
		margin-bottom: 3px;
	}
}

@media (max-width: 640px) {
	.bw-form-grid,
	.bw-form-grid-3,
	.bw-checkbox-grid { grid-template-columns: 1fr; }
	.bw-form { padding: 16px; }
	.bw-form-actions { flex-direction: column; }
	.bw-form-actions .bw-btn { width: 100%; text-align: center; }
	.bw-row-actions { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ---------- Standalone / home-screen app (iOS "Add to Home Screen") ---------- */
@media (display-mode: standalone) {
	.bw-header { padding-top: calc(14px + env(safe-area-inset-top)); }
	.bw-footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
	body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
.bwcrm-login-body {
	padding-top: calc(20px + env(safe-area-inset-top));
	padding-bottom: calc(20px + env(safe-area-inset-bottom));
	padding-left: calc(20px + env(safe-area-inset-left));
	padding-right: calc(20px + env(safe-area-inset-right));
}
