/* =============================================================
   Tour Itinerary Builder — frontend styles
   Everything below is scoped and !important-guarded on the
   properties that WordPress themes most commonly override
   (buttons, headings, inputs) so the widget looks the same
   regardless of the active theme.
   ============================================================= */

.tib-wrap,
.tib-wrap *,
#tib-drawer,
#tib-drawer *,
#tib-floating-bar,
#tib-floating-bar *,
#tib-modal-overlay {
	box-sizing: border-box;
}

.tib-wrap,
#tib-drawer,
#tib-floating-bar {
	--tib-ink: #111318;
	--tib-muted: #6b7280;
	--tib-border: #ececec;
	--tib-accent: #16181d;
	--tib-accent-hover: #2c2f36;
	--tib-success: #16a34a;
	--tib-danger: #dc2626;
	--tib-radius: 10px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

/* Reset headings so theme H1-H6 rules can't leak in */
.tib-wrap h1, .tib-wrap h2, .tib-wrap h3, .tib-wrap h4,
#tib-drawer h1, #tib-drawer h2, #tib-drawer h3, #tib-drawer h4 {
	margin: 0 !important;
	padding: 0 !important;
	line-height: 1.25 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
}

/* Reset every button/input/textarea inside our widget before
   applying our own look, so theme button skins don't bleed in */
.tib-wrap button, .tib-wrap input, .tib-wrap textarea,
#tib-drawer button, #tib-drawer input, #tib-drawer textarea,
#tib-floating-bar button {
	all: revert;
	box-sizing: border-box;
	font-family: inherit !important;
	appearance: none;
	-webkit-appearance: none;
}

/* ---------- Tour grid & cards ---------- */

.tib-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 24px;
	margin: 24px 0;
}

.tib-card {
	background: #fff;
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
	display: flex;
	flex-direction: column;
	transition: transform .2s ease, box-shadow .2s ease;
}
.tib-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 10px 24px rgba(0,0,0,0.10);
}

@keyframes tib-card-glow {
	0%   { box-shadow: 0 0 0 0 rgba(22,163,74,0.35), 0 1px 3px rgba(0,0,0,0.07); }
	100% { box-shadow: 0 0 0 14px rgba(22,163,74,0), 0 1px 3px rgba(0,0,0,0.07); }
}
.tib-card-added-glow { animation: tib-card-glow .7s ease-out; }

.tib-card-image {
	height: 220px;
	background-size: cover;
	background-position: center;
	background-color: #eee;
	transition: transform .5s ease;
}
.tib-card:hover .tib-card-image { transform: scale(1.06); }

.tib-card-image-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	color: #9ca3af !important;
	background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
	font-size: 13px !important;
}

.tib-card-body { padding: 20px; }

.tib-card-title {
	font-size: 19px !important;
	font-weight: 700 !important;
	color: var(--tib-ink) !important;
	margin-bottom: 4px !important;
}

.tib-card-subtitle {
	margin: 0 0 12px !important;
	font-size: 13.5px !important;
	line-height: 1.45 !important;
	color: var(--tib-muted) !important;
	font-weight: 400 !important;
}

.tib-card-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	font-size: 12.5px !important;
	color: var(--tib-muted) !important;
	padding-bottom: 14px;
	margin-bottom: 14px;
	border-bottom: 1px solid var(--tib-border);
}

.tib-meta-item {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	white-space: nowrap;
}
.tib-meta-item svg { flex-shrink: 0; color: #9ca3af; }

.tib-card-footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.tib-card-price { display: flex; flex-direction: column; }
.tib-label { font-size: 11.5px !important; color: #9ca3af !important; }
.tib-card-price strong { font-size: 18px !important; color: var(--tib-ink) !important; font-weight: 700 !important; }

/* ---------- Buttons (shared "primary pill" look) ---------- */

.tib-add-btn {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	text-align: center !important;
	gap: 6px !important;
	width: auto !important;
	background: var(--tib-accent) !important;
	color: #fff !important;
	border: none !important;
	border-radius: 10px !important;
	padding: 10px 18px !important;
	font-size: 13.5px !important;
	font-weight: 600 !important;
	line-height: 1.2 !important;
	cursor: pointer;
	white-space: nowrap;
	transition: background .15s ease, transform .1s ease, box-shadow .15s ease;
	box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.tib-add-btn:hover { background: var(--tib-accent-hover) !important; }
.tib-add-btn:active { transform: scale(0.97); }
.tib-add-btn.tib-added { background: var(--tib-success) !important; }
.tib-add-btn:disabled { opacity: .6 !important; cursor: default; transform: none; }

@keyframes tib-btn-bounce {
	0%   { transform: scale(1); }
	35%  { transform: scale(1.14); }
	65%  { transform: scale(0.95); }
	100% { transform: scale(1); }
}
.tib-add-btn.tib-just-added { animation: tib-btn-bounce .45s cubic-bezier(.34,1.56,.64,1); }

@keyframes tib-pop {
	0%   { transform: scale(1); }
	40%  { transform: scale(1.18); }
	100% { transform: scale(1); }
}
.tib-pulse { animation: tib-pop .35s ease; }

/* ---------- Floating bar ---------- */

.tib-floating-bar {
	position: fixed;
	left: 0; right: 0; bottom: 0;
	background: var(--tib-accent);
	color: #fff !important;
	z-index: 9997;
	box-shadow: 0 -6px 20px rgba(0,0,0,0.18);
	transform: translateY(100%);
	transition: transform .4s cubic-bezier(.34,1.4,.64,1);
}
.tib-floating-bar.tib-visible { transform: translateY(0); }

.tib-floating-bar-inner {
	max-width: 960px;
	margin: 0 auto;
	padding: 16px 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}
.tib-floating-count { font-size: 14.5px !important; color: #fff !important; font-weight: 500 !important; }
.tib-floating-bar .tib-add-btn { background: #fff !important; color: var(--tib-ink) !important; }
.tib-floating-bar .tib-add-btn:hover { background: #ececec !important; }

/* ---------- Drawer overlay ---------- */

.tib-drawer-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15,15,18,0.45);
	z-index: 9998;
	opacity: 0;
	visibility: hidden;
	transition: opacity .28s ease, visibility .28s ease;
}
.tib-drawer-overlay.tib-open { opacity: 1; visibility: visible; }

/* ---------- Drawer panel ---------- */

#tib-drawer.tib-drawer {
	position: fixed;
	top: 0; right: 0; bottom: 0;
	width: 440px;
	max-width: 100vw;
	background: #fff !important;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	transform: translateX(100%);
	transition: transform .32s cubic-bezier(.32,.72,0,1);
	box-shadow: -12px 0 40px rgba(0,0,0,0.16);
}
#tib-drawer.tib-drawer.tib-open { transform: translateX(0); }

/* Keep clear of the WP admin toolbar so it never covers the drawer header
   (only visible to logged-in admins/editors, not regular site visitors) */
body.admin-bar .tib-drawer-overlay { top: 32px; }
body.admin-bar #tib-drawer.tib-drawer { top: 32px; }
@media (max-width: 782px) {
	body.admin-bar .tib-drawer-overlay { top: 46px; }
	body.admin-bar #tib-drawer.tib-drawer { top: 46px; }
}

.tib-drawer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 18px 24px;
	border-bottom: 1px solid var(--tib-border);
	flex-shrink: 0;
}
.tib-drawer-header h2 {
	font-size: 17px !important;
	font-weight: 700 !important;
	color: var(--tib-ink) !important;
}

.tib-modal-close {
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 32px !important;
	height: 32px !important;
	min-width: 32px !important;
	border-radius: 50% !important;
	background: #f3f4f6 !important;
	border: none !important;
	color: #6b7280 !important;
	font-size: 20px !important;
	line-height: 1 !important;
	cursor: pointer;
	padding: 0 !important;
	transition: background .15s ease, color .15s ease;
}
.tib-modal-close:hover { background: #e5e7eb !important; color: var(--tib-ink) !important; }

.tib-drawer-body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
}
.tib-drawer-body::-webkit-scrollbar { width: 6px; }
.tib-drawer-body::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 3px; }
.tib-drawer-body::-webkit-scrollbar-track { background: transparent; }

.tib-drawer-scroll {
	padding: 20px 24px 4px;
}

.tib-drawer-footer {
	position: sticky;
	bottom: 0;
	margin-top: auto;
	padding: 16px 24px 20px;
	border-top: 1px solid var(--tib-border);
	background: #fff;
	box-shadow: 0 -6px 16px rgba(0,0,0,0.04);
}

.tib-drawer-subhead {
	font-size: 12px !important;
	font-weight: 700 !important;
	text-transform: uppercase !important;
	letter-spacing: .04em !important;
	color: var(--tib-muted) !important;
	margin-top: 4px !important;
	margin-bottom: 14px !important;
}

.tib-drawer-divider {
	border: none;
	border-top: 1px solid var(--tib-border);
	margin: 22px 0 18px;
}

.tib-drawer-total {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 13px 14px;
	margin-top: 2px;
	background: #f9fafb;
	border-radius: 10px;
	font-size: 14px !important;
	font-weight: 600 !important;
	color: var(--tib-ink) !important;
}
.tib-drawer-total strong { font-size: 16px !important; }

/* ---------- Selected-tour rows ---------- */

.tib-modal-item {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid #f2f2f2;
	font-size: 14px;
	max-height: 100px;
	opacity: 0;
	transform: translateX(16px);
	animation: tib-item-in .38s ease forwards;
	transition: max-height .22s ease, opacity .22s ease, padding .22s ease, margin .22s ease, transform .22s ease;
}
.tib-modal-item:last-of-type { border-bottom: none; }
.tib-modal-item.tib-removing {
	opacity: 0 !important;
	max-height: 0 !important;
	padding-top: 0 !important;
	padding-bottom: 0 !important;
	margin: 0 !important;
	border-bottom: none !important;
	transform: translateX(16px) !important;
	overflow: hidden;
}

@keyframes tib-item-in {
	to { opacity: 1; transform: translateX(0); }
}

.tib-modal-item-thumb {
	width: 52px;
	height: 52px;
	border-radius: 10px;
	background-size: cover;
	background-position: center;
	background-color: #eee;
	flex-shrink: 0;
}
.tib-modal-item-info { flex: 1; min-width: 0; }
.tib-modal-item-title {
	font-weight: 600 !important;
	font-size: 14px !important;
	color: var(--tib-ink) !important;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.tib-modal-item-price { color: var(--tib-muted) !important; font-size: 12.5px !important; margin-top: 2px !important; }

.tib-modal-item-remove {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 4px !important;
	background: transparent !important;
	border: 1px solid #f0d0d0 !important;
	color: var(--tib-danger) !important;
	cursor: pointer;
	font-size: 12px !important;
	font-weight: 500 !important;
	padding: 6px 10px !important;
	border-radius: 8px !important;
	flex-shrink: 0;
	transition: background .15s ease, border-color .15s ease;
}
.tib-modal-item-remove:hover { background: #fef2f2 !important; border-color: #f3b8b8 !important; }

.tib-modal-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	color: var(--tib-muted) !important;
	font-size: 13.5px !important;
	line-height: 1.55 !important;
	padding: 32px 8px;
	text-align: center;
}
.tib-modal-empty svg { color: #d1d5db; }
.tib-modal-empty strong { color: var(--tib-ink) !important; }

/* ---------- Success state ---------- */

.tib-drawer-body.tib-success-active > *:not(.tib-success-state) {
	display: none;
}

.tib-success-state {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	padding: 48px 16px;
	gap: 6px;
	animation: tib-fade-up .4s ease;
}
.tib-success-check { color: var(--tib-success); margin-bottom: 8px; }
.tib-success-circle {
	stroke-dasharray: 164;
	stroke-dashoffset: 164;
	animation: tib-draw .5s ease forwards;
}
.tib-success-tick {
	stroke-dasharray: 40;
	stroke-dashoffset: 40;
	animation: tib-draw .35s ease .45s forwards;
}
.tib-success-state h3 {
	font-size: 18px !important;
	font-weight: 700 !important;
	color: var(--tib-ink) !important;
	margin-top: 4px !important;
}
.tib-success-state p {
	font-size: 13.5px !important;
	color: var(--tib-muted) !important;
	line-height: 1.5 !important;
	max-width: 300px;
}

@keyframes tib-draw {
	to { stroke-dashoffset: 0; }
}
@keyframes tib-fade-up {
	from { opacity: 0; transform: translateY(8px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Form ---------- */

#tib-itinerary-form { margin-top: 4px; }
.tib-form-row { margin-bottom: 16px; }
.tib-form-row-2 {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
	margin-bottom: 16px;
}
.tib-form-row label, .tib-form-row-2 label {
	display: block !important;
	font-size: 12.5px !important;
	font-weight: 600 !important;
	margin-bottom: 6px !important;
	color: var(--tib-ink) !important;
}
.tib-form-row input,
.tib-form-row-2 input,
.tib-form-row textarea {
	width: 100% !important;
	padding: 11px 13px !important;
	border: 1.5px solid #e2e4e8 !important;
	border-radius: 9px !important;
	font-size: 14px !important;
	color: var(--tib-ink) !important;
	background: #fff !important;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.tib-form-row input:focus,
.tib-form-row-2 input:focus,
.tib-form-row textarea:focus {
	outline: none !important;
	border-color: var(--tib-ink) !important;
	box-shadow: 0 0 0 3px rgba(17,19,24,0.08) !important;
}
.tib-form-row textarea { resize: vertical; min-height: 70px; }

.tib-submit-btn { width: 100% !important; padding: 12px !important; margin-top: 2px; font-size: 14px !important; }

.tib-form-message {
	font-size: 13.5px !important;
	margin-top: 10px !important;
	line-height: 1.4 !important;
}
.tib-form-message.success { color: var(--tib-success) !important; }
.tib-form-message.error { color: var(--tib-danger) !important; }

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
	.tib-form-row-2 { grid-template-columns: 1fr; }
	.tib-floating-bar-inner { padding: 14px 18px; }
	#tib-drawer.tib-drawer { width: 100vw; }
}

@media (prefers-reduced-motion: reduce) {
	.tib-wrap *, #tib-drawer *, #tib-floating-bar * {
		animation-duration: 0.001ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.001ms !important;
	}
}
