/**
 * Calendar Styles
 *
 * Modern calendar styling with native WordPress aesthetics.
 *
 * @package EventsAndTicketsForWooCommerce
 * @since 1.0.0
 */

/* Calendar Container */
.emwc-calendar {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	max-width: 100%;
	margin: 0 auto;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	overflow: hidden;
}

/* Calendar Header */
.emwc-calendar-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	background: linear-gradient(to bottom, #fff, #fafbfc);
	border-bottom: 1px solid #e2e8f0;
}

.emwc-calendar-title {
	margin: 0;
	font-size: 1.375em;
	font-weight: 600;
	color: #1e293b;
	letter-spacing: -0.01em;
}

.emwc-calendar-nav {
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 10px 14px;
	cursor: pointer;
	transition: all 0.15s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #64748b;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.emwc-calendar-nav:hover {
	background: #f8fafc;
	border-color: #cbd5e1;
	color: #1e293b;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.emwc-calendar-nav:active {
	background: #f1f5f9;
	box-shadow: none;
}

.emwc-calendar-nav .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

/* Calendar Table */
.emwc-calendar-table {
	width: 100%;
	border-collapse: collapse;
	background: #fff;
	table-layout: fixed;
}

/* Day Headers */
.emwc-calendar-table th {
	background: #f8fafc;
	padding: 14px 8px;
	text-align: center;
	font-weight: 600;
	font-size: 0.75em;
	color: #64748b;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	border-bottom: 1px solid #e2e8f0;
}

/* Weekend day headers - subtle tint */
.emwc-calendar-table th:first-child,
.emwc-calendar-table th:last-child {
	color: #94a3b8;
	background: #f1f5f9;
}

/* Calendar Cells */
.emwc-calendar-table td {
	border: 1px solid #f1f5f9;
	vertical-align: top;
	height: 120px;
	padding: 8px;
	position: relative;
	background: #fff;
	transition: background 0.15s ease;
}

/* Weekday cells */
.emwc-calendar-day {
	background: #fff;
}

.emwc-calendar-day:hover {
	background: #fafbfc;
}

/* Weekend cells - soft warm gray tint */
.emwc-calendar-weekend {
	background: #fafafa;
}

.emwc-calendar-weekend:hover {
	background: #f5f5f5;
}

/* Empty cells */
.emwc-calendar-empty {
	background: #fafbfc;
}

.emwc-calendar-empty.emwc-calendar-weekend,
.emwc-calendar-empty:hover {
	background: #f5f5f4;
}

/* Today highlight */
.emwc-calendar-today {
	background: #eff6ff !important;
}

.emwc-calendar-today:hover {
	background: #dbeafe !important;
}

.emwc-calendar-today .emwc-day-number {
	background: #2563eb;
	color: #fff;
	font-weight: 600;
}

/* Day Number */
.emwc-day-number {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	font-weight: 500;
	font-size: 0.875em;
	color: #374151;
	margin-bottom: 6px;
	transition: all 0.15s ease;
}

/* Weekend day numbers - slightly muted */
.emwc-calendar-weekend .emwc-day-number {
	color: #6b7280;
}

/* Day Events Container */
.emwc-day-events {
	display: flex;
	flex-direction: column;
	gap: 4px;
	overflow: hidden;
	max-height: calc(100% - 40px);
}

/* Event Item */
.emwc-day-event {
	display: flex;
	align-items: center;
	padding: 4px 8px;
	background: #f0f9ff;
	border-left: 3px solid #3b82f6;
	border-radius: 0 6px 6px 0;
	font-size: 0.75em;
	text-decoration: none;
	color: #1e40af;
	transition: all 0.15s ease;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
}

.emwc-day-event:hover {
	background: #dbeafe;
	color: #1e3a8a;
	transform: translateX(2px);
}

.emwc-event-dot {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	margin-right: 6px;
	flex-shrink: 0;
}

.emwc-event-title {
	overflow: hidden;
	text-overflow: ellipsis;
	font-weight: 500;
}

/* More events indicator */
.emwc-day-event.emwc-more-events {
	background: #f8fafc;
	border-left-color: #94a3b8;
	color: #64748b;
	font-size: 0.6875em;
	font-weight: 500;
}

/* Calendar Footer */
.emwc-calendar-footer {
	padding: 18px 24px;
	text-align: center;
	background: linear-gradient(to top, #fff, #fafbfc);
	border-top: 1px solid #e2e8f0;
}

.emwc-calendar-today-btn {
	background: #2563eb;
	color: #fff;
	border: none;
	padding: 10px 28px;
	border-radius: 8px;
	cursor: pointer;
	font-size: 0.875em;
	font-weight: 500;
	transition: all 0.15s ease;
	box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.emwc-calendar-today-btn:hover {
	background: #1d4ed8;
	box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
	transform: translateY(-1px);
}

.emwc-calendar-today-btn:active {
	background: #1e40af;
	transform: translateY(0);
	box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

/* Event Popup */
.emwc-event-popup {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(15, 23, 42, 0.4);
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	backdrop-filter: blur(4px);
}

.emwc-popup-content {
	background: #fff;
	border-radius: 16px;
	max-width: 480px;
	width: 100%;
	max-height: 80vh;
	overflow-y: auto;
	position: relative;
	box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
	animation: emwc-popup-in 0.2s ease-out;
}

@keyframes emwc-popup-in {
	from {
		opacity: 0;
		transform: scale(0.95) translateY(10px);
	}
	to {
		opacity: 1;
		transform: scale(1) translateY(0);
	}
}

.emwc-popup-close {
	position: absolute;
	top: 16px;
	right: 16px;
	background: #f1f5f9;
	border: none;
	font-size: 18px;
	cursor: pointer;
	color: #64748b;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 8px;
	transition: all 0.15s ease;
}

.emwc-popup-close:hover {
	background: #e2e8f0;
	color: #1e293b;
}

.emwc-popup-body {
	padding: 28px;
}

.emwc-popup-body h3 {
	margin: 0 0 16px;
	font-size: 1.25em;
	font-weight: 600;
	color: #1e293b;
	padding-right: 40px;
}

.emwc-popup-meta p {
	margin: 12px 0;
	display: flex;
	align-items: center;
	gap: 10px;
	color: #64748b;
	font-size: 0.9375em;
}

.emwc-popup-meta .dashicons {
	color: #3b82f6;
	font-size: 18px;
	width: 18px;
	height: 18px;
}

.emwc-popup-excerpt {
	margin: 20px 0;
	color: #475569;
	line-height: 1.6;
}

.emwc-popup-actions {
	margin-top: 24px;
}

.emwc-popup-actions .button {
	background: #2563eb;
	color: #fff;
	border: none;
	padding: 12px 24px;
	border-radius: 8px;
	text-decoration: none;
	display: inline-block;
	font-weight: 500;
	font-size: 0.9375em;
	transition: background 0.15s ease;
}

.emwc-popup-actions .button:hover {
	background: #1d4ed8;
	color: #fff;
}

/* List View */
.emwc-calendar-list {
	background: transparent;
	border: none;
	border-radius: 0;
}

.emwc-calendar-list .emwc-event-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.emwc-event-item {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	padding: 20px;
	background: #fff;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	transition: all 0.2s ease;
}

.emwc-event-item:hover {
	border-color: #cbd5e1;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
	transform: translateY(-2px);
}

.emwc-event-date-box {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-width: 64px;
	padding: 12px 14px;
	background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
	color: #fff;
	border-radius: 10px;
	text-align: center;
	box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.emwc-event-month {
	font-size: 0.6875em;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	font-weight: 500;
	opacity: 0.9;
}

.emwc-event-day {
	font-size: 1.625em;
	font-weight: 700;
	line-height: 1.1;
}

.emwc-event-info {
	flex: 1;
	min-width: 0;
}

.emwc-event-info h3 {
	margin: 0 0 8px;
	font-size: 1.0625em;
	font-weight: 600;
}

.emwc-event-info h3 a {
	color: #1e293b;
	text-decoration: none;
	transition: color 0.15s ease;
}

.emwc-event-info h3 a:hover {
	color: #2563eb;
}

.emwc-event-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	color: #64748b;
	font-size: 0.875em;
}

.emwc-event-meta span {
	display: flex;
	align-items: center;
	gap: 6px;
}

.emwc-event-meta .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
	color: #3b82f6;
}

.emwc-event-thumbnail {
	width: 100px;
	height: 80px;
	overflow: hidden;
	border-radius: 8px;
	flex-shrink: 0;
}

.emwc-event-thumbnail img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* No Events */
.emwc-no-events {
	text-align: center;
	padding: 48px 24px;
	color: #64748b;
	background: #f8fafc;
	border-radius: 12px;
	font-size: 0.9375em;
	border: 1px dashed #e2e8f0;
}

/* Loading State */
.emwc-calendar.loading {
	opacity: 0.6;
	pointer-events: none;
	position: relative;
}

.emwc-calendar.loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 32px;
	height: 32px;
	margin: -16px 0 0 -16px;
	border: 3px solid #e2e8f0;
	border-top-color: #3b82f6;
	border-radius: 50%;
	animation: emwc-spin 0.8s linear infinite;
}

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

/* ========================================
   Responsive Styles
   ======================================== */

/* Tablet */
@media (max-width: 768px) {
	.emwc-calendar {
		border-radius: 10px;
	}

	.emwc-calendar-header {
		padding: 16px 20px;
	}

	.emwc-calendar-title {
		font-size: 1.125em;
	}

	.emwc-calendar-table td {
		height: 90px;
		padding: 6px;
	}

	.emwc-day-number {
		width: 26px;
		height: 26px;
		font-size: 0.8125em;
	}

	.emwc-day-event {
		font-size: 0.6875em;
		padding: 3px 6px;
		border-left-width: 2px;
	}

	.emwc-event-dot {
		width: 5px;
		height: 5px;
		margin-right: 4px;
	}

	.emwc-event-item {
		flex-direction: column;
		padding: 16px;
	}

	.emwc-event-date-box {
		min-width: auto;
		flex-direction: row;
		gap: 8px;
		padding: 10px 14px;
	}

	.emwc-event-thumbnail {
		width: 100%;
		height: 160px;
		order: -1;
	}
}

/* Mobile */
@media (max-width: 480px) {
	.emwc-calendar {
		border-radius: 8px;
	}

	.emwc-calendar-header {
		padding: 14px 16px;
	}

	.emwc-calendar-title {
		font-size: 1em;
	}

	.emwc-calendar-nav {
		padding: 8px 12px;
	}

	.emwc-calendar-table th {
		padding: 10px 4px;
		font-size: 0.625em;
		letter-spacing: 0.05em;
	}

	.emwc-calendar-table td {
		height: 60px;
		padding: 4px;
	}

	.emwc-day-events {
		display: none;
	}

	/* Show dot indicator on mobile when events exist */
	.emwc-calendar-has-events {
		position: relative;
	}

	.emwc-calendar-has-events::after {
		content: '';
		position: absolute;
		bottom: 6px;
		left: 50%;
		transform: translateX(-50%);
		width: 6px;
		height: 6px;
		background: #3b82f6;
		border-radius: 50%;
	}

	.emwc-calendar-footer {
		padding: 14px 16px;
	}

	.emwc-calendar-today-btn {
		padding: 10px 20px;
		font-size: 0.8125em;
	}

	.emwc-popup-body {
		padding: 20px;
	}
}

/* ========================================
   Block Editor Specific Styles
   ======================================== */

/* Ensure consistent rendering in editor */
.editor-styles-wrapper .emwc-calendar,
.block-editor-block-list__block .emwc-calendar {
	margin: 0;
}

.editor-styles-wrapper .emwc-calendar-table td,
.block-editor-block-list__block .emwc-calendar-table td {
	height: 110px;
}

/* Fix dashicons in editor */
.editor-styles-wrapper .emwc-calendar .dashicons,
.block-editor-block-list__block .emwc-calendar .dashicons {
	font-family: dashicons;
}

/* Ensure weekend colors work in editor */
.editor-styles-wrapper .emwc-calendar-weekend,
.block-editor-block-list__block .emwc-calendar-weekend {
	background: #fafafa;
}

.editor-styles-wrapper .emwc-calendar-today,
.block-editor-block-list__block .emwc-calendar-today {
	background: #eff6ff !important;
}
