/* =============================================================================
   Shared Schedule Page (Public)
   ============================================================================= */
.shared-schedule-page {
	min-height: 100vh;
	background: var(--bg-gradient);
	padding: 2rem;
}

.shared-schedule-container {
	max-width: 800px;
	margin: 0 auto;
}

.shared-schedule-loading,
.shared-schedule-error {
	text-align: center;
	padding: 4rem 2rem;
}

.shared-schedule-loading h1,
.shared-schedule-error h1 {
	font-size: 2rem;
	margin-bottom: 1rem;
}

.shared-schedule-error .error-message {
	color: var(--danger);
	font-size: 1.125rem;
}

/* Expired link styling */
.shared-schedule-error.expired {
	max-width: 500px;
	margin: 0 auto;
}

.shared-schedule-error .expired-icon {
	font-size: 4rem;
	margin-bottom: 1rem;
}

.shared-overview-section-header h2 {
	margin: 0;
	font-size: 1.1rem;
	font-weight: 700;
}

.shared-schedule-error.expired h2 {
	font-size: 1.5rem;
	color: var(--warning);
	margin-bottom: 1.5rem;
}

.shared-schedule-error .expired-message {
	font-size: 1.125rem;
	color: var(--text-primary);
	margin-bottom: 1rem;
	line-height: 1.5;
}

.shared-schedule-error .expired-contact {
	font-size: 1rem;
	color: var(--text-secondary);
	margin-bottom: 1.5rem;
	padding: 1rem;
	background: var(--bg-tertiary);
	border-radius: 8px;
	border: 1px solid var(--border-primary);
}

.shared-schedule-error .expired-date {
	font-size: 0.875rem;
	color: var(--text-muted);
}

.shared-schedule-header {
	text-align: center;
	margin-bottom: 2rem;
	padding-bottom: 1.5rem;
	border-bottom: 1px solid var(--border-primary);
	position: relative;
}

.shared-schedule-header-actions {
	position: absolute;
	top: 0;
	right: 0;
	display: flex;
	gap: 0.5rem;
}

.shared-schedule-header h1 {
	font-size: 1.75rem;
	margin-bottom: 0.5rem;
}

.shared-schedule-period {
	color: var(--text-secondary);
	font-size: 1rem;
}

.shared-schedule-section {
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
}

.shared-timeline {
	background: var(--bg-secondary);
	border-radius: 12px;
	padding: 1.5rem;
	border: 1px solid var(--border-primary);
}

.shared-schedule-empty {
	text-align: center;
	padding: 2rem;
	color: var(--text-secondary);
}

.shared-dose {
	background: transparent;
	border: none;
	padding: 0.5rem 0;
}

.med-name-stack {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	min-width: 0;
	gap: 0.1rem;
}

.med-generic-inline {
	font-size: 0.875rem;
	color: var(--text-secondary);
	margin-left: 0;
}

.shared-schedule-footer {
	text-align: center;
	margin-top: 2rem;
	padding-top: 1.5rem;
	border-top: 1px solid var(--border-primary);
	color: var(--text-secondary);
	font-size: 0.875rem;
}

/* =============================================================================
   Shared Overview Page (Public)
   ============================================================================= */
.shared-overview-container {
	max-width: 1080px;
}

.shared-overview-inline-section {
	display: flex;
	flex-direction: column;
	gap: 0.9rem;
	margin-bottom: 1.5rem;
}

.shared-overview-section-header {
	display: flex;
	flex-direction: column;
	gap: 0.2rem;
}

.shared-overview-table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border-primary);
	border-radius: 12px;
	background: var(--bg-secondary);
}

.shared-overview-table {
	width: 100%;
	border-collapse: collapse;
	min-width: 600px;
}

.shared-overview-table th,
.shared-overview-table td {
	padding: 0.85rem 0.75rem;
	border-bottom: 1px solid var(--border-primary);
	text-align: left;
	vertical-align: middle;
}

.shared-overview-table th {
	color: var(--text-secondary);
	font-size: 0.85rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.02em;
	background: var(--bg-tertiary);
}

.shared-overview-table tr:last-child td {
	border-bottom: none;
}

.shared-overview-medication-cell {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	min-width: 220px;
}

.shared-overview-medication-text {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.15rem;
	min-width: 0;
}

.shared-overview-med-name {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 0.15rem;
	min-width: 0;
}

.shared-overview-medication-text strong {
	font-size: 0.95rem;
	word-break: break-word;
}

.shared-overview-medication-text .shared-overview-med-generic {
	font-size: 0.8rem;
	color: var(--text-secondary);
	word-break: break-word;
}

.shared-overview-stock-value,
.shared-overview-date-value {
	white-space: nowrap;
}

.shared-overview-priority {
	display: inline-flex;
	align-items: center;
	align-self: flex-start;
	padding: 0.2rem 0.5rem;
	border-radius: 999px;
	font-size: 0.8rem;
	font-weight: 600;
	border: 1px solid transparent;
	width: fit-content;
	max-width: 100%;
}

.shared-overview-priority.normal {
	color: var(--success);
	background: var(--success-bg);
	border-color: rgba(16, 185, 129, 0.25);
}

.shared-overview-priority.high {
	color: var(--danger);
	background: var(--danger-bg);
	border-color: rgba(239, 68, 68, 0.25);
}

.shared-overview-priority.warning {
	color: var(--warning);
	background: color-mix(in srgb, var(--warning) 12%, transparent);
	border-color: color-mix(in srgb, var(--warning) 30%, transparent);
}

.shared-overview-priority.danger {
	color: var(--danger);
	background: var(--danger-bg);
	border-color: rgba(239, 68, 68, 0.25);
}

.shared-overview-cards {
	display: none;
	gap: 0.75rem;
}

.shared-overview-card {
	background: var(--bg-secondary);
	border: 1px solid var(--border-primary);
	border-radius: 12px;
	padding: 0.9rem;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.shared-overview-card-title {
	display: flex;
	align-items: center;
	gap: 0.6rem;
}

.shared-overview-card-title p {
	margin: 0.1rem 0 0;
	font-size: 0.8rem;
	color: var(--text-secondary);
}

.shared-overview-card-grid {
	display: grid;
	grid-template-columns: minmax(120px, 1fr) minmax(0, 1fr);
	gap: 0.35rem 0.75rem;
}

.shared-overview-card-grid span {
	color: var(--text-secondary);
	font-size: 0.82rem;
}

.shared-overview-card-grid strong {
	font-size: 0.88rem;
	font-weight: 600;
	word-break: break-word;
}

@media (max-width: 600px) {
	.shared-schedule-page {
		padding: 1rem;
	}

	.shared-schedule-header h1 {
		font-size: 1.25rem;
	}

	.shared-timeline {
		padding: 1rem;
	}

	.shared-overview-table-wrap {
		display: none;
	}

	.shared-overview-cards {
		display: grid;
	}
}

/* ── Desktop Edit Panel (two-column layout) ── */
.edit-sidebar {
	display: none;
	padding: 0;
}

@media (min-width: 769px) {
	.med-grid-wrapper.desktop-edit-open {
		display: grid;
		grid-template-columns: minmax(0, 1fr) minmax(380px, 46%);
		gap: 1rem;
		align-items: start;
	}

	.med-grid-wrapper.desktop-edit-open .med-grid,
	.med-grid-wrapper.desktop-edit-open .med-grid-obsolete {
		grid-template-columns: 1fr;
	}

	.edit-sidebar.open {
		display: block;
	}
}

.edit-sidebar .card {
	box-shadow: none;
	border: none;
	background: transparent;
	padding: 0;
	padding-top: 1.25rem;
}

/* Desktop only - hide on mobile */
@media (max-width: 768px) {
	.desktop-only {
		display: none !important;
	}
}

/* Mobile Edit Modal */
.mobile-edit-overlay {
	align-items: flex-start;
	padding-top: 0.35rem;
	padding-bottom: 0.35rem;
}

.edit-modal {
	max-width: 95vw;
	max-height: none;
	height: min(96dvh, 96vh);
	padding: 0.6rem;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	overflow-x: hidden;
}

.edit-modal-header {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.edit-modal-header h2 {
	font-size: 1.25rem;
	margin: 0;
	text-align: left;
	min-width: 0;
}

.mobile-edit-form.form-grid {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	overflow-x: hidden;
}

.mobile-edit-form .modal-footer {
	border-top: none;
	padding: 0.45rem 0.15rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
	gap: 0.6rem;
	margin-top: 0;
}

.mobile-edit-form .readonly-fieldset {
	display: flex;
	flex-direction: column;
	border: 0;
	margin: 0;
	padding: 0;
	min-inline-size: 0;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	overscroll-behavior: contain;
}

.mobile-edit-form .readonly-fieldset.swiping-horizontal {
	overflow-y: hidden;
}

.mobile-edit-form .mobile-tab-viewport {
	flex: 1;
	min-height: 0;
	overflow: hidden;
}

.mobile-edit-form .mobile-tab-track {
	display: flex;
	height: 100%;
	will-change: transform;
}

.mobile-edit-form .mobile-tab-track:not(.is-swiping) {
	transition: transform 220ms ease;
}

.mobile-edit-form .mobile-tab-track > .form-tab-panel {
	display: block;
	flex: 0 0 100%;
	min-width: 100%;
	height: 100%;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	padding-right: 0.1rem;
	overscroll-behavior: contain;
}

.mobile-edit-form .form-tabs {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: none;
}

.mobile-edit-form .form-tabs::-webkit-scrollbar {
	display: none;
}

.mobile-edit-form .form-tab {
	flex: 0 0 auto;
	min-width: max-content;
	overflow: visible;
	text-overflow: clip;
}

.mobile-edit-form .form-tab-panel.active {
	display: block;
}

.mobile-edit-form.form-grid > label {
	font-size: 0.8rem;
	min-width: 0 !important;
	width: 100%;
}

.mobile-edit-form .form-category {
	grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	gap: 0.75rem 0.75rem;
	padding: 0.5rem;
	border-color: color-mix(in srgb, var(--border-primary) 50%, transparent);
}

.mobile-edit-form .refill-prescription-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: 0.6rem;
	align-items: start;
	width: 100%;
}

.mobile-edit-form .refill-prescription-row .refill-prescription-toggle {
	grid-template-columns: 18px minmax(0, 1fr);
	line-height: 1.3;
	max-width: 100%;
}

.mobile-edit-form .refill-remaining-badge {
	margin-left: 0;
	justify-self: start;
}

.mobile-edit-form.form-grid input,
.mobile-edit-form.form-grid textarea,
.mobile-edit-form.form-grid select {
	font-size: 16px !important;
	width: 100%;
}

.mobile-edit-form .blister-row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.5rem;
	padding: 0.75rem;
	background: var(--bg-secondary);
	border-radius: 8px;
	margin-bottom: 0.5rem;
	align-items: end;
}

.mobile-edit-form .blister-row label.compact {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.mobile-edit-form .blister-row label.compact span {
	font-size: 0.75rem;
	color: var(--text-secondary);
	font-weight: 500;
}

.mobile-edit-form .blister-row label.compact.full-row {
	grid-column: 1 / -1;
}

.blister-inputs .remind-toggle-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	align-self: end;
	padding-bottom: 0.5rem;
}

.mobile-edit-form .blister-row .remind-toggle-row {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	grid-column: 1 / 2;
}

.mobile-edit-form .blister-row .datetime-inputs {
	display: flex;
	gap: 0.5rem;
}

.mobile-edit-form .blister-row .datetime-inputs input[type="date"] {
	flex: 2;
	min-width: 0;
}

.mobile-edit-form .blister-row .datetime-inputs input[type="time"] {
	flex: 1;
	min-width: 0;
}

.mobile-edit-form .blister-row label.compact.time-label {
	width: fit-content;
}

.mobile-edit-form .blister-row label.compact.time-label input[type="time"] {
	width: auto;
}

/* Remove blister button */
.remove-blister-btn {
	padding: 0.4rem !important;
	font-size: 1rem;
	line-height: 1;
	border-radius: 6px !important;
	min-width: 2.5rem;
	min-height: 2.5rem;
	align-self: center;
	opacity: 0.7;
}

.remove-blister-btn:hover {
	opacity: 1;
}

.mobile-edit-form .blister-row .remove-blister-btn {
	grid-column: 2 / 3;
	justify-self: end;
}

.mobile-edit-form .add-blister {
	margin-top: 0.5rem;
	width: auto;
}

/* Action Cards (for Export/Import etc.) - similar to radio-card */
.action-card {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1rem 1.25rem;
	background: var(--bg-tertiary);
	border: 1px solid var(--border-secondary);
	border-radius: 12px;
	transition: all 0.2s ease;
}

.action-card:hover {
	border-color: var(--border-primary);
}

.action-card-content {
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
	flex: 1;
	min-width: 0;
}

.action-card-title {
	font-weight: 600;
	color: var(--text-primary);
	font-size: 0.95rem;
}

.action-card-desc {
	color: var(--text-secondary);
	font-size: 0.85rem;
	line-height: 1.4;
}

.action-card button,
.action-card .btn {
	flex-shrink: 0;
}

/* ==========================================
   Custom DateInput / DateTimeInput
   ========================================== */
.date-input-wrapper {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
	cursor: pointer;
}

.date-input-display {
	position: absolute;
	left: 0.85rem;
	right: 2.5rem;
	pointer-events: none;
	color: var(--text-primary);
	font-size: 0.95rem;
	font-family: inherit;
	text-transform: none;
	letter-spacing: normal;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	z-index: 1;
}

.mobile-edit-form .date-input-display {
	font-size: 16px !important;
}

.date-input-native {
	color: transparent !important;
	caret-color: transparent !important;
	width: 100%;
	cursor: pointer;
}

/* Ensure native text stays invisible on focus/selection */
.date-input-native:focus,
.date-input-native:active {
	color: transparent !important;
	caret-color: transparent !important;
}

.date-input-native::selection {
	background: transparent;
	color: transparent;
}

.date-input-native::-webkit-datetime-edit {
	color: transparent;
}

/* Keep the calendar/clock picker icon visible and clickable */
.date-input-native::-webkit-calendar-picker-indicator {
	opacity: 0.6;
	cursor: pointer;
	filter: invert(0.8);
	z-index: 2;
}

.date-input-native::-webkit-calendar-picker-indicator:hover {
	opacity: 1;
}

/* Light theme: don't invert icon */
@media (prefers-color-scheme: light) {
	.date-input-native::-webkit-calendar-picker-indicator {
		filter: none;
		opacity: 0.7;
	}
}

@media (max-width: 480px) {
	.action-card {
		flex-direction: column;
		align-items: flex-start;
		gap: 0.75rem;
	}

	.action-card button,
	.action-card .btn {
		width: 100%;
		text-align: center;
		justify-content: center;
	}
}
