/**
 * Page Speed Auditor Frontend Styles
 */

/* Container */
.psa-container {
	max-width: 700px;
	margin: 0 auto;
	padding: 20px;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Card */
.psa-card {
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
	padding: 32px;
}

/* Title */
.psa-title {
	margin: 0 0 8px 0;
	font-size: 28px;
	font-weight: 700;
	color: #1a1a2e;
}

/* Description */
.psa-description {
	color: #6b7280;
	font-size: 15px;
	line-height: 1.6;
	margin: 0 0 24px 0;
}

/* Form */
.psa-form {
	margin-top: 24px;
}

.psa-form-group {
	margin-bottom: 20px;
}

.psa-label {
	display: block;
	font-weight: 600;
	font-size: 14px;
	color: #374151;
	margin-bottom: 8px;
}

.psa-input {
	width: 100%;
	padding: 12px 16px;
	font-size: 15px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	transition: border-color 0.2s, box-shadow 0.2s;
	box-sizing: border-box;
}

.psa-input:focus {
	outline: none;
	border-color: #3b82f6;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.psa-input:disabled {
	background-color: #f3f4f6;
	cursor: not-allowed;
}

.psa-input-number {
	max-width: 150px;
}

.psa-help-text {
	font-size: 13px;
	color: #9ca3af;
	margin: 6px 0 0 0;
}

/* Buttons */
.psa-form-actions {
	margin-top: 28px;
}

.psa-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 14px 28px;
	font-size: 15px;
	font-weight: 600;
	border-radius: 8px;
	border: none;
	cursor: pointer;
	transition: all 0.2s;
}

.psa-button-primary {
	background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
	color: #ffffff;
}

.psa-button-primary:hover:not(:disabled) {
	background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.psa-button-primary:disabled {
	background: #9ca3af;
	cursor: not-allowed;
}

.psa-button-secondary {
	background: #f3f4f6;
	color: #374151;
	border: 2px solid #e5e7eb;
}

.psa-button-secondary:hover {
	background: #e5e7eb;
}

.psa-button-loading {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* Spinner */
.psa-spinner {
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 50%;
	border-top-color: #ffffff;
	animation: psa-spin 0.8s linear infinite;
}

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

/* Notice */
.psa-notice {
	padding: 16px 20px;
	border-radius: 8px;
	margin-bottom: 20px;
}

.psa-notice-warning {
	background: #fef3c7;
	border: 1px solid #f59e0b;
	color: #92400e;
}

.psa-notice-error {
	background: #fee2e2;
	border: 1px solid #ef4444;
	color: #991b1b;
}

.psa-notice p {
	margin: 0;
}

/* Progress Section */
.psa-progress {
	margin-top: 32px;
	padding-top: 32px;
	border-top: 1px solid #e5e7eb;
}

.psa-progress-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}

.psa-progress-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: #1a1a2e;
}

.psa-progress-percentage {
	font-size: 24px;
	font-weight: 700;
	color: #3b82f6;
}

/* Progress Bar */
.psa-progress-bar-container {
	margin-bottom: 28px;
}

.psa-progress-bar {
	height: 12px;
	background: #e5e7eb;
	border-radius: 6px;
	overflow: hidden;
}

.psa-progress-fill {
	height: 100%;
	background: linear-gradient(90deg, #3b82f6 0%, #8b5cf6 100%);
	border-radius: 6px;
	transition: width 0.4s ease;
	width: 0%;
}

/* Progress Steps */
.psa-progress-steps {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.psa-step {
	display: flex;
	align-items: flex-start;
	gap: 16px;
	padding: 16px;
	background: #f9fafb;
	border-radius: 8px;
	transition: all 0.3s;
}

.psa-step.active {
	background: #eff6ff;
	border: 1px solid #bfdbfe;
}

.psa-step.completed {
	background: #f0fdf4;
	border: 1px solid #86efac;
}

.psa-step-icon {
	width: 32px;
	height: 32px;
	border-radius: 50%;
	background: #e5e7eb;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-weight: 600;
	font-size: 14px;
	color: #6b7280;
}

.psa-step.active .psa-step-icon {
	background: #3b82f6;
	color: #ffffff;
	animation: psa-pulse 2s infinite;
}

.psa-step.completed .psa-step-icon {
	background: #22c55e;
	color: #ffffff;
}

@keyframes psa-pulse {
	0%, 100% {
		box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
	}
	50% {
		box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
	}
}

.psa-step-content {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.psa-step-title {
	font-weight: 600;
	font-size: 15px;
	color: #1a1a2e;
}

.psa-step-status {
	font-size: 13px;
	color: #6b7280;
}

.psa-step.active .psa-step-status {
	color: #3b82f6;
}

.psa-step.completed .psa-step-status {
	color: #22c55e;
}

.psa-step-check {
	font-size: 16px;
}

/* Activity Log */
.psa-progress-log {
	margin-top: 24px;
	background: #f9fafb;
	border-radius: 8px;
	overflow: hidden;
}

.psa-log-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 12px 16px;
	background: #f3f4f6;
	font-weight: 600;
	font-size: 13px;
	color: #374151;
	cursor: pointer;
}

.psa-log-toggle {
	background: none;
	border: none;
	color: #3b82f6;
	font-size: 13px;
	cursor: pointer;
	font-weight: 500;
}

.psa-log-toggle:hover {
	text-decoration: underline;
}

.psa-log-content {
	max-height: 200px;
	overflow-y: auto;
	padding: 12px 16px;
}

.psa-log-list {
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 13px;
	font-family: monospace;
}

.psa-log-list li {
	padding: 6px 0;
	border-bottom: 1px solid #e5e7eb;
	display: flex;
	gap: 10px;
}

.psa-log-list li:last-child {
	border-bottom: none;
}

.psa-log-time {
	color: #9ca3af;
	flex-shrink: 0;
}

.psa-log-message {
	color: #374151;
}

.psa-log-message.success {
	color: #22c55e;
}

.psa-log-message.error {
	color: #ef4444;
}

/* Results Section */
.psa-results {
	margin-top: 32px;
	padding: 32px;
	background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
	border-radius: 12px;
	text-align: center;
	border: 1px solid #86efac;
}

.psa-results-icon {
	width: 64px;
	height: 64px;
	background: #22c55e;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 16px;
	font-size: 32px;
	color: #ffffff;
}

.psa-results-title {
	margin: 0 0 8px 0;
	font-size: 24px;
	font-weight: 700;
	color: #166534;
}

.psa-results-summary {
	color: #15803d;
	font-size: 15px;
	margin: 0 0 24px 0;
}

.psa-results-actions {
	display: flex;
	gap: 12px;
	justify-content: center;
	flex-wrap: wrap;
}

.psa-download-icon {
	margin-right: 6px;
}

/* Error Section */
#psa-error {
	margin-top: 32px;
}

.psa-error-message {
	margin-bottom: 16px;
}

#psa-retry {
	margin-top: 8px;
}

/* Method Selector */
.psa-method-selector {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.psa-method-option {
	flex: 1;
	min-width: 200px;
	cursor: pointer;
}

.psa-method-option input[type="radio"] {
	display: none;
}

.psa-method-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 20px 16px;
	background: #f9fafb;
	border: 2px solid #e5e7eb;
	border-radius: 12px;
	transition: all 0.2s;
	text-align: center;
}

.psa-method-option:hover .psa-method-card {
	border-color: #3b82f6;
	background: #eff6ff;
}

.psa-method-option input[type="radio"]:checked + .psa-method-card,
.psa-method-option.psa-method-selected .psa-method-card {
	border-color: #3b82f6;
	background: #eff6ff;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.psa-method-option.psa-method-disabled {
	cursor: not-allowed;
	opacity: 0.6;
}

.psa-method-option.psa-method-disabled .psa-method-card {
	background: #f3f4f6;
}

.psa-method-option.psa-method-disabled:hover .psa-method-card {
	border-color: #e5e7eb;
	background: #f3f4f6;
}

.psa-method-icon {
	font-size: 32px;
	margin-bottom: 8px;
}

.psa-method-name {
	font-weight: 600;
	font-size: 15px;
	color: #1a1a2e;
	margin-bottom: 4px;
}

.psa-method-desc {
	font-size: 12px;
	color: #6b7280;
}

.psa-method-option input[type="radio"]:checked + .psa-method-card .psa-method-name {
	color: #2563eb;
}

/* Score Mode Selector */
.psa-score-mode-group {
	margin-top: 16px;
	padding: 16px;
	background: #f0fdf4;
	border: 1px solid #86efac;
	border-radius: 8px;
}

.psa-score-mode-selector {
	display: flex;
	gap: 12px;
	flex-wrap: wrap;
}

.psa-score-mode-option {
	flex: 1;
	min-width: 200px;
	cursor: pointer;
}

.psa-score-mode-option input[type="radio"] {
	display: none;
}

.psa-score-mode-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 16px 12px;
	background: #ffffff;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	transition: all 0.2s;
	text-align: center;
}

.psa-score-mode-option:hover .psa-score-mode-card {
	border-color: #22c55e;
	background: #f0fdf4;
}

.psa-score-mode-option input[type="radio"]:checked + .psa-score-mode-card,
.psa-score-mode-option.psa-score-mode-selected .psa-score-mode-card {
	border-color: #22c55e;
	background: #f0fdf4;
	box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.psa-score-mode-icon {
	font-size: 24px;
	margin-bottom: 6px;
}

.psa-score-mode-name {
	font-weight: 600;
	font-size: 14px;
	color: #1a1a2e;
	margin-bottom: 4px;
}

.psa-score-mode-desc {
	font-size: 11px;
	color: #6b7280;
}

.psa-score-mode-option input[type="radio"]:checked + .psa-score-mode-card .psa-score-mode-name {
	color: #16a34a;
}

/* Page Management Section */
.psa-page-management {
	margin-top: 24px;
}

.psa-management-header {
	margin-bottom: 20px;
}

.psa-management-title {
	margin: 0 0 8px 0;
	font-size: 20px;
	font-weight: 600;
	color: #1a1a2e;
}

.psa-management-description {
	color: #6b7280;
	font-size: 14px;
	margin: 0;
}

.psa-add-page-section {
	margin-bottom: 16px;
}

.psa-add-page-input-group {
	display: flex;
	gap: 8px;
}

.psa-add-page-input {
	flex: 1;
}

.psa-add-page-btn {
	white-space: nowrap;
	background: #22c55e;
	color: #ffffff;
}

.psa-add-page-btn:hover {
	background: #16a34a;
}

.psa-pages-count {
	font-weight: 600;
	color: #374151;
	margin-bottom: 12px;
	padding: 8px 12px;
	background: #f3f4f6;
	border-radius: 6px;
	display: inline-block;
}

.psa-managed-page-list {
	max-height: 350px;
	overflow-y: auto;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	margin-bottom: 20px;
}

.psa-managed-page-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	border-bottom: 1px solid #e5e7eb;
	transition: background-color 0.2s;
}

.psa-managed-page-item:last-child {
	border-bottom: none;
}

.psa-managed-page-item:hover {
	background: #f9fafb;
}

.psa-managed-page-item.psa-custom-page {
	background: #fefce8;
}

.psa-managed-page-item.psa-custom-page:hover {
	background: #fef9c3;
}

.psa-managed-page-url {
	flex: 1;
	font-size: 14px;
	color: #1a1a2e;
	word-break: break-all;
	padding-right: 12px;
}

.psa-managed-page-badge {
	font-size: 10px;
	background: #fde047;
	color: #854d0e;
	padding: 2px 6px;
	border-radius: 4px;
	margin-left: 8px;
	text-transform: uppercase;
	font-weight: 600;
}

.psa-remove-page-btn {
	padding: 6px 12px;
	font-size: 12px;
	background: #fee2e2;
	color: #dc2626;
	border: 1px solid #fca5a5;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s;
}

.psa-remove-page-btn:hover {
	background: #fca5a5;
	color: #991b1b;
}

.psa-management-footer {
	display: flex;
	gap: 12px;
	justify-content: center;
	flex-wrap: wrap;
}

/* AI Options */
.psa-ai-options {
	background: #f0f9ff;
	border: 1px solid #bae6fd;
	border-radius: 8px;
	padding: 16px;
	margin-top: 20px;
}

.psa-checkbox-label {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	cursor: pointer;
	font-weight: 500;
}

.psa-checkbox-label input[type="checkbox"] {
	width: 18px;
	height: 18px;
	margin-top: 2px;
	cursor: pointer;
}

.psa-checkbox-text {
	color: #0369a1;
	font-size: 15px;
}

.psa-ai-options .psa-help-text {
	margin-left: 28px;
	margin-top: 8px;
}

.psa-keywords-group {
	background: #fefce8;
	border: 1px solid #fde047;
	border-radius: 8px;
	padding: 16px;
}

/* Page Selection Section */
.psa-page-selection {
	margin-top: 24px;
}

.psa-selection-header {
	margin-bottom: 20px;
}

.psa-selection-title {
	margin: 0 0 8px 0;
	font-size: 20px;
	font-weight: 600;
	color: #1a1a2e;
}

.psa-selection-description {
	color: #6b7280;
	font-size: 14px;
	margin: 0;
}

.psa-selection-controls {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
	padding: 12px 16px;
	background: #f3f4f6;
	border-radius: 8px;
}

.psa-selection-actions {
	display: flex;
	gap: 8px;
}

.psa-button-small {
	padding: 8px 16px;
	font-size: 13px;
}

.psa-selected-count {
	font-weight: 600;
	color: #374151;
}

/* Page List */
.psa-page-list {
	max-height: 400px;
	overflow-y: auto;
	border: 1px solid #e5e7eb;
	border-radius: 8px;
	margin-bottom: 20px;
}

.psa-page-item {
	border-bottom: 1px solid #e5e7eb;
	transition: background-color 0.2s;
}

.psa-page-item:last-child {
	border-bottom: none;
}

.psa-page-item:hover {
	background: #f9fafb;
}

.psa-page-item-content {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 16px;
	cursor: pointer;
}

.psa-page-item input[type="checkbox"] {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
	cursor: pointer;
}

.psa-page-info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.psa-page-url {
	font-size: 14px;
	font-weight: 500;
	color: #1a1a2e;
	word-break: break-all;
}

.psa-page-reasoning {
	font-size: 12px;
	color: #6b7280;
	line-height: 1.4;
}

.psa-page-score {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	flex-shrink: 0;
	min-width: 60px;
}

.psa-score-value {
	font-size: 20px;
	font-weight: 700;
}

.psa-score-label {
	font-size: 10px;
	text-transform: uppercase;
	font-weight: 600;
}

/* Priority colors */
.psa-priority-high .psa-score-value,
.psa-priority-high .psa-score-label {
	color: #16a34a;
}

.psa-priority-high {
	border-left: 3px solid #16a34a;
}

.psa-priority-medium .psa-score-value,
.psa-priority-medium .psa-score-label {
	color: #ca8a04;
}

.psa-priority-medium {
	border-left: 3px solid #ca8a04;
}

.psa-priority-low .psa-score-value,
.psa-priority-low .psa-score-label {
	color: #9ca3af;
}

.psa-priority-low {
	border-left: 3px solid #9ca3af;
}

/* Selection Footer */
.psa-selection-footer {
	display: flex;
	gap: 12px;
	justify-content: center;
	flex-wrap: wrap;
}

/* Responsive */
@media screen and (max-width: 600px) {
	.psa-container {
		padding: 12px;
	}

	.psa-card {
		padding: 20px;
	}

	.psa-title {
		font-size: 22px;
	}

	.psa-button {
		width: 100%;
	}

	.psa-results-actions {
		flex-direction: column;
	}

	.psa-progress-header {
		flex-direction: column;
		align-items: flex-start;
		gap: 8px;
	}

	.psa-method-selector {
		flex-direction: column;
	}

	.psa-method-option {
		min-width: 100%;
	}

	.psa-selection-controls {
		flex-direction: column;
		gap: 12px;
		align-items: stretch;
	}

	.psa-selection-actions {
		justify-content: center;
	}

	.psa-selected-count {
		text-align: center;
	}

	.psa-page-item-content {
		flex-wrap: wrap;
	}

	.psa-page-score {
		width: 100%;
		flex-direction: row;
		justify-content: flex-start;
		gap: 8px;
		margin-top: 8px;
		padding-left: 30px;
	}

	.psa-selection-footer {
		flex-direction: column;
	}

	.psa-score-mode-selector {
		flex-direction: column;
	}

	.psa-score-mode-option {
		min-width: 100%;
	}

	.psa-add-page-input-group {
		flex-direction: column;
	}

	.psa-add-page-btn {
		width: 100%;
	}

	.psa-management-footer {
		flex-direction: column;
	}

	.psa-managed-page-item {
		flex-wrap: wrap;
		gap: 8px;
	}

	.psa-managed-page-url {
		width: 100%;
		padding-right: 0;
	}

	.psa-remove-page-btn {
		width: 100%;
		text-align: center;
	}
}
