/**
 * SecuBox Widget System Styles
 * Responsive grid layout for app widgets
 */

/* Widget Grid Container */
.widget-grid {
	display: grid;
	gap: 1.5rem;
	margin-top: 1.5rem;
}

/* Grid Modes */
.widget-grid-auto {
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.widget-grid-fixed-2 {
	grid-template-columns: repeat(2, 1fr);
}

.widget-grid-fixed-3 {
	grid-template-columns: repeat(3, 1fr);
}

.widget-grid-fixed-4 {
	grid-template-columns: repeat(4, 1fr);
}

/* Responsive adjustments */
@media (max-width: 1400px) {
	.widget-grid-fixed-4 {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 1024px) {
	.widget-grid-fixed-3,
	.widget-grid-fixed-4 {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 768px) {
	.widget-grid {
		grid-template-columns: 1fr !important;
		gap: 1rem;
	}
}

/* Widget Item */
.widget-item {
	background: var(--card-bg, #fff);
	border: 1px solid var(--border-color, #e0e0e0);
	border-radius: 8px;
	padding: 1rem;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	transition: box-shadow 0.2s, transform 0.2s;
}

.widget-item:hover {
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
	transform: translateY(-2px);
}

/* Widget Loading State */
.widget-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 120px;
	color: #999;
}

.widget-loading .spinner {
	width: 40px;
	height: 40px;
	border: 3px solid #f3f3f3;
	border-top: 3px solid #0066cc;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin-bottom: 0.5rem;
}

@keyframes spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* Widget Error State */
.widget-error {
	text-align: center;
	padding: 1.5rem;
	color: #d32f2f;
}

.widget-error .error-icon {
	font-size: 2.5rem;
	margin-bottom: 0.5rem;
}

.widget-error .error-message {
	font-weight: 600;
	margin-bottom: 0.25rem;
}

.widget-error .error-details {
	font-size: 0.85rem;
	color: #666;
}

/* Widget Header */
.widget-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 1rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid var(--border-color, #e0e0e0);
}

.widget-icon {
	font-size: 2rem;
	line-height: 1;
}

.widget-icon-small {
	font-size: 1.5rem;
	line-height: 1;
}

.widget-title {
	font-size: 1.1rem;
	font-weight: 600;
	flex: 1;
	color: var(--text-primary, #333);
}

.widget-title-small {
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--text-secondary, #666);
}

.widget-status-indicator {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	margin-left: auto;
}

.widget-status-badge {
	padding: 0.25rem 0.75rem;
	border-radius: 12px;
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	margin-left: auto;
}

/* Status Colors */
.status-success,
.widget-status-badge.status-success {
	background-color: #4caf50;
	color: white;
}

.status-warning,
.widget-status-badge.status-warning {
	background-color: #ff9800;
	color: white;
}

.status-error,
.widget-status-badge.status-error {
	background-color: #f44336;
	color: white;
}

.status-unknown,
.widget-status-badge.status-unknown {
	background-color: #9e9e9e;
	color: white;
}

/* Widget Metrics */
.widget-metrics {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
}

.metric-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.metric-row:last-child {
	border-bottom: none;
}

.metric-label {
	font-size: 0.9rem;
	color: var(--text-secondary, #666);
}

.metric-value {
	font-size: 1.1rem;
	font-weight: 600;
	color: var(--text-primary, #333);
}

.metric-value.value-warning {
	color: #ff9800;
}

.metric-value.value-error {
	color: #f44336;
}

/* Widget Metrics Grid */
.widget-metrics-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
	gap: 1rem;
	margin-top: 0.5rem;
}

.metric-card {
	text-align: center;
	padding: 1rem;
	background: var(--card-accent-bg, #f8f9fa);
	border-radius: 6px;
	border: 1px solid var(--border-light, #f0f0f0);
}

.metric-card-label {
	font-size: 0.8rem;
	color: var(--text-secondary, #666);
	margin-bottom: 0.5rem;
	text-transform: uppercase;
	font-weight: 500;
}

.metric-card-value {
	font-size: 1.5rem;
	font-weight: 700;
	color: var(--text-primary, #333);
	line-height: 1.2;
}

.metric-card-value.value-warning {
	color: #ff9800;
}

.metric-card-value.value-error {
	color: #f44336;
}

.metric-card-unit {
	font-size: 0.75rem;
	color: var(--text-secondary, #666);
	margin-top: 0.25rem;
}

/* Security Widget Specific */
.widget-security .widget-last-event {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--border-color, #e0e0e0);
	font-size: 0.85rem;
	color: var(--text-secondary, #666);
}

.widget-security .event-label {
	font-weight: 500;
}

.widget-security .event-time {
	color: var(--text-primary, #333);
}

/* Network Widget Specific */
.widget-network .widget-metrics {
	margin-top: 0.5rem;
}

/* Monitoring Widget Specific */
.widget-monitoring .widget-uptime {
	margin-top: 1rem;
	padding-top: 1rem;
	border-top: 1px solid var(--border-color, #e0e0e0);
	text-align: center;
	font-size: 0.9rem;
}

.widget-monitoring .uptime-label {
	color: var(--text-secondary, #666);
}

.widget-monitoring .uptime-value {
	font-weight: 600;
	color: var(--text-primary, #333);
}

/* Hosting Widget Specific */
.widget-hosting .widget-services {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.widget-hosting .service-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0.75rem;
	background: var(--card-accent-bg, #f8f9fa);
	border-radius: 4px;
	border-left: 3px solid transparent;
}

.widget-hosting .service-item.service-running {
	border-left-color: #4caf50;
}

.widget-hosting .service-item.service-stopped {
	border-left-color: #f44336;
}

.widget-hosting .service-name {
	font-weight: 500;
	color: var(--text-primary, #333);
}

.widget-hosting .service-status {
	font-size: 1.2rem;
}

.widget-hosting .service-running .service-status {
	color: #4caf50;
}

.widget-hosting .service-stopped .service-status {
	color: #f44336;
}

/* Compact Widget */
.widget-compact {
	display: flex;
	align-items: center;
	gap: 1rem;
	padding: 0.5rem;
}

.widget-compact .widget-content {
	flex: 1;
}

.widget-compact .widget-value-large {
	font-size: 2rem;
	font-weight: 700;
	color: var(--accent-color, #0066cc);
	line-height: 1;
}

.widget-compact .widget-label-small {
	font-size: 0.8rem;
	color: var(--text-secondary, #666);
	margin-top: 0.25rem;
}

/* Default Widget */
.widget-default {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-height: 120px;
	text-align: center;
}

.widget-default .widget-icon {
	font-size: 3rem;
	margin-bottom: 0.5rem;
}

.widget-default .widget-title {
	font-size: 1.1rem;
	font-weight: 600;
	margin-bottom: 0.5rem;
}

.widget-default .widget-status {
	font-size: 0.9rem;
	color: var(--text-secondary, #666);
}

/* No Widgets State */
.no-widgets {
	grid-column: 1 / -1;
	text-align: center;
	padding: 4rem 2rem;
	color: var(--text-secondary, #666);
}

.no-widgets-icon {
	font-size: 4rem;
	margin-bottom: 1rem;
	opacity: 0.5;
}

.no-widgets h3 {
	font-size: 1.5rem;
	margin-bottom: 0.5rem;
	color: var(--text-primary, #333);
}

.no-widgets p {
	font-size: 1rem;
	max-width: 500px;
	margin: 0 auto;
}

/* Widget Category Colors */
.widget-security {
	border-left: 4px solid #f44336;
}

.widget-network {
	border-left: 4px solid #2196f3;
}

.widget-monitoring {
	border-left: 4px solid #4caf50;
}

.widget-hosting {
	border-left: 4px solid #ff9800;
}

.widget-productivity {
	border-left: 4px solid #9c27b0;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
	.widget-item {
		background: #2a2a2a;
		border-color: #444;
	}

	.widget-header {
		border-bottom-color: #444;
	}

	.widget-title {
		color: #e0e0e0;
	}

	.metric-row {
		border-bottom-color: #333;
	}

	.metric-label {
		color: #999;
	}

	.metric-value {
		color: #e0e0e0;
	}

	.metric-card {
		background: #333;
		border-color: #444;
	}

	.metric-card-value {
		color: #e0e0e0;
	}

	.widget-hosting .service-item {
		background: #333;
	}

	.no-widgets h3 {
		color: #e0e0e0;
	}
}

/* Print Styles */
@media print {
	.widget-grid {
		display: block;
	}

	.widget-item {
		break-inside: avoid;
		page-break-inside: avoid;
		margin-bottom: 1rem;
		box-shadow: none;
		border: 1px solid #ccc;
	}
}

/* Widget Header with Version and Status */
.widget-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	margin-bottom: 1rem;
	padding-bottom: 0.75rem;
	border-bottom: 1px solid rgba(99, 102, 241, 0.1);
}

.widget-title-wrapper {
	flex: 1;
	min-width: 0;
}

.widget-title {
	font-size: 0.95rem;
	font-weight: 600;
	color: var(--cyber-text, #1e293b);
	margin: 0;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.widget-version {
	font-size: 0.75rem;
	color: var(--cyber-text-dim, #64748b);
	font-family: 'JetBrains Mono', monospace;
	margin-top: 0.2rem;
}

/* Widget Status Indicator (Dot) */
.widget-status-indicator {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex-shrink: 0;
	box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
	animation: pulse 2s ease-in-out infinite;
}

.widget-status-indicator.status-success {
	background: #10b981;
	box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2), 0 0 10px rgba(16, 185, 129, 0.3);
}

.widget-status-indicator.status-warning {
	background: #f59e0b;
	box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2), 0 0 10px rgba(245, 158, 11, 0.3);
}

.widget-status-indicator.status-error {
	background: #ef4444;
	box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2), 0 0 10px rgba(239, 68, 68, 0.3);
}

.widget-status-indicator.status-unknown {
	background: #6b7280;
	box-shadow: 0 0 0 2px rgba(107, 116, 128, 0.2);
	animation: none;
}

@keyframes pulse {
	0%, 100% {
		opacity: 1;
	}
	50% {
		opacity: 0.6;
	}
}

/* Widget Status Text Badge */
.widget-status-text {
	margin-bottom: 0.75rem;
}

.status-badge {
	display: inline-block;
	padding: 0.25rem 0.75rem;
	font-size: 0.7rem;
	font-weight: 600;
	border-radius: 12px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.status-badge.status-success {
	background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.15));
	color: #059669;
	border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.status-warning {
	background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.15));
	color: #d97706;
	border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.status-error {
	background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(220, 38, 38, 0.15));
	color: #dc2626;
	border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.status-unknown {
	background: rgba(107, 116, 128, 0.1);
	color: #6b7280;
	border: 1px solid rgba(107, 116, 128, 0.2);
}

/* Enhanced widget icon */
.widget-icon {
	font-size: 2rem;
	line-height: 1;
	flex-shrink: 0;
}
