/* Shadcn Nova - Gray Base, Amber Theme */
@view-transition {
	navigation: auto;
}

:root {
	/* Font */
	--font-sans: 'Plus Jakarta Sans', sans-serif;

	/* Colors (Forced Dark Mode - Gray Base) */
	--background: 224 71% 4%;
	--foreground: 210 40% 98%;

	--card: 224 71% 4%;
	--card-foreground: 210 40% 98%;

	--popover: 224 71% 4%;
	--popover-foreground: 210 40% 98%;

	--primary: 36 100% 50%;
	--primary-foreground: 224 71% 4%;

	--secondary: 215 28% 17%;
	--secondary-foreground: 210 40% 98%;

	--muted: 215 28% 17%;
	--muted-foreground: 215 20% 65%;

	--accent: 215 28% 17%;
	--accent-foreground: 210 40% 98%;

	--destructive: 0 63% 31%;
	--destructive-foreground: 210 40% 98%;

	--border: 215 28% 17%;
	--input: 215 28% 17%;
	--ring: 36 100% 60%;

	--radius: 0.5rem;

	--success: 142 76% 36%;
	--warning: 36 100% 50%;
	--error: 0 84% 60%;
}

* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html {
	height: 100%;
	font-size: 14px;
}

body {
	font-family: var(--font-sans);
	height: 100%;
	background: hsl(var(--background));
	color: hsl(var(--foreground));
	transition: background 0.3s, color 0.3s;
	-webkit-font-smoothing: antialiased;
}

/* Utilities */
.btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: var(--radius);
	font-size: 0.875rem;
	font-weight: 600;
	height: 40px;
	padding: 0 16px;
	gap: 8px;
	cursor: pointer;
	transition: all 0.2s;
	border: 1px solid transparent;
	background: hsl(var(--primary));
	color: hsl(var(--primary-foreground));
	text-transform: none;
	letter-spacing: normal;
}

.btn:hover {
	opacity: 0.9;
}

.btn-secondary {
	background: hsl(var(--secondary));
	color: hsl(var(--secondary-foreground));
	border: 1px solid transparent;
}

.btn-secondary:hover {
	background: hsl(var(--secondary) / 0.8);
}

.btn-cancel {
	background: transparent;
	color: hsl(var(--muted-foreground));
	border: 1px solid hsl(var(--border));
}

.btn-cancel:hover {
	background: hsl(var(--accent));
	color: hsl(var(--accent-foreground));
}

.btn-danger {
	background: hsl(0 84% 60%);
	color: white;
	border: 1px solid transparent;
}

.btn-danger:hover {
	background: hsl(0 84% 50%);
}

/* Layout */
.app-container {
	min-height: 100%;
	display: flex;
	flex-direction: column;
}

.header {
	background: hsl(var(--card));
	border-bottom: 1px solid hsl(var(--border));
	padding: 16px 24px;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.header-left {
	display: flex;
	align-items: center;
	gap: 12px;
}

.logo {
	width: 36px;
	height: 36px;
	background: transparent;
	border-radius: var(--radius);
	display: flex;
	align-items: center;
	justify-content: center;
}

.header-title {
	font-size: 1.25rem;
	font-weight: 700;
	color: hsl(var(--foreground));
}

.header-subtitle {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
}

.theme-toggle {
	background: hsl(var(--secondary));
	color: hsl(var(--secondary-foreground));
	border: none;
	border-radius: calc(var(--radius) * 1.5);
	padding: 8px 16px;
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	font-weight: 500;
	font-size: 0.875rem;
}

.theme-toggle:hover {
	opacity: 0.9;
}

.main-content {
	flex: 1;
	padding: 32px;
	max-width: 1280px;
	margin: 0 auto;
	width: 100%;
}

/* Cards & Panels */
.panel,
.stat-card,
.modal {
	background: hsl(var(--card));
	color: hsl(var(--card-foreground));
	border: 1px solid hsl(var(--border));
	border-radius: var(--radius);
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.stat-card {
	padding: 24px;
}

.stat-header {
	display: flex;
	align-items: center;
	gap: 12px;
	margin-bottom: 8px;
}

.stat-icon {
	width: 32px;
	height: 32px;
	border-radius: var(--radius);
	display: flex;
	align-items: center;
	justify-content: center;
	color: hsl(var(--primary-foreground));
	background: hsl(var(--primary));
}

.stat-title {
	font-size: 0.875rem;
	font-weight: 600;
	color: hsl(var(--muted-foreground));
}

.stat-value {
	font-size: 2.25rem;
	font-weight: 700;
	color: hsl(var(--foreground));
	letter-spacing: -0.02em;
}

/* Lists */
.email-rule,
.activity-item,
.email-item {
	padding: 16px;
	border-bottom: 1px solid hsl(var(--border));
}

.email-rule {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 16px;
}

.email-rule:last-child {
	border-bottom: none;
}

.rule-from {
	font-weight: 600;
	color: hsl(var(--foreground));
}

.rule-to {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
}

.rule-status {
	display: inline-flex;
	padding: 2px 8px;
	border-radius: var(--radius);
	font-size: 0.75rem;
	font-weight: 700;
	text-transform: uppercase;
}

.rule-status.active {
	background: hsl(var(--primary) / 0.1);
	color: hsl(var(--primary));
	border: 1px solid hsl(var(--primary) / 0.2);
}

.rule-status.inactive {
	background: hsl(var(--muted));
	color: hsl(var(--muted-foreground));
}

.rule-shared {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 0.75rem;
	color: hsl(142 76% 50%);
	margin-top: 4px;
}

.rule-shared .material-icons {
	font-size: 14px;
}

.rule-shared.no-share {
	color: hsl(var(--muted-foreground));
	opacity: 0.7;
}

/* Navbar Tabs */
.nav-tabs {
	display: inline-flex;
	padding: 4px;
	background: hsl(var(--muted));
	border-radius: var(--radius);
	margin-bottom: 24px;
	border: none;
	gap: 4px;
}

.nav-tab {
	padding: 6px 16px;
	font-size: 0.875rem;
	font-weight: 500;
	color: hsl(var(--muted-foreground));
	border-radius: calc(var(--radius) - 2px);
	border: none;
	background: transparent;
	display: flex;
	align-items: center;
	gap: 8px;
	height: 32px;
	line-height: 1;
}

.nav-tab .material-icons {
	font-size: 18px;
}

.nav-tab:hover {
	color: hsl(var(--foreground));
}

.nav-tab.active {
	background: hsl(var(--background));
	color: hsl(var(--foreground));
	box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
	font-weight: 600;
}

/* Forms & Inputs */
.form-group {
	margin-bottom: 16px;
}

.form-label {
	display: block;
	font-size: 0.875rem;
	font-weight: 500;
	color: hsl(var(--foreground));
	margin-bottom: 6px;
}

.form-input,
.form-select {
	width: 100%;
	padding: 8px 12px;
	border-radius: var(--radius);
	border: 1px solid hsl(var(--input));
	background: transparent;
	font-size: 0.875rem;
	color: hsl(var(--foreground));
	transition: border-color 0.2s;
	font-family: inherit;
}

.form-input:focus,
.form-select:focus {
	outline: none;
	border-color: hsl(var(--ring));
	box-shadow: 0 0 0 1px hsl(var(--ring));
}

.form-select option {
	background-color: hsl(var(--card));
	color: hsl(var(--foreground));
}

/* Modals */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.9);
	backdrop-filter: blur(4px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 9999;
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
}

.modal-overlay.active {
	opacity: 1;
	visibility: visible;
}

.modal {
	border: 1px solid hsl(var(--border));
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
	max-width: 500px;
	width: 90%;
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 20px;
	border-bottom: 1px solid hsl(var(--border));
	gap: 16px;
}

.modal-title {
	font-size: 1.125rem;
	font-weight: 700;
	margin: 0;
	flex: 1;
}

.modal-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	border: none;
	background: hsl(var(--secondary));
	color: hsl(var(--muted-foreground));
	cursor: pointer;
	transition: all 0.2s;
	flex-shrink: 0;
}

.modal-close:hover {
	background: hsl(var(--destructive));
	color: hsl(var(--destructive-foreground));
}

.modal-close .material-icons {
	font-size: 18px;
}

.modal-body {
	padding: 20px;
}

.modal-actions {
	padding: 16px 20px;
	background: hsl(var(--muted) / 0.5);
	border-top: 1px solid hsl(var(--border));
	display: flex;
	justify-content: flex-end;
	gap: 12px;
}

/* API Status */
.api-status-container {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
	gap: 16px;
}

.api-status-item {
	padding: 16px;
	display: flex;
	align-items: center;
	gap: 16px;
	border-radius: var(--radius);
	background: hsl(var(--card));
	border: 1px solid hsl(var(--border));
}

.api-status-info {
	flex: 1;
}

.api-status-title {
	font-weight: 600;
	color: hsl(var(--foreground));
	margin-bottom: 4px;
}

.api-status-desc {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
}

.api-status-icon {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.api-status-icon.success {
	background: hsl(142 76% 36% / 0.1);
	color: hsl(142 76% 36%);
}

.api-status-icon.error {
	background: hsl(0 84% 60% / 0.1);
	color: hsl(0 84% 60%);
}

.api-status-badge {
	font-weight: 700;
	background: hsl(var(--secondary));
	color: hsl(var(--secondary-foreground));
}

.api-status-badge.success {
	background: hsl(142 76% 36% / 0.1);
	color: hsl(142 76% 36%);
}

.api-status-badge.error {
	background: hsl(0 84% 60% / 0.1);
	color: hsl(0 84% 60%);
}

/* Grid systems */
.stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
	gap: 24px;
	margin-bottom: 32px;
}

.content-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 24px;
}

/* Misc */
.notification {
	border: 1px solid hsl(var(--border));
	background: hsl(var(--background));
	color: hsl(var(--foreground));
}

.notification.success {
	border-color: hsl(142 76% 36%);
	color: hsl(142 76% 36%);
}

/* Component Styles */
.rule-info {
	flex: 1;
	min-width: 0;
}

.rule-actions {
	display: flex;
	gap: 4px;
	align-items: center;
}

.rule-action-btn {
	background: transparent;
	border: none;
	color: hsl(var(--muted-foreground));
	cursor: pointer;
	padding: 6px;
	border-radius: var(--radius);
	transition: all 0.2s;
}

.rule-action-btn:hover {
	background: hsl(var(--accent));
	color: hsl(var(--accent-foreground));
}

.inbox-list {
	display: flex;
	flex-direction: column;
}

.email-item {
	display: flex;
	align-items: center;
	gap: 16px;
	cursor: pointer;
	transition: background 0.2s;
}

.email-item:hover {
	background: hsl(var(--accent) / 0.5);
}

.email-avatar {
	width: 40px;
	height: 40px;
	border-radius: var(--radius);
	background: hsl(var(--primary));
	color: hsl(var(--primary-foreground));
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	flex-shrink: 0;
	font-size: 1.125rem;
	text-transform: uppercase;
}

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

.email-sender {
	font-weight: 600;
	color: hsl(var(--foreground));
	margin-bottom: 2px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.email-subject {
	color: hsl(var(--muted-foreground));
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 0.875rem;
}

.email-date {
	font-size: 0.75rem;
	color: hsl(var(--muted-foreground));
	white-space: nowrap;
}

.email-meta {
	margin-bottom: 16px;
	padding-bottom: 16px;
	border-bottom: 1px solid hsl(var(--border));
}

.email-meta-row {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.email-content-tabs {
	margin-bottom: 12px;
	display: flex;
	gap: 8px;
}

.email-body-container {
	min-height: 200px;
	max-height: 60vh;
	background: white;
	border: 1px solid hsl(var(--border));
	border-radius: var(--radius);
	padding: 0;
	overflow: auto;
	position: relative;
	-webkit-overflow-scrolling: touch;
}

.email-body-iframe {
	width: 100%;
	height: auto;
	min-height: 200px;
	border: none;
	display: block;
}

.email-body-text {
	padding: 12px;
	white-space: pre-wrap;
	word-break: break-word;
	font-family: monospace;
	font-size: 0.8rem;
	color: #333;
	overflow: auto;
	max-height: 100%;
}

/* Panel Header & Title */
.panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 16px;
	padding: 16px 20px;
	border-bottom: 1px solid hsl(var(--border));
	flex-wrap: wrap;
}

.panel-title {
	font-size: 1rem;
	font-weight: 700;
	color: hsl(var(--foreground));
	margin: 0;
}

.panel-content {
	padding: 16px 20px;
}

.panel-actions {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

/* Small Button */
.btn-sm {
	height: 32px;
	padding: 0 10px;
	font-size: 0.75rem;
}

.btn-sm .material-icons {
	font-size: 16px;
}

/* User Cards */
.users-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.user-card {
	background: hsl(var(--secondary));
	border: 1px solid hsl(var(--border));
	border-radius: var(--radius);
	padding: 16px;
}

.user-card-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 12px;
	margin-bottom: 12px;
}

.user-card-info {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
}

.user-card-name {
	font-weight: 600;
	font-size: 1rem;
	color: hsl(var(--foreground));
}

.user-you {
	font-weight: 400;
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
}

.user-card-actions {
	display: flex;
	gap: 8px;
}

.user-card-emails {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
	word-break: break-all;
}

.user-card-label {
	color: hsl(var(--muted-foreground));
}

.user-card-value {
	color: hsl(var(--foreground));
}

/* Info Box */
.info-box {
	background: hsl(var(--card));
	border: 1px solid hsl(var(--border));
	border-radius: var(--radius);
	overflow: hidden;
}

.info-box-header {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 12px 16px;
	background: hsl(var(--secondary));
	border-bottom: 1px solid hsl(var(--border));
	font-weight: 600;
	font-size: 0.875rem;
	color: hsl(var(--foreground));
}

.info-box-header .material-icons {
	font-size: 18px;
	color: hsl(var(--primary));
}

.info-box-content {
	padding: 16px;
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 16px;
}

.info-item {
	padding: 12px;
	background: hsl(var(--secondary) / 0.5);
	border-radius: var(--radius);
}

.info-item-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-weight: 600;
	font-size: 0.875rem;
	color: hsl(var(--foreground));
	margin-bottom: 8px;
}

.info-item-title .material-icons {
	font-size: 18px;
}

.info-item p {
	font-size: 0.8rem;
	color: hsl(var(--muted-foreground));
	line-height: 1.5;
	margin: 0;
}

/* Terms of Service */
.tos-content {
	max-width: 800px;
}

.tos-content h3 {
	font-size: 1rem;
	font-weight: 700;
	color: hsl(var(--foreground));
	margin: 24px 0 12px 0;
	padding-bottom: 8px;
	border-bottom: 1px solid hsl(var(--border));
}

.tos-content h3:first-of-type {
	margin-top: 16px;
}

.tos-content p {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
	line-height: 1.7;
	margin: 0 0 12px 0;
}

.tos-content ul {
	margin: 0 0 16px 0;
	padding-left: 24px;
}

.tos-content li {
	font-size: 0.875rem;
	color: hsl(var(--muted-foreground));
	line-height: 1.7;
	margin-bottom: 8px;
}

.tos-content li strong {
	color: hsl(var(--foreground));
}

.tos-updated {
	font-size: 0.75rem;
	color: hsl(var(--muted-foreground));
	font-style: italic;
	margin-bottom: 8px !important;
}

/* Search Box */
.search-box {
	display: flex;
	align-items: center;
	gap: 8px;
	background: hsl(var(--secondary));
	border: 1px solid hsl(var(--border));
	border-radius: var(--radius);
	padding: 0 12px;
}

.search-box .material-icons {
	font-size: 18px;
	color: hsl(var(--muted-foreground));
}

.search-box .form-input {
	border: none;
	background: transparent;
	padding: 8px 0;
	width: 150px;
}

.search-box .form-input:focus {
	box-shadow: none;
}

/* Responsive - Desktop */
@media (min-width: 1024px) {
	.content-grid {
		grid-template-columns: 2fr 1fr;
	}
}

/* Responsive - Mobile */
@media (max-width: 640px) {
	.header {
		flex-direction: column;
		gap: 12px;
		align-items: stretch;
		padding: 12px 16px;
	}

	.header-left {
		width: 100%;
		flex-wrap: nowrap;
	}

	/* Keep header action buttons in a row */
	.header .flex {
		display: flex;
		justify-content: flex-end;
		gap: 8px;
	}

	.theme-toggle {
		padding: 8px 12px;
		font-size: 0.8rem;
	}

	.main-content {
		padding: 12px;
	}

	.stats-grid {
		grid-template-columns: 1fr 1fr;
		gap: 12px;
		margin-bottom: 16px;
	}

	/* Compact stat cards on mobile */
	.stat-card {
		padding: 12px;
	}

	.stat-header {
		gap: 8px;
		margin-bottom: 4px;
	}

	.stat-icon {
		width: 28px;
		height: 28px;
	}

	.stat-icon .material-icons {
		font-size: 16px;
	}

	.stat-title {
		font-size: 0.75rem;
	}

	.stat-value {
		font-size: 1.5rem;
	}

	.stat-change {
		font-size: 0.7rem;
	}

	.api-status-container {
		grid-template-columns: 1fr;
	}

	.api-status-item {
		flex-wrap: wrap;
		gap: 12px;
	}

	.api-status-info {
		min-width: 180px;
	}

	.api-status-badge {
		margin-left: auto;
	}

	.email-item {
		padding: 12px;
		gap: 12px;
	}

	.email-avatar {
		width: 32px;
		height: 32px;
		font-size: 0.875rem;
	}

	.nav-tabs {
		width: 100%;
		justify-content: center;
	}

	.nav-tab {
		padding: 6px 12px;
		font-size: 0.8rem;
	}

	/* Panel header mobile */
	.panel-header {
		flex-direction: column;
		gap: 12px;
		align-items: stretch;
		padding: 12px 16px;
	}

	.panel-actions {
		justify-content: space-between;
		width: 100%;
	}

	.search-box {
		flex: 1;
		min-width: 0;
	}

	.search-box .form-input {
		width: 100%;
	}

	.panel-content {
		padding: 12px 16px;
	}

	/* Email Modal Mobile */
	.modal[style*="max-width: 800px"] {
		width: 100% !important;
		max-width: 100% !important;
		margin: 0;
		border-radius: 0;
		max-height: 100vh;
		overflow-y: auto;
	}

	.email-meta-row {
		flex-direction: column;
		align-items: flex-start;
		gap: 4px;
	}

	.email-body-container {
		min-height: 150px;
		max-height: 50vh;
	}

	.email-body-iframe {
		min-height: 150px;
	}

	.email-content-tabs {
		flex-wrap: wrap;
	}

	.email-content-tabs .btn {
		flex: 1;
		justify-content: center;
	}

	/* Info box mobile */
	.info-box-content {
		grid-template-columns: 1fr;
	}
}