/* ==========================================================================
   Timeline — Admin screens
   Tables inherit base styles from gdv-cw-table in admin.css.
   ========================================================================== */

/* Phase blocks */
.gdv-cw-timeline-admin {
	max-width: 1100px;
	margin-top: 16px;
}

.gdv-cw-tpl-phase {
	margin-bottom: 24px;
}

.gdv-cw-tpl-phase__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.gdv-cw-tpl-phase__title {
	font-size: 16px;
	font-weight: 600;
	margin: 0;
	display: flex;
	align-items: center;
	gap: 8px;
}

.gdv-cw-tpl-phase__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #e2e8f0;
	color: #475569;
	font-size: 12px;
	font-weight: 600;
}

/* Column widths */
.gdv-cw-tpl-col--order {
	width: 40px;
	text-align: center;
	color: #94a3b8;
	font-weight: 600;
}

.gdv-cw-tpl-col--label {
	width: 30%;
}

.gdv-cw-tpl-col--responsible {
	width: 20%;
	color: #64748b;
}

.gdv-cw-tpl-col--description {
	color: #64748b;
	font-size: 12px;
}

.gdv-cw-tpl-col--actions {
	width: 140px;
	text-align: right;
	white-space: nowrap;
}

.gdv-cw-tpl-step__delete {
	color: #dc2626;
}

/* Edit form (inline) */
.gdv-cw-tpl-step--editing td {
	padding: 16px;
	background: #f8fafc;
}

.gdv-cw-tpl-edit-form {
	max-width: 600px;
}

.gdv-cw-tpl-edit-form__row {
	margin-bottom: 10px;
}

.gdv-cw-tpl-edit-form__row label {
	display: block;
	font-weight: 600;
	font-size: 12px;
	color: #475569;
	margin-bottom: 4px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.gdv-cw-tpl-edit-form__row input,
.gdv-cw-tpl-edit-form__row textarea {
	width: 100%;
	max-width: 500px;
}

.gdv-cw-tpl-edit-form__actions {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}

/* Add step / Add phase buttons */
.gdv-cw-tpl-phase__add {
	margin-top: 8px;
}

.gdv-cw-tpl-add-phase {
	margin-top: 16px;
}

.gdv-cw-tpl-add-phase-form {
	margin-top: 12px;
	padding: 16px;
	background: #f8fafc;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	max-width: 400px;
}

/* Empty state */
.gdv-cw-timeline-empty {
	color: #64748b;
	font-style: italic;
	padding: 24px 0;
}

/* ==========================================================================
   Milestone Labels — Admin screen
   ========================================================================== */

.gdv-cw-labels-table {
	max-width: 1000px;
}

/* Column widths */
.gdv-cw-labels-col--drag {
	width: 32px;
	text-align: center;
}

.gdv-cw-labels-drag-handle {
	cursor: grab;
	color: #94a3b8;
	font-size: 18px;
	line-height: 1;
	user-select: none;
}

.gdv-cw-labels-drag-handle:hover {
	color: #475569;
}

.gdv-cw-labels-col--label,
.gdv-cw-labels-col--label-fr {
	width: 30%;
}

.gdv-cw-labels-col--actions {
	width: 140px;
	text-align: right;
	white-space: nowrap;
}

.gdv-cw-labels-row__delete {
	color: #dc2626;
}

/* Edit row */
.gdv-cw-labels-row--editing td {
	background: #f8fafc;
	padding: 8px 12px;
}

.gdv-cw-labels-row--editing input {
	width: 100%;
}

/* Drag state */
.gdv-cw-labels-row--dragging {
	opacity: 0.4;
	background: #e2e8f0;
}

/* Empty state */
.gdv-cw-labels-empty td {
	color: #64748b;
	font-style: italic;
	padding: 24px 12px;
}

/* Add label button */
.gdv-cw-labels-add {
	margin-top: 12px;
}

/* Status message */
.gdv-cw-labels-status {
	margin-top: 8px;
	font-size: 13px;
	color: #16a34a;
}

/* ==========================================================================
   Phase bar — compact horizontal indicator (workspace topbar + public page)
   Uses CSS custom properties from variables.css.
   ========================================================================== */

.gdv-cw-phase-bar {
	display: flex;
	align-items: center;
	gap: 2px;
	flex-shrink: 1;
	min-width: 0;
}

.gdv-cw-phase-bar--workspace {
	margin: 0 8px;
}

.gdv-cw-phase-bar--public {
	justify-content: center;
	margin: 20px 0;
	flex-wrap: wrap;
	gap: 4px;
}

.gdv-cw-phase-bar__seg {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 4px 10px;
	border: none;
	border-radius: 4px;
	font-size: 0.75em;
	font-weight: 600;
	line-height: 1.4;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.15s, color 0.15s;
}

.gdv-cw-phase-bar__seg--completed {
	background: var(--gdv-cw-bg-tertiary, #f6f7f7);
	color: var(--gdv-cw-success, #427a7b);
}

.gdv-cw-phase-bar__seg--active {
	background: var(--gdv-cw-accent-bg, #fdf8ee);
	color: var(--gdv-cw-accent, #e1ad4e);
}

.gdv-cw-phase-bar__seg--pending {
	background: var(--gdv-cw-bg-tertiary, #f6f7f7);
	color: var(--gdv-cw-text-faint, #9ca3af);
}

.gdv-cw-phase-bar__seg:hover {
	background: var(--gdv-cw-bg-hover, #f0f0f1);
}

.gdv-cw-phase-bar__icon {
	font-size: 0.9em;
}

.gdv-cw-phase-bar__fraction {
	font-size: 0.85em;
	opacity: 0.8;
}

.gdv-cw-phase-bar__arrow {
	color: var(--gdv-cw-text-faint, #9ca3af);
	font-size: 10px;
	margin: 0 1px;
}

.gdv-cw-phase-bar__arrow::before {
	content: '\203A';
}

/* Hide label on very small workspace topbars, keep fraction. */
@media (max-width: 900px) {
	.gdv-cw-phase-bar--workspace .gdv-cw-phase-bar__label {
		display: none;
	}
}

/* Public: stack vertically on mobile */
@media (max-width: 600px) {
	.gdv-cw-phase-bar--public {
		flex-direction: column;
		align-items: stretch;
	}

	.gdv-cw-phase-bar--public .gdv-cw-phase-bar__arrow {
		display: none;
	}

	.gdv-cw-phase-bar--public .gdv-cw-phase-bar__seg {
		justify-content: space-between;
	}
}

/* ==========================================================================
   Timeline detail panel — expandable step list
   ========================================================================== */

.gdv-cw-timeline-panel {
	border-bottom: 1px solid var(--gdv-cw-border-light, #dcdcde);
	background: var(--gdv-cw-bg, #fff);
	overflow-y: auto;
	max-height: 70vh;
}

.gdv-cw-timeline-panel--workspace {
	position: relative;
	z-index: 90;
}

.gdv-cw-timeline-panel--public {
	border: 1px solid var(--gdv-cw-border-light, #dcdcde);
	border-radius: 8px;
	margin: 20px 0;
}

.gdv-cw-timeline-panel__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	border-bottom: 1px solid var(--gdv-cw-border-faint, #f0f0f1);
}

.gdv-cw-timeline-panel__title {
	margin: 0;
	font-size: 1em;
	font-weight: 600;
}

.gdv-cw-timeline-panel__close {
	border: none;
	background: none;
	font-size: 1.3em;
	cursor: pointer;
	color: var(--gdv-cw-text-muted, #50575e);
	padding: 0 4px;
	line-height: 1;
}

.gdv-cw-timeline-panel__body {
	padding: 8px 16px 16px;
}

/* Phase in detail panel */
.gdv-cw-tl-phase {
	margin-bottom: 4px;
}

.gdv-cw-tl-phase__toggle {
	display: flex;
	align-items: center;
	gap: 6px;
	width: 100%;
	padding: 8px 0;
	border: none;
	background: none;
	cursor: pointer;
	font-weight: 400;
	font-size: 0.9em;
	line-height: 1.65em;
	color: var(--gdv-cw-text-muted, #50575e);
	text-align: left;
	letter-spacing: 0.01em;
}

.gdv-cw-tl-phase__toggle:hover {
	background: none;
	border-color: transparent;
	color: var(--gdv-cw-text, #1e1e1e);
}

.gdv-cw-tl-phase__name::before {
	display: inline-block;
	margin-right: 4px;
	font-size: 0.7em;
	vertical-align: 1px;
	transition: transform 0.15s ease;
}

.gdv-cw-tl-phase__toggle[aria-expanded="true"] .gdv-cw-tl-phase__name::before {
	content: '\25BC';
}

.gdv-cw-tl-phase__toggle[aria-expanded="false"] .gdv-cw-tl-phase__name::before {
	content: '\25B6';
}

.gdv-cw-tl-phase__progress {
	font-weight: 400;
	color: var(--gdv-cw-text-muted, #50575e);
}

/* Steps */
.gdv-cw-tl-phase__steps {
	padding-left: 8px;
}

.gdv-cw-tl-step {
	margin-bottom: 2px;
}

.gdv-cw-tl-step__row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 5px 4px;
	border-radius: 4px;
	font-size: 0.9em;
	line-height: 1.5;
}

.gdv-cw-tl-step__row:hover {
	background: var(--gdv-cw-bg-hover, #f0f0f1);
}

/* Status icons */
.gdv-cw-tl-step__icon {
	flex-shrink: 0;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	border: 2px solid var(--gdv-cw-border, #c3c4c7);
	display: inline-block;
}

.gdv-cw-tl-step--completed .gdv-cw-tl-step__icon {
	background: var(--gdv-cw-success, #427a7b);
	border-color: var(--gdv-cw-success, #427a7b);
}

.gdv-cw-tl-step--completed .gdv-cw-tl-step__icon::after {
	content: '\2713';
	color: #fff;
	font-size: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
}

.gdv-cw-tl-step--active .gdv-cw-tl-step__icon {
	background: var(--gdv-cw-accent, #e1ad4e);
	border-color: var(--gdv-cw-accent, #e1ad4e);
}

.gdv-cw-tl-step--skipped .gdv-cw-tl-step__icon {
	background: var(--gdv-cw-bg-tertiary, #f6f7f7);
	border-color: var(--gdv-cw-border, #c3c4c7);
}

.gdv-cw-tl-step--skipped .gdv-cw-tl-step__icon::after {
	content: '\2013';
	color: var(--gdv-cw-text-faint, #9ca3af);
	font-size: 12px;
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100%;
}

/* Labels */
.gdv-cw-tl-step__label {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.gdv-cw-tl-step--completed .gdv-cw-tl-step__label {
	color: var(--gdv-cw-success, #427a7b);
}

.gdv-cw-tl-step--active .gdv-cw-tl-step__label {
	font-weight: 600;
	color: var(--gdv-cw-accent, #e1ad4e);
}

.gdv-cw-tl-step--skipped .gdv-cw-tl-step__label {
	text-decoration: line-through;
	color: var(--gdv-cw-text-faint, #9ca3af);
}

.gdv-cw-tl-step--pending .gdv-cw-tl-step__label {
	color: var(--gdv-cw-text-muted, #50575e);
}

/* Responsible + date */
.gdv-cw-tl-step__responsible {
	color: var(--gdv-cw-text-subtle, #787c82);
	white-space: nowrap;
}

.gdv-cw-tl-step__date {
	color: var(--gdv-cw-text-subtle, #787c82);
	white-space: nowrap;
}

.gdv-cw-tl-step__date--overdue {
	color: #dc2626;
	font-weight: 600;
}

/* Note */
.gdv-cw-tl-step__note {
	padding: 2px 4px 2px 26px;
	font-size: 0.85em;
	line-height: 1.5;
	color: var(--gdv-cw-text-subtle, #787c82);
	font-style: italic;
}

/* Derived status hint */
.gdv-cw-tl-step__derived-hint {
	padding: 2px 4px 2px 26px;
	font-size: 0.85em;
	line-height: 1.5;
	color: var(--gdv-cw-text-faint, #9ca3af);
	margin: 0;
}

/* Action buttons (PM only) */
.gdv-cw-tl-step__actions {
	display: flex;
	gap: 4px;
	margin-left: auto;
	flex-shrink: 0;
}

.gdv-cw-tl-action {
	border: 1px solid var(--gdv-cw-border-light, #dcdcde);
	background: var(--gdv-cw-bg, #fff);
	cursor: pointer;
	padding: 3px 8px;
	font-size: 0.8em;
	font-weight: 500;
	color: var(--gdv-cw-text-muted, #50575e);
	border-radius: 4px;
	line-height: 1.4;
	white-space: nowrap;
}

.gdv-cw-tl-action:hover {
	background: var(--gdv-cw-bg-hover, #f0f0f1);
	border-color: var(--gdv-cw-border-hover, #a2a2a2);
	color: var(--gdv-cw-text, #1e1e1e);
}

.gdv-cw-tl-action--danger {
	color: #dc2626;
	border-color: #fecaca;
}

.gdv-cw-tl-action--danger:hover {
	background: #fef2f2;
	border-color: #dc2626;
}

/* Sub-steps */
.gdv-cw-tl-substeps {
	padding-left: 22px;
	border-left: 2px solid var(--gdv-cw-border-faint, #f0f0f1);
	margin-left: 6px;
	margin-top: 2px;
}

.gdv-cw-tl-substep {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 3px 4px;
	border-radius: 4px;
	font-size: 0.85em;
	line-height: 1.5;
}

.gdv-cw-tl-substep:hover {
	background: var(--gdv-cw-bg-hover, #f0f0f1);
}

.gdv-cw-tl-substep .gdv-cw-tl-step__icon {
	width: 10px;
	height: 10px;
}

.gdv-cw-tl-substep .gdv-cw-tl-step__actions {
	display: flex;
}

/* Add buttons */
.gdv-cw-tl-add-substep,
.gdv-cw-tl-add-step {
	border: none;
	background: none;
	cursor: pointer;
	padding: 4px 4px;
	font-size: 0.85em;
	line-height: 1.5;
	color: var(--gdv-cw-text-subtle, #787c82);
}

.gdv-cw-tl-add-substep:hover,
.gdv-cw-tl-add-step:hover {
	color: var(--gdv-cw-accent, #e1ad4e);
}

/* Inline forms */
.gdv-cw-tl-inline-form {
	padding: 10px 4px 10px 26px;
	background: var(--gdv-cw-bg-secondary, #fafafa);
	border-radius: 6px;
	margin: 4px 0;
}

.gdv-cw-tl-inline-form__row {
	margin-bottom: 6px;
}

.gdv-cw-tl-inline-form__row label {
	display: block;
	font-size: 0.75em;
	font-weight: 600;
	color: var(--gdv-cw-text-subtle, #787c82);
	text-transform: uppercase;
	letter-spacing: 0.04em;
	margin-bottom: 2px;
}

.gdv-cw-tl-input {
	display: block;
	width: 100%;
	max-width: 320px;
	padding: 6px 8px;
	font-size: 0.9em;
	line-height: 1.5;
	border: 1px solid var(--gdv-cw-border-light, #dcdcde);
	border-radius: 4px;
	background: var(--gdv-cw-bg, #fff);
	color: var(--gdv-cw-text, #1e1e1e);
}

.gdv-cw-tl-input:focus {
	outline: none;
	border-color: var(--gdv-cw-accent, #e1ad4e);
	box-shadow: 0 0 0 1px var(--gdv-cw-accent, #e1ad4e);
}

.gdv-cw-tl-inline-form__actions {
	display: flex;
	gap: 6px;
	margin-top: 8px;
}

.gdv-cw-tl-inline-form .gdv-cw-btn {
	font-size: 0.85em;
	padding: 6px 14px;
}

/* ==========================================================================
   Mobile — Admin timeline + milestone labels
   ========================================================================== */

@media screen and (max-width: 782px) {

	/* Timeline template: max-width override */
	.gdv-cw-timeline-admin {
		max-width: 100%;
	}

	/* Labels table: max-width override */
	.gdv-cw-labels-table {
		max-width: 100% !important;
	}

	/* Phase header: stack on narrow screens */
	.gdv-cw-tpl-phase__header {
		flex-wrap: wrap;
		gap: 8px;
	}

	.gdv-cw-tpl-phase__toggle {
		min-height: 44px;
		padding: 8px 14px;
		font-size: 14px;
	}

	/* Column widths: reset for card layout */
	.gdv-cw-tpl-col--order,
	.gdv-cw-tpl-col--label,
	.gdv-cw-tpl-col--responsible,
	.gdv-cw-tpl-col--description,
	.gdv-cw-tpl-col--actions,
	.gdv-cw-labels-col--drag,
	.gdv-cw-labels-col--label,
	.gdv-cw-labels-col--label-fr,
	.gdv-cw-labels-col--actions {
		width: auto;
		text-align: left;
		white-space: normal;
	}

	/* Timeline step — hide order number on mobile (redundant in card view) */
	.gdv-cw-tpl-col--order {
		display: none;
	}

	/* Labels drag handle — larger touch target */
	.gdv-cw-labels-drag-handle {
		font-size: 22px;
		padding: 8px;
		display: inline-block;
	}

	/* Action buttons in labels / template tables */
	.gdv-cw-labels-col--actions,
	.gdv-cw-tpl-col--actions {
		display: flex;
		flex-wrap: wrap;
		gap: 8px;
		padding-top: 8px;
		border-top: 1px solid #f0f0f0;
		margin-top: 4px;
	}

	.gdv-cw-labels-col--actions .button,
	.gdv-cw-tpl-col--actions .button {
		min-height: 44px;
		padding: 8px 16px;
		font-size: 14px;
		flex: 1;
		text-align: center;
	}

	/* Edit form: full width on mobile */
	.gdv-cw-tpl-edit-form {
		max-width: 100%;
	}

	.gdv-cw-tpl-edit-form__row input,
	.gdv-cw-tpl-edit-form__row textarea {
		max-width: 100%;
		font-size: 16px;
	}

	.gdv-cw-tpl-edit-form__row label {
		font-size: 13px;
	}

	.gdv-cw-tpl-edit-form__actions .button,
	.gdv-cw-tpl-edit-form__actions .button-primary {
		min-height: 44px;
		padding: 8px 20px;
		font-size: 14px;
	}

	/* Edit row in labels table: full-width inputs */
	.gdv-cw-labels-row--editing input {
		font-size: 16px;
		padding: 8px;
	}

	.gdv-cw-labels-row--editing .button,
	.gdv-cw-labels-row--editing .button-primary {
		min-height: 44px;
		padding: 8px 16px;
		font-size: 14px;
	}

	/* Add buttons */
	.gdv-cw-labels-add__btn,
	.gdv-cw-tpl-add-step,
	.gdv-cw-tpl-add-phase__btn {
		min-height: 44px;
		padding: 8px 16px;
		font-size: 14px;
	}

	/* Add-phase form */
	.gdv-cw-tpl-add-phase-form {
		max-width: 100%;
	}

	.gdv-cw-tpl-add-phase-form input {
		font-size: 16px;
	}

	.gdv-cw-tpl-add-phase-form .button,
	.gdv-cw-tpl-add-phase-form .button-primary {
		min-height: 44px;
		padding: 8px 20px;
		font-size: 14px;
	}

	/* Timeline detail panel — wider on mobile */
	.gdv-cw-timeline-panel {
		max-height: 60vh;
	}

	.gdv-cw-timeline-panel__close {
		min-width: 44px;
		min-height: 44px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}

	/* Timeline action buttons */
	.gdv-cw-tl-action {
		min-height: 36px;
		padding: 6px 12px;
		font-size: 0.85em;
	}

	/* Inline forms */
	.gdv-cw-tl-input {
		max-width: 100%;
		font-size: 16px;
	}

	.gdv-cw-tl-inline-form .gdv-cw-btn {
		min-height: 44px;
		font-size: 14px;
		padding: 8px 16px;
	}

}
