/* =====================================================================
   Taxi Dispatch — "Red Crystal" design system
   Glass panels over a soft warm gradient, red brand accent, edge-glow
   status indicators instead of flat fills.
   ===================================================================== */

.ttb-crystal-widget {
	--ttb-red: #b91c1c;
	--ttb-red-dark: #8f1616;
	--ttb-bg-a: #fff9f8;
	--ttb-bg-b: #ffe9e7;
	--ttb-glass: rgba(255, 255, 255, 0.55);
	--ttb-glass-border: rgba(255, 255, 255, 0.6);
	--ttb-text: #1c1c1c;
	--ttb-muted: #6b7280;
	--ttb-green: #1f9d55;
	--ttb-grey: #9ca3af;

	font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
	color: var(--ttb-text);
	background: linear-gradient(160deg, var(--ttb-bg-a) 0%, var(--ttb-bg-b) 100%);
	padding: 28px;
	border-radius: 20px;
	position: relative;
}

.ttb-crystal-widget h2,
.ttb-crystal-widget h3 {
	font-family: 'Outfit', sans-serif;
	font-weight: 600;
	margin: 0 0 16px;
	letter-spacing: -0.01em;
}

.ttb-crystal-widget h2 { font-size: 1.5em; }
.ttb-crystal-widget h3 { font-size: 1.1em; margin-top: 28px; }

/* ---------- Glass panel primitive ---------- */
.ttb-glass-panel {
	background: var(--ttb-glass);
	backdrop-filter: blur(18px);
	-webkit-backdrop-filter: blur(18px);
	border: 1px solid var(--ttb-glass-border);
	border-radius: 16px;
	padding: 20px 22px;
	box-shadow: 0 8px 32px rgba(185, 28, 28, 0.06);
	margin-bottom: 20px;
}

.ttb-access-denied {
	text-align: center;
	color: var(--ttb-muted);
}

.ttb-widget-loading {
	text-align: center;
	padding: 40px 0;
	color: var(--ttb-muted);
	font-family: 'Outfit', sans-serif;
}

.ttb-spinner {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 2px solid rgba(185, 28, 28, 0.25);
	border-top-color: var(--ttb-red);
	border-radius: 50%;
	animation: ttb-spin 0.8s linear infinite;
	vertical-align: middle;
	margin-left: 8px;
}

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

/* ---------- Fleet strip (the signature moment) ---------- */
.ttb-fleet-strip {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
	gap: 16px;
	margin-bottom: 24px;
}

.ttb-fleet-card {
	background: var(--ttb-glass);
	backdrop-filter: blur(18px);
	-webkit-backdrop-filter: blur(18px);
	border-radius: 16px;
	padding: 18px;
	position: relative;
	border: 1px solid var(--ttb-glass-border);
	box-shadow: 0 0 0 1px transparent, 0 8px 24px rgba(0, 0, 0, 0.04);
	transition: box-shadow 0.3s ease;
}

.ttb-fleet-card.status-available { box-shadow: 0 0 0 1.5px var(--ttb-green), 0 8px 24px rgba(31, 157, 85, 0.12); }
.ttb-fleet-card.status-on_job { box-shadow: 0 0 0 1.5px var(--ttb-red), 0 8px 24px rgba(185, 28, 28, 0.14); animation: ttb-pulse 2.4s ease-in-out infinite; }
.ttb-fleet-card.status-offline { box-shadow: 0 0 0 1.5px var(--ttb-grey); opacity: 0.65; }

@keyframes ttb-pulse {
	0%, 100% { box-shadow: 0 0 0 1.5px var(--ttb-red), 0 8px 24px rgba(185, 28, 28, 0.1); }
	50% { box-shadow: 0 0 0 2.5px var(--ttb-red), 0 8px 28px rgba(185, 28, 28, 0.22); }
}

.ttb-fleet-card .car-label { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1.15em; }
.ttb-fleet-card .car-rego { display: block; font-size: 0.72em; color: var(--ttb-muted); font-family: monospace; letter-spacing: 0.04em; }
.ttb-fleet-card .car-status-label { display: block; font-size: 0.8em; color: var(--ttb-muted); margin: 4px 0 10px; }
.ttb-fleet-card .car-driver { display: block; font-size: 0.85em; margin-bottom: 8px; }
.ttb-fleet-card .car-driver small { color: var(--ttb-muted); }
.ttb-fleet-card select,
.ttb-fleet-card input { width: 100%; margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.ttb-btn {
	display: inline-block;
	background: var(--ttb-red);
	color: #fff;
	border: none;
	padding: 8px 16px;
	border-radius: 8px;
	font-size: 0.88em;
	font-weight: 600;
	cursor: pointer;
	font-family: 'Inter', sans-serif;
	transition: background 0.15s ease, transform 0.1s ease;
}
.ttb-btn:hover { background: var(--ttb-red-dark); }
.ttb-btn:active { transform: scale(0.97); }
.ttb-btn-small { padding: 5px 11px; font-size: 0.8em; border-radius: 6px; }
.ttb-btn-ghost { background: transparent; color: var(--ttb-red); border: 1px solid rgba(185, 28, 28, 0.35); }
.ttb-btn-ghost:hover { background: rgba(185, 28, 28, 0.06); }
.ttb-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.ttb-crystal-widget input,
.ttb-crystal-widget select,
.ttb-crystal-widget textarea {
	font-family: 'Inter', sans-serif;
	border: 1px solid rgba(0, 0, 0, 0.1);
	background: rgba(255, 255, 255, 0.7);
	border-radius: 8px;
	padding: 8px 10px;
	font-size: 0.92em;
	box-sizing: border-box;
}
.ttb-crystal-widget input:focus,
.ttb-crystal-widget select:focus,
.ttb-crystal-widget textarea:focus {
	outline: none;
	border-color: var(--ttb-red);
	box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.12);
}
.ttb-field { margin-bottom: 14px; }
.ttb-field label { display: block; font-size: 0.82em; font-weight: 600; margin-bottom: 4px; color: var(--ttb-muted); }
.ttb-field input, .ttb-field select, .ttb-field textarea { width: 100%; }
.ttb-field-row { display: flex; gap: 12px; }
.ttb-field-row .ttb-field { flex: 1; }

/* ---------- Tables ---------- */
.ttb-crystal-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.ttb-crystal-table th {
	text-align: left;
	font-family: 'Outfit', sans-serif;
	font-weight: 600;
	font-size: 0.78em;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--ttb-muted);
	padding: 8px 10px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.ttb-crystal-table td {
	padding: 10px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.05);
	vertical-align: top;
}
.ttb-crystal-table tr:last-child td { border-bottom: none; }

/* ---------- Status pills ---------- */
.ttb-pill {
	display: inline-block;
	padding: 2px 10px;
	border-radius: 999px;
	font-size: 0.78em;
	font-weight: 600;
}
.ttb-pill-pending { background: #fff3cd; color: #7a5b00; }
.ttb-pill-assigned { background: #dbeafe; color: #1e40af; }
.ttb-pill-enroute { background: #cffafe; color: #0e7490; }
.ttb-pill-completed { background: #d1fae5; color: #065f46; }
.ttb-pill-cancelled, .ttb-pill-noshow { background: #fee2e2; color: #991b1b; }

/* ---------- Layout helpers ---------- */
.ttb-two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 780px) { .ttb-two-col { grid-template-columns: 1fr; } }
.ttb-toast {
	position: fixed;
	bottom: 24px;
	right: 24px;
	background: var(--ttb-text);
	color: #fff;
	padding: 10px 18px;
	border-radius: 10px;
	font-size: 0.9em;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
	z-index: 9999;
	opacity: 0;
	transform: translateY(8px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.ttb-toast.show { opacity: 1; transform: translateY(0); }
.ttb-toast.error { background: var(--ttb-red-dark); }

.ttb-muted { color: var(--ttb-muted); font-size: 0.85em; }
.ttb-empty-row td { text-align: center; color: var(--ttb-muted); padding: 24px 0; }

/* ---------- Alerts (SOS) ---------- */
.ttb-alert-banner {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin-bottom: 20px;
}
.ttb-alert-item {
	background: #fee2e2;
	border: 1px solid #f3b6b6;
	border-left: 4px solid #d63638;
	border-radius: 8px;
	padding: 12px 16px;
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
	animation: ttb-alert-pulse 1.6s ease-in-out infinite;
}
@keyframes ttb-alert-pulse {
	0%, 100% { box-shadow: 0 0 0 0 rgba(214, 54, 56, 0.25); }
	50% { box-shadow: 0 0 0 6px rgba(214, 54, 56, 0.08); }
}
.ttb-alert-item button { margin-left: auto; }

/* ---------- Messages ---------- */
.ttb-messages-list { max-height: 260px; overflow-y: auto; margin-bottom: 8px; }
.ttb-message-item {
	padding: 8px 12px;
	border-radius: 8px;
	margin-bottom: 8px;
	font-size: 0.88em;
	background: rgba(0, 0, 0, 0.03);
}
.ttb-message-item.ttb-message-dispatch { background: rgba(185, 28, 28, 0.06); border-left: 3px solid var(--ttb-red); }
.ttb-message-item.ttb-message-driver { background: rgba(31, 157, 85, 0.06); border-left: 3px solid var(--ttb-green); }

/* ---------- Driver Dashboard ---------- */
.ttb-driver-widget { max-width: 640px; margin: 0 auto; }
.ttb-shift-panel { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.ttb-shift-panel h3 { margin: 0; }

.ttb-sos-btn {
	display: block;
	width: 100%;
	background: var(--ttb-red);
	color: #fff;
	border: none;
	padding: 18px;
	font-size: 1.1em;
	font-weight: 700;
	font-family: 'Outfit', sans-serif;
	border-radius: 14px;
	cursor: pointer;
	margin: 16px 0 24px;
	box-shadow: 0 6px 20px rgba(185, 28, 28, 0.25);
}
.ttb-sos-btn:hover { background: var(--ttb-red-dark); }
.ttb-sos-btn:active { transform: scale(0.98); }

.ttb-job-card { border-left: 4px solid var(--ttb-red); }
.ttb-job-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ttb-job-actions { margin: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; }

/* Bigger touch targets throughout the driver dashboard - built for a
   tablet mounted in a car, not a mouse and a desk. */
.ttb-driver-widget .ttb-btn { padding: 12px 20px; font-size: 1em; }
.ttb-driver-widget input,
.ttb-driver-widget select,
.ttb-driver-widget textarea { padding: 12px; font-size: 1em; }

.ttb-shift-elapsed { font-size: 0.85em; color: var(--ttb-muted); margin: 2px 0 10px; }

/* ---------- Landscape tablet layout ----------
   Single column by default (portrait phones, narrow windows). At 900px+
   (a tablet mounted in landscape, or any wide browser window) the shift/
   SOS/earnings/messages sidebar sits alongside the jobs list instead of
   stacking above it, and stays in view while the job list scrolls. */
.ttb-driver-widget .ttb-driver-layout {
	display: flex;
	flex-direction: column;
	gap: 16px;
}
@media (min-width: 900px) {
	.ttb-driver-widget { max-width: 1100px; }
	.ttb-driver-widget .ttb-driver-layout {
		flex-direction: row;
		align-items: flex-start;
	}
	.ttb-driver-widget .ttb-driver-sidebar {
		flex: 0 0 340px;
		position: sticky;
		top: 16px;
		display: flex;
		flex-direction: column;
		gap: 16px;
	}
	.ttb-driver-widget .ttb-driver-main {
		flex: 1;
		min-width: 0;
	}
}

/* ---------- On-brand confirmation modal (replaces browser confirm()) ---------- */
.ttb-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(28, 28, 28, 0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10000;
	padding: 20px;
}
.ttb-modal-box {
	background: #fff;
	border-radius: 16px;
	padding: 24px;
	max-width: 360px;
	width: 100%;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	font-family: 'Inter', sans-serif;
}
.ttb-modal-box p { margin: 0 0 18px; font-size: 1.05em; color: var(--ttb-text, #1c1c1c); }
.ttb-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
