/* General Wrapper Constraints */
.smsidea-wrap {
	max-width: 100%;
	overflow-x: hidden;
}

.smsidea-wrap * {
	box-sizing: border-box;
}

/* Card Styling */
.smsidea-wrap .smsidea-card {
	background: #fff;
	padding: 16px 20px;
	border: 1px solid #ddd;
	border-radius: 6px;
	margin-top: 16px;
	max-width: 100%;
}

/* Info Notice Responsive */
.smsidea-info-notice {
	margin: 20px;
	padding: 18px 20px;
	max-width: calc(100% - 40px);
	border-left: 4px solid #2271b1;
	border-radius: 4px;
}

.smsidea-info-notice p {
	overflow-wrap: break-word;
	word-wrap: break-word;
	margin-bottom: 12px;
}

.smsidea-info-notice p:last-child {
	margin-bottom: 0;
}

.notice p {
	margin-bottom: 12px;
}

.notice .button-group {
	margin-top: 12px;
}

/* Responsive Form Table */
.smsidea-wrap .form-table th {
	width: 200px;
	max-width: 200px;
	padding: 15px 10px 15px 0;
	word-wrap: break-word;
	font-weight: 600;
}

.smsidea-wrap .form-table td {
	padding: 15px 10px;
}

.smsidea-wrap .form-table input.regular-text:focus,
.smsidea-wrap .form-table textarea:focus {
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
	outline: 2px solid transparent;
}

.smsidea-wrap .form-table input.regular-text,
.smsidea-wrap .form-table textarea {
	max-width: 100%;
	box-sizing: border-box;
}

/* Setup Tab Content */
.setup-tab-content {
	background-color: white;
	padding: 25px 30px;
	margin: 20px;
	box-sizing: border-box;
	border: 1px solid #e5e5e5;
	border-radius: 8px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.setup-tab-content form {
	overflow: visible;
	margin-bottom: 25px;
}

.setup-tab-content form:last-of-type {
	margin-bottom: 0;
}

.setup-tab-content .button-group {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
	margin-top: 15px;
	overflow: visible;
}

.setup-tab-content .button-group form,
.smsidea-inline-form {
	overflow: visible;
	display: inline-flex;
	margin: 0;
	padding: 0;
	align-items: center;
}

.setup-tab-content .button-group .button,
.setup-tab-content .button-group button {
	overflow: visible;
	box-sizing: border-box;
	position: relative;
	margin: 0;
	border: 1px solid;
}

.setup-tab-content .button-group .button-primary {
	border-color: #2271b1;
	background: #2271b1;
	color: #fff;
}

.setup-tab-content .button-group .button-secondary {
	display: inline-block;
	border-color: #2271b1;
	background: #fff;
	color: #2271b1;
}

.setup-tab-content .button-group .button-primary:hover {
	background: #135e96;
	border-color: #135e96;
}

.setup-tab-content .button-group .button-secondary:hover {
	background: #f0f6fc;
	border-color: #2271b1;
}

.setup-tab-content .description {
	word-wrap: break-word;
	overflow-wrap: break-word;
	max-width: 100%;
	color: #646970;
	font-style: italic;
	margin-top: 8px;
}

.setup-tab-content .required {
	color: #d63638;
	font-weight: 600;
}

.main-setup {
	display: block;
	max-width: 100%;
	overflow-x: hidden;
}

.card {
	min-width: 100% !important;
	max-width: 100% !important;
	box-sizing: border-box;
}

/* Responsive Grid Layout for Setup Sections */
.smsidea-setup-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0;
	max-width: 100%;
}

.smsidea-setup-grid > * {
	min-width: 0;
	overflow-wrap: break-word;
}

/* Notifications Table Responsive */
.notification-tabs {
	overflow-x: auto;
	margin: 20px 0;
	max-width: 100%;
}

.notification-tabs table.widefat {
	min-width: 100%;
	table-layout: auto;
	max-width: 100%;
}

.notification-tabs table.widefat th,
.notification-tabs table.widefat td {
	padding: 12px;
	word-wrap: break-word;
}

.notification-tabs table.widefat textarea {
	width: 100%;
	min-width: 200px;
	max-width: 100%;
	box-sizing: border-box;
	resize: vertical;
}

/* Documentation Grid Responsive */
.smsidea-documentation {
	display: grid;
	grid-template-columns: 1fr;
	gap: 20px;
	max-width: 100%;
}

.smsidea-documentation > * {
	min-width: 0;
}

.smsidea-documentation .smsidea-card {
	word-wrap: break-word;
	overflow-wrap: break-word;
}

.smsidea-documentation code,
.smsidea-documentation a {
	word-wrap: break-word;
	overflow-wrap: break-word;
	display: inline-block;
	max-width: 100%;
}

.smsidea-documentation ol,
.smsidea-documentation ul {
	padding-left: 20px;
}

.smsidea-documentation li {
	margin-bottom: 8px;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* Medium screens and up (tablets) */
@media (min-width: 768px) {
	.smsidea-setup-grid {
		grid-template-columns: 1fr 1fr;
		gap: 20px;
	}
	
	.smsidea-setup-grid .setup-tab-content {
		margin: 20px 0;
	}
}

/* Medium-Large screens (tablets landscape and up) */
@media (min-width: 900px) {
	.notification-tabs table.widefat tbody td:before {
		display: none;
	}
}

/* Large screens (desktops) */
@media (min-width: 1024px) {
	.smsidea-documentation {
		grid-template-columns: 1fr 1fr;
	}
	
	.smsidea-wrap .form-table th {
		width: 220px;
		max-width: 220px;
	}
}

/* Tablet and smaller - stack form tables vertically */
@media (max-width: 782px) {
	.smsidea-wrap .form-table th,
	.smsidea-wrap .form-table td {
		display: block;
		width: 100% !important;
		max-width: 100% !important;
		padding: 10px 0;
	}
	
	.smsidea-wrap .form-table th {
		padding-bottom: 5px;
	}
	
	.smsidea-wrap .form-table td {
		padding-top: 0;
	}
	
.setup-tab-content {
	margin: 10px;
	padding: 20px;
}
	
	/* Stack notification table cells */
	.notification-tabs table.widefat thead {
		display: none;
	}
	
	.notification-tabs table.widefat tbody tr {
		display: block;
		margin-bottom: 20px;
		border: 1px solid #ddd;
		padding: 10px;
	}
	
	.notification-tabs table.widefat tbody td {
		display: block;
		width: 100%;
		text-align: left;
		padding: 8px 0;
		border: none;
	}
	
	.notification-tabs table.widefat tbody td:before {
		content: attr(data-label);
		font-weight: bold;
		display: block;
		margin-bottom: 5px;
	}
}

/* Small screens and high zoom */
@media (max-width: 600px) {
	.setup-tab-content {
		margin: 5px;
		padding: 15px;
	}
	
	.smsidea-wrap .form-table input.regular-text {
		width: 100%;
	}
	
	.notice,
	.smsidea-info-notice {
		margin: 10px 5px !important;
		padding: 10px !important;
	}
	
	.smsidea-info-notice p {
		font-size: 13px !important;
	}
	
	.smsidea-info-notice p span {
		font-size: 16px !important;
	}
}

/* Handle high zoom levels */
@media (max-width: 480px) {
	.smsidea-wrap h1 {
		font-size: 1.5em;
		word-wrap: break-word;
		overflow-wrap: break-word;
	}
	
	.smsidea-wrap h2 {
		font-size: 1.3em;
	}
	
.setup-tab-content h2 {
	font-size: 1.35em;
	color: #23282d;
	margin-top: 0;
	margin-bottom: 20px;
	padding-bottom: 12px;
	border-bottom: 2px solid #f0f0f1;
	font-weight: 600;
}

.setup-tab-content h3 {
	font-size: 1.15em;
	color: #23282d;
	margin-top: 25px;
	margin-bottom: 15px;
	font-weight: 600;
}
	
	.smsidea-wrap .nav-tab-wrapper {
		margin-bottom: 10px;
	}
	
	.smsidea-wrap .nav-tab-wrapper .nav-tab {
		margin-bottom: 5px;
		display: inline-block;
		font-size: 12px;
		padding: 6px 10px;
	}
	
	.wp-core-ui .button,
	.wp-core-ui .button-primary,
	.wp-core-ui .button-secondary {
		padding: 8px 12px;
		font-size: 13px;
		white-space: normal;
		height: auto;
	}
	
	.smsidea-documentation ol,
	.smsidea-documentation ul {
		padding-left: 15px;
		margin-left: 5px;
	}
	
	.smsidea-documentation .smsidea-card {
		padding: 12px 15px;
	}
}

/* Status Panel Styles */
.smsidea-status-panel {
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 6px;
	padding: 20px;
	margin: 25px 0;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.smsidea-status-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 15px;
}

.smsidea-status-item {
	display: flex;
	flex-direction: column;
	gap: 5px;
}

.smsidea-status-item strong {
	font-weight: 600;
	color: #23282d;
}

.smsidea-status-item span {
	color: #555;
}

.smsidea-masked-key {
	font-family: monospace;
	background: #fff;
	padding: 4px 8px;
	border-radius: 3px;
	border: 1px solid #ddd;
	display: inline-block;
}

/* Status Table Styles */
.smsidea-status-section {
	margin-top: 30px;
}

#smsidea-instances-table {
	margin-top: 25px;
	border-radius: 4px;
	overflow: hidden;
}

#smsidea-instances-table th {
	background-color: #f6f7f7;
	font-weight: 600;
	padding: 12px 15px;
	border-bottom: 2px solid #e5e5e5;
}

#smsidea-instances-table td {
	vertical-align: middle;
	padding: 12px 15px;
}

#smsidea-instances-table tbody tr:hover {
	background-color: #f9f9f9;
}

.smsidea-instance-name {
	font-weight: 500;
}

.smsidea-connectivity-status {
	display: inline-block;
	padding: 4px 8px;
	border-radius: 3px;
	font-size: 12px;
	font-weight: 500;
}

/* Ensure button borders are fully visible */
#smsidea-create-instance-btn,
#smsidea-refresh-status-btn {
	border-width: 1px !important;
	border-style: solid !important;
}
.smsidea-status-connected,
.smsidea-status-active {
	background-color: #d4edda;
	color: #155724;
}

.smsidea-status-disconnected,
.smsidea-status-inactive {
	background-color: #f8d7da;
	color: #721c24;
}

.smsidea-empty-state {
	text-align: center;
	padding: 40px 20px;
	color: #666;
	font-style: italic;
}

/* Refresh Button Loading State */
#smsidea-refresh-status-btn.smsidea-loading {
	position: relative;
	color: transparent;
}

#smsidea-refresh-status-btn.smsidea-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 16px;
	height: 16px;
	margin: -8px 0 0 -8px;
	border: 2px solid #fff;
	border-top-color: transparent;
	border-radius: 50%;
	animation: smsidea-spin 0.6s linear infinite;
}

@keyframes smsidea-spin {
	to {
		transform: rotate(360deg);
	}
}

/* ARIA Live Region */
.screen-reader-text {
	position: absolute;
	left: -9999px;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* AJAX Notices */
.smsidea-ajax-notice {
	margin: 15px 0;
	animation: smsidea-fade-in 0.3s ease-in;
}

@keyframes smsidea-fade-in {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Reconnect Button */
.smsidea-reconnect-btn {
	min-width: 100px;
}

/* Responsive Status Panel */
@media (max-width: 782px) {
	.smsidea-status-grid {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.smsidea-status-panel {
		padding: 15px;
	}

	#smsidea-instances-table {
		overflow-x: auto;
		display: block;
		width: 100%;
	}

	#smsidea-instances-table thead,
	#smsidea-instances-table tbody,
	#smsidea-instances-table tr,
	#smsidea-instances-table td,
	#smsidea-instances-table th {
		display: block;
	}

	#smsidea-instances-table thead {
		display: none;
	}

	#smsidea-instances-table tbody tr {
		border: 1px solid #ddd;
		margin-bottom: 15px;
		padding: 10px;
		border-radius: 4px;
	}

	#smsidea-instances-table tbody td {
		border: none;
		padding: 8px 0;
		text-align: left;
	}

	#smsidea-instances-table tbody td:before {
		content: attr(data-label);
		font-weight: 600;
		display: inline-block;
		width: 120px;
		margin-right: 10px;
	}

	#smsidea-instances-table tbody td:last-child {
		border-top: 1px solid #eee;
		padding-top: 12px;
		margin-top: 8px;
	}
}

/* QR Code Modal */
.smsidea-modal {
	position: fixed;
	z-index: 100000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	overflow: auto;
	background-color: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
}

.smsidea-modal-content {
	background-color: #fff;
	margin: auto;
	padding: 0;
	border: 1px solid #888;
	border-radius: 4px;
	width: 90%;
	max-width: 500px;
	box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
	position: relative;
}

.smsidea-modal-header {
	padding: 15px 20px;
	border-bottom: 1px solid #ddd;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.smsidea-modal-header h2 {
	margin: 0;
	font-size: 18px;
}

.smsidea-modal-close {
	background: none;
	border: none;
	font-size: 28px;
	font-weight: bold;
	color: #aaa;
	cursor: pointer;
	padding: 0;
	width: 30px;
	height: 30px;
	line-height: 1;
	text-align: center;
}

.smsidea-modal-close:hover,
.smsidea-modal-close:focus {
	color: #000;
	text-decoration: none;
}

.smsidea-modal-body {
	padding: 20px;
	text-align: center;
}

#smsidea-qr-code-container {
	min-height: 200px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.smsidea-qr-loading,
.smsidea-qr-error {
	color: #666;
	font-style: italic;
}

.smsidea-qr-error {
	color: #d63638;
}

.smsidea-qr-instructions {
	margin-top: 20px;
	padding-top: 20px;
	border-top: 1px solid #eee;
	color: #555;
	font-size: 14px;
	line-height: 1.6;
	text-align: left;
}

/* Active Instance Checkbox */
.smsidea-active-checkbox-label {
	display: inline-flex;
	align-items: center;
	cursor: pointer;
}

.smsidea-active-instance-checkbox {
	margin: 0;
	cursor: pointer;
}

.smsidea-active-instance-checkbox:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Media Upload Styles */
.smsidea-media-upload-section {
	background: #f9f9f9;
	border-radius: 4px;
	padding: 15px;
}

.smsidea-media-upload-section h4 {
	margin-top: 0;
	margin-bottom: 10px;
	font-size: 14px;
	font-weight: 600;
	color: #23282d;
}

.smsidea-media-upload-controls {
	display: flex;
	gap: 10px;
	margin-bottom: 10px;
}

.smsidea-upload-media-btn,
.smsidea-remove-media-btn {
	margin: 0;
}

.smsidea-media-preview {
	margin-top: 10px;
}

.smsidea-media-preview-content {
	display: inline-block;
}

.smsidea-media-preview img,
.smsidea-media-preview video {
	max-width: 200px;
	max-height: 150px;
	border: 1px solid #ddd;
	padding: 5px;
	background: #fff;
	border-radius: 3px;
}

.smsidea-send-media-checkbox:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Responsive Media Upload */
@media (max-width: 782px) {
	.smsidea-media-upload-section {
		margin-top: 15px;
		padding: 12px;
	}

	.smsidea-media-preview img,
	.smsidea-media-preview video {
		max-width: 100%;
		height: auto;
	}
}

/* Inline Message Styles */
.smsidea-inline-message {
	margin-top: 15px;
	margin-bottom: 0;
	padding: 12px 15px;
	border-left: 4px solid;
	border-radius: 4px;
	display: none;
}

.smsidea-inline-message.notice-success {
	background-color: #d4edda;
	border-left-color: #46b450;
	color: #155724;
}

.smsidea-inline-message.notice-error {
	background-color: #f8d7da;
	border-left-color: #dc3232;
	color: #721c24;
}

.smsidea-inline-message.notice-warning {
	background-color: #fff3cd;
	border-left-color: #ffb900;
	color: #856404;
}

.smsidea-inline-message p {
	margin: 0;
	padding: 0;
}