/* Geolocation Groups Styles */

/* Location Search */
.wpconsent-location-search {
	margin-bottom: 15px;

	input {
		width: 100%;
		padding: 8px;
		border: var(--wpconsent-input-border);
		border-radius: 4px;
	}
}

/* Location Tools */
.wpconsent-location-tools {
	display: flex;
	gap: 10px;
	margin-bottom: 15px;

	.wpconsent-button {
		padding: 8px 16px;
		background: var(--wpconsent-button-secondary-bg);
		border: var(--wpconsent-button-secondary-border);
		border-radius: 3px;
		cursor: pointer;
		font-size: 14px;
		color: var(--wpconsent-button-secondary-text);

		&:hover {
			background: var(--wpconsent-button-secondary-bg-hover);
			color: var(--wpconsent-button-secondary-text-hover);
		}
	}
}

/* Hierarchical Tree */
.wpconsent-hierarchical-selector {
	margin-bottom: 20px;
}

.wpconsent-hierarchical-tree {
	border: 1px solid var(--wpconsent-border-color);
	border-radius: 4px;
	background: var(--wpconsent-background-gray);
	max-height: 500px;
	overflow-y: auto;
	padding: 10px;
}

.wpconsent-tree-item {
	margin-bottom: 8px;
}

.wpconsent-tree-item-header {
	display: flex;
	align-items: center;
	padding: 10px;
	border-radius: 3px;
	background: var(--wpconsent-background-white);
	border: 1px solid var(--wpconsent-border-color);

	&:hover {
		background: var(--wpconsent-background-light);
	}
}

.wpconsent-tree-toggle {
	cursor: pointer;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	margin-right: 8px;
}

.wpconsent-tree-spacer {
	width: 28px;
	margin-right: 8px;
}

.wpconsent-tree-label {
	display: flex;
	align-items: center;
	flex-grow: 1;
	cursor: pointer;
}

.wpconsent-tree-children {
	margin-left: 36px;
	margin-top: 8px;
}

/* Continent level styling */
.wpconsent-tree-continent {
	& > .wpconsent-tree-item-header {
		background: var(--wpconsent-background-white);
		border-color: var(--wpconsent-border-color);

		&:hover {
			background: var(--wpconsent-background-light);
		}
	}

	.wpconsent-tree-label .wpconsent-checkbox-toggle {
		margin-right: 8px;
		margin-top: 0;

		input:disabled {
			cursor: not-allowed;

			& + .wpconsent-checkbox-toggle-slider {
				opacity: 0.5;
			}
		}
	}
}

/* Country level styling */
.wpconsent-tree-country {
	& > .wpconsent-tree-item-header {
		background: var(--wpconsent-background-white);
	}

	.wpconsent-tree-label .wpconsent-checkbox-toggle {
		margin-right: 8px;
		margin-top: 0;

		input:disabled {
			cursor: not-allowed;

			& + .wpconsent-checkbox-toggle-slider {
				opacity: 0.5;
			}
		}
	}
}

/* State level styling */
.wpconsent-tree-state {
	& > .wpconsent-tree-item-header {
		background: var(--wpconsent-background-gray);
	}

	.wpconsent-tree-label .wpconsent-checkbox-toggle {
		margin-right: 8px;
		margin-top: 0;

		input:disabled {
			cursor: not-allowed;

			& + .wpconsent-checkbox-toggle-slider {
				opacity: 0.5;
			}
		}
	}
}

/* Location Grid */
.wpconsent-location-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
	gap: 10px;
	max-height: 300px;
	overflow-y: auto;
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background: #f9f9f9;
}

.wpconsent-location-item {
	display: flex;
	align-items: center;
	padding: 5px 10px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 3px;
	cursor: pointer;

	&:hover {
		background: #f0f0f0;
	}

	.wpconsent-checkbox-toggle {
		margin-right: 8px;
		vertical-align: middle;

		input:disabled {
			cursor: not-allowed;

			& + .wpconsent-checkbox-toggle-slider {
				opacity: 0.5;
			}
		}
	}
}

.wpconsent-location-used {
	opacity: 0.6;
	background: #f5f5f5;
}

.wpconsent-location-used-indicator {
	font-size: 0.8em;
	color: #999;
	margin-left: 5px;
}

/* Countries Search */
.wpconsent-countries-search {
	margin-bottom: 10px;

	input {
		width: 100%;
		padding: 8px;
		border: 1px solid #ddd;
		border-radius: 4px;
	}
}

/* Selected Locations */
.wpconsent-selected-locations {
	margin-top: 20px;
	padding: 15px;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;

	h4 {
		margin-top: 0;
		margin-bottom: 10px;
		font-size: 14px;
		color: #23282d;
	}
}

.wpconsent-selected-locations-list {
	min-height: 50px;
}

.wpconsent-selected-location {
	display: inline-flex;
	align-items: center;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 3px;
	padding: 5px 10px;
	margin: 0 5px 5px 0;
}

.wpconsent-selected-location-remove {
	cursor: pointer;
	color: #cc0000;
	margin-left: 5px;
}

.wpconsent-no-selections {
	color: #999;
	font-style: italic;
}

/* Location Group Items */
.wpconsent-location-group-item {
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;
	margin-bottom: 15px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.wpconsent-location-group-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 15px;
	border-bottom: 1px solid #eee;
	background: #f9f9f9;
	border-radius: 4px 4px 0 0;

	h4 {
		margin: 0;
		font-size: 14px;
	}
}

.wpconsent-location-group-actions {
	display: flex;
	gap: 5px;
}

.wpconsent-location-group-details {
	padding: 15px;
}

.wpconsent-location-group-locations,
.wpconsent-location-group-settings {
	margin-bottom: 10px;
}

.wpconsent-location-group-settings {
	ul {
		margin: 5px 0 0 20px;
		list-style-type: disc;
	}
}

/* Form Actions */
.wpconsent-form-actions {
	margin-top: 20px;
	display: flex;
	gap: 10px;
}

/* Responsive Adjustments */
@media (max-width: 782px) {
	.wpconsent-location-grid {
		grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
	}

	.wpconsent-location-group-header {
		flex-direction: column;
		align-items: flex-start;
	}

	.wpconsent-location-group-actions {
		margin-top: 10px;
	}
}

/* Predefined Rules Styles */
.wpconsent-predefined-rules {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: 16px;
	margin-bottom: 20px;
}

.wpconsent-predefined-rule {
	background: #fff;
	border: 1px solid #c3c4c7;
	border-radius: 4px;
	padding: 20px;
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
	display: flex;
	flex-direction: column;
	min-height: 140px;
	position: relative;
	transition: border-color 200ms;

	h3 {
		margin: 0 0 8px 0;
		font-size: 14px;
		font-weight: 600;
		color: #1d2327;
		line-height: 1.4;
	}

	p {
		margin: 0 0 16px 0;
		flex-grow: 1;
		color: #646970;
		font-size: 13px;
		line-height: 1.4;
	}

	.wpconsent-button {
		display: inline-block;
		padding: 0;
		background: none;
		color: #2271b1;
		border: none;
		cursor: pointer;
		text-decoration: none;
		text-align: left;
		font-size: 13px;
		line-height: 1.4;
		font-weight: normal;
		margin-top: auto;

		&:hover {
			color: #135e96;
			text-decoration: underline;
		}

		&:focus {
			box-shadow: 0 0 0 2px #2271b1;
			outline: 2px solid transparent;
		}
	}

	.wpconsent-button-disabled {
		color: #a7aaad;
		cursor: not-allowed;

		&:hover {
			color: #a7aaad;
			text-decoration: none;
		}
	}

	&:hover {
		border-color: #4F9027;
	}
}

/* Responsive adjustments for predefined rules */
@media (max-width: 1200px) {
	.wpconsent-predefined-rules {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 782px) {
	.wpconsent-predefined-rules {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.wpconsent-predefined-rule {
		padding: 16px;
		min-height: 120px;
	}
}

/* Location Groups Table - Figma Design Match */
.wp-list-table.wpconsent-location-groups-table {
	margin-top: 0;
	margin-bottom: 20px;
	background: #ffffff;
	border: 1px solid #E8E8EB;
	border-radius: 8px;
	box-shadow: none;
	font-size: 14px;
	border-collapse: separate;
	border-spacing: 0;

	th,
	td {
		padding: 16px 20px;
		vertical-align: middle;
		border-bottom: 1px solid #E8E8EB;
		border-right: none;
		border-left: none;
	}

	thead th {
		background: #ffffff;
		font-weight: 600;
		font-size: 14px;
		color: #1D2327;
		letter-spacing: 0;
		text-transform: none;
		border-top: none;
		border-bottom: 1px solid #E8E8EB;
	}

	thead th:first-child {
		border-top-left-radius: 8px;
	}

	thead th:last-child {
		border-top-right-radius: 8px;
	}

	tbody tr:last-child td {
		border-bottom: none;
	}

	tbody tr:last-child td:first-child {
		border-bottom-left-radius: 8px;
	}

	tbody tr:last-child td:last-child {
		border-bottom-right-radius: 8px;
	}

	tbody tr:hover {
		background: #F9F9F9;
	}

	.column-checkbox {
		width: 60px;
		text-align: center;
	}

	.column-name {
		font-weight: 600;
		color: #1D2327;
	}

	.column-locations {
		color: #646970;
		font-size: 13px;
	}

	.column-type {
		color: #646970;
		font-size: 13px;
	}

	.column-consent-settings {
		min-width: 140px;
	}

	.consent-setting-item {
		font-size: 13px;
		margin-bottom: 4px;
		display: flex;
		align-items: center;
		gap: 4px;

		.consent-setting-checkmark {
			width: 16px;
			text-align: center;
		}

		.consent-setting-checkmark-enabled {
			color: #4F9027; /* Green for checkmark */
		}

		.consent-setting-checkmark-disabled {
			color: #cc0000; /* Red for X */
		}

		.consent-setting-text {
			color: #646970; /* Default text color */
		}
	}

	.consent-setting-item:last-child {
		margin-bottom: 0;
	}

	.column-mode {
		color: #646970;
		font-size: 13px;
	}

	.column-action {
		min-width: 90px;
		text-align: left;
	}

	.wpconsent-button-icon {
		padding: 8px;
		background: none;
		border: none;
		cursor: pointer;
		color: #646970;
		margin-right: 8px;
		border-radius: 4px;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		transition: all 0.2s ease;
	}

	.wpconsent-button-icon:hover {
		background: #F0F0F1;
		color: #1D2327;

		svg path {
			fill: #1D2327;
		}
	}

	.dashicons {
		font-size: 16px;
		line-height: 1;
	}

	/* Remove WordPress default striping */

	&.striped > tbody > :nth-child(odd) {
		background: transparent;
	}

	/* Remove default border styling */

	&.widefat {
		border: 1px solid #E8E8EB;
	}

	@media (max-width: 782px) {
		th,
		td {
			padding: 12px 16px;
			font-size: 13px;
		}

		.column-checkbox {
			width: 50px;
		}

		.column-consent-settings {
			min-width: 120px;
		}

		.consent-setting-item {
			font-size: 12px;
		}

		.column-action {
			min-width: 80px;
		}

		.wpconsent-button-icon {
			padding: 6px;
			margin-right: 6px;
		}
	}
}
