.ultimate-email-logger {
	max-width: 100%;
	padding: 20px 0;
}

.habibi-log-viewer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 16px;

	h1 {
		margin: 0;
	}
}

.habibi-bulk-actions {
	display: flex;
	gap: 8px;
	align-items: center;
}

.habibi-settings {
	max-width: 1032px;
}

.habibi-settings__description {
	color: #757575;
	font-size: 14px;
	margin: 0 0 24px;
	padding-bottom: 24px;
	border-bottom: 1px solid #ddd;
}

.habibi-settings-section {
	display: flex;
	gap: 24px;
	margin-bottom: 32px;
	align-items: flex-start;

	&__info {
		flex: 0 0 280px;

		h3 {
			margin: 0 0 8px;
			font-size: 14px;
		}

		p {
			color: #757575;
			margin: 0;
			font-size: 13px;
		}
	}

	&__controls {
		flex: 1;
		min-width: 0;
	}

	@media (max-width: 782px) {
		flex-direction: column;

		&__info {
			flex-basis: auto;
		}
	}
}

.habibi-search-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	align-items: flex-end;
	margin-bottom: 16px;

	.components-base-control {
		margin-bottom: 0;

		.components-base-control__field {
			margin-bottom: 0;
		}

		input,
		select,
		.components-input-control__container {
			height: 36px;
			min-height: 36px;
		}
	}

	&__search {
		flex: 1;
		min-width: 200px;
		max-width: 300px;
	}

	&__date {
		width: 160px;
	}
}

.habibi-log-table-wrapper {
	position: relative;
}

.habibi-log-table-loading {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.7);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10;
}

.habibi-log-table {
	.habibi-log-table__checkbox-cell {
		width: 40px;
		padding: 8px 10px;
		vertical-align: top;

		input[type="checkbox"] {
			margin: 0;
		}
	}

	.habibi-log-table__id-cell {
		width: 60px;
	}

	.habibi-log-table__status-cell {
		width: 80px;
	}

	.habibi-log-table__actions-cell {
		width: 140px;

		.components-button {
			height: 30px;
			min-height: 30px;
			padding: 5px;
			margin-right: 6px;

			&.has-icon .dashicon {
				padding: 5px;
			}
		}
	}

	.habibi-log-table__cc-cell,
	.habibi-log-table__bcc-cell,
	.habibi-log-table__reply-to-cell {
		width: 120px;
	}

	.habibi-log-table__attachments-cell {
		width: 90px;
	}

	.habibi-log-table__opens-cell {
		width: 70px;
	}

	@media (max-width: 1200px) {
		.habibi-log-table__cc-cell,
		.habibi-log-table__bcc-cell,
		.habibi-log-table__reply-to-cell,
		.habibi-log-table__opens-cell {
			display: none;
		}
	}

	th.sortable {
		cursor: pointer;
		user-select: none;

		&:hover {
			background: #f0f0f1;
		}
	}

	.sort-indicator {
		margin-left: 4px;
		font-size: 12px;
	}
}

.habibi-status-badge {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 3px;
	font-size: 12px;
	font-weight: 600;

	&--sent {
		background: #d4edda;
		color: #155724;
	}

	&--failed {
		background: #f8d7da;
		color: #721c24;
	}
}

.habibi-pagination {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 0;
	flex-wrap: wrap;
	gap: 8px;

	&__info {
		color: #50575e;
	}

	&__controls {
		display: flex;
		align-items: center;
		gap: 8px;
	}

	&__per-page {
		display: flex;
		align-items: center;
		gap: 4px;

		.components-base-control {
			margin-bottom: 0;
		}
	}
}

.habibi-empty-state {
	text-align: center;
	padding: 40px 20px;
	color: #757575;
}

.habibi-log-detail-modal {
	min-width: 600px;
	max-width: 90vw;

	.habibi-log-detail-meta {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 12px;
		margin-bottom: 20px;
		padding: 16px;
		background: #f6f7f7;
		border-radius: 4px;

		dt {
			font-weight: 600;
			color: #1e1e1e;
			font-size: 12px;
			text-transform: uppercase;
			margin: 0;
		}

		dd {
			margin: 0 0 8px;
			word-break: break-all;
		}
	}

	.habibi-log-detail-body {
		iframe {
			width: 100%;
			border: 1px solid #ddd;
			min-height: 300px;
			background: #fff;
		}

		pre {
			background: #f6f7f7;
			padding: 16px;
			overflow-x: auto;
			border-radius: 4px;
			max-height: 500px;
			overflow-y: auto;

			code {
				white-space: pre-wrap;
				word-break: break-all;
			}
		}
	}

	.habibi-log-attachments {
		list-style: disc;
		padding-left: 20px;
		margin: 4px 0 0;

		li {
			font-size: 13px;
		}
	}
}

.habibi-resend-modal {
	min-width: 500px;
	max-width: 700px;

	.habibi-resend-meta {
		display: grid;
		grid-template-columns: repeat(2, 1fr);
		gap: 8px 16px;
		margin-bottom: 16px;
		padding: 12px;
		background: #f6f7f7;
		border-radius: 4px;
		font-size: 13px;

		dt {
			font-weight: 600;
			margin: 0;
		}

		dd {
			margin: 0;
			word-break: break-all;
		}
	}

	.habibi-resend-body-preview {
		margin-bottom: 16px;

		&__label {
			font-weight: 600;
			margin: 0 0 8px;
		}

		iframe {
			width: 100%;
			border: 1px solid #ddd;
			min-height: 250px;
			background: #fff;
		}

		pre {
			background: #f6f7f7;
			padding: 12px;
			overflow-x: auto;
			border-radius: 4px;
			max-height: 300px;
			overflow-y: auto;
			white-space: pre-wrap;
			word-break: break-all;
		}
	}

	.habibi-resend-actions {
		display: flex;
		gap: 8px;
		justify-content: flex-end;
		margin-top: 16px;
	}
}

.habibi-export-modal {
	min-width: 500px;
	max-width: 600px;

	.habibi-export-scope {
		margin-bottom: 16px;
		font-weight: 600;
	}

	.habibi-export-fields {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 4px;
		margin-bottom: 16px;

		.components-base-control {
			margin-bottom: 0;
		}
	}

	.habibi-export-options {
		margin-bottom: 16px;

		.components-base-control {
			margin-bottom: 8px;
		}
	}

	.habibi-export-actions {
		display: flex;
		gap: 8px;
		justify-content: flex-end;
	}
}

.habibi-stats-summary {
	display: flex;
	gap: 16px;
	margin-bottom: 24px;
	flex-wrap: wrap;

	.habibi-stats-card {
		flex: 1;
		min-width: 150px;
		text-align: center;

		&__value {
			font-size: 32px;
			font-weight: 700;
			line-height: 1.2;
		}

		&__label {
			font-size: 13px;
			color: #757575;
			margin-top: 4px;
		}

		&--sent .habibi-stats-card__value {
			color: #155724;
		}

		&--failed .habibi-stats-card__value {
			color: #721c24;
		}
	}
}

.habibi-stats-chart {
	margin-bottom: 24px;
	padding: 16px;
	background: #fff;
	border: 1px solid #ddd;
	border-radius: 4px;

	&__title {
		font-size: 14px;
		font-weight: 600;
		margin-bottom: 12px;
	}

	&__bars {
		display: flex;
		align-items: flex-end;
		gap: 2px;
		height: 200px;
	}

	&__bar {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: flex-end;
		min-width: 4px;
		height: 100%;
	}

	&__sent {
		background: #d4edda;
	}

	&__failed {
		background: #f8d7da;
	}

	&__labels {
		display: flex;
		gap: 2px;
		margin-top: 4px;
	}

	&__label {
		flex: 1;
		text-align: center;
		font-size: 10px;
		color: #757575;
		overflow: hidden;
		min-width: 4px;
	}

	&__empty {
		text-align: center;
		padding: 40px;
		color: #757575;
	}
}

.habibi-stats-recipients {
	margin-bottom: 24px;

	table {
		width: 100%;
		border-collapse: collapse;
	}

	th,
	td {
		padding: 8px 12px;
		text-align: left;
		border-bottom: 1px solid #ddd;
	}

	th {
		font-weight: 600;
		background: #f6f7f7;
	}
}
