/* Estilos CSS - Sistema PWA
 * Tokens alinhados ao layout SIG moderno (chamado 8129 / home v04).
 * Nao alterar paddings/widths/posicoes abaixo sem revisao de layout.
 */
:root {
	/* SIGSISTEM -> midnight_blue (listas.php LST_CORES_SISTEMA) */
	--color-primary: #051532;
	--color-primary-hover: #12386a;
	--color-primary-soft: rgba(30, 90, 143, 0.14);
	--color-text-default: #333;
	--color-text-muted: #666;
	--color-bg-body: #f4f6f9;
	--color-bg-white: #fff;
	--color-bg-muted: #f8f9fa;
	--sig-border-color: #dee2e6;
	--sig-border-color-light: #e9ecef;
	--sig-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
	--sig-shadow-dropdown: 0 4px 16px rgba(0, 0, 0, 0.12);
	--sig-focus-ring: 0 0 0 2px rgba(5, 21, 50, 0.28);
	--sig-radius-md: 6px;
	--sig-radius-lg: 8px;
	--sig-radius-pill: 999px;
	color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
	:root {
		--color-primary: #4a85b8;
		--color-primary-hover: #1e5a8f;
		--color-primary-soft: rgba(74, 133, 184, 0.22);
		--color-text-default: #e9ecef;
		--color-text-muted: #adb5bd;
		--color-bg-body: #121212;
		--color-bg-white: #1e1e1e;
		--color-bg-muted: #2a2a2a;
		--sig-border-color: rgba(255, 255, 255, 0.14);
		--sig-border-color-light: rgba(255, 255, 255, 0.08);
		--sig-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.35);
		--sig-shadow-dropdown: 0 8px 24px rgba(0, 0, 0, 0.45);
		--sig-focus-ring: 0 0 0 2px rgba(74, 133, 184, 0.4);
	}
}

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

body {
	font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	background: var(--color-bg-body);
	color: var(--color-text-default);
	min-height: 100vh;
	overflow-x: hidden;
	-webkit-font-smoothing: antialiased;
}

html.modal-open,
body.modal-open {
	overflow: hidden !important;
	height: 100% !important;
	overscroll-behavior: none;
}
body.modal-open {
	position: fixed !important;
	width: 100% !important;
	left: 0;
	right: 0;
}

.app-container {
	max-width: 480px;
	margin: 0 auto;
	background: var(--color-bg-white);
	min-height: 100vh;
	box-shadow: var(--sig-shadow-dropdown);
}

/* Tela de Login */
.login-screen {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 40px 20px;
	min-height: 100vh;
	background: var(--color-bg-white);
}

.logo-container { margin-bottom: 30px; }
.logo { width: 250px; height: auto; margin-bottom: 20px; }
.login-hint { margin-bottom: 30px; color: var(--color-text-muted); }
.welcome-text { font-size: 18px; color: var(--color-text-default); margin-bottom: 30px; }
.login-form { width: 100%; max-width: 350px; }
.form-group { margin-bottom: 20px; position: relative; }
.form-label { color: var(--color-primary); font-size: 14px; margin-bottom: 5px; display: block; font-weight: 500; }
.form-input { width: 100%; padding: 12px 15px; border: 1px solid var(--sig-border-color); border-radius: var(--sig-radius-lg); font-size: 16px; background: var(--color-bg-white); color: var(--color-text-default); transition: border-color 0.2s, box-shadow 0.2s; }
.form-input:focus { outline: none; border-color: var(--color-primary); box-shadow: var(--sig-focus-ring); }
.password-toggle { position: absolute; right: 12px; bottom: 10px; background: none; border: none; color: var(--color-primary); cursor: pointer; font-size: 18px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--sig-radius-md); }
.password-toggle:hover { background: var(--color-primary-soft); }
.password-toggle i { pointer-events: none; }
.login-btn { width: 100%; padding: 14px; background: var(--color-primary); color: white; border: none; border-radius: var(--sig-radius-pill); font-size: 16px; font-weight: 500; cursor: pointer; margin-top: 20px; transition: background 0.2s, box-shadow 0.2s; }
.login-btn:hover { background: var(--color-primary-hover); box-shadow: var(--sig-shadow-dropdown); }

/* Cabeçalho */
.header {
	background: var(--color-primary); color: white; padding: 15px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; gap: 8px;
}
.menu-btn, .back-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; padding: 5px; width: 40px; flex-shrink: 0; }
.header-title-container { text-align: center; flex: 1; min-width: 0; }
.back-btn.hidden {
	visibility: hidden;
	pointer-events: none;
	display: flex !important; /* mantem largura e o logo centralizado */
}
.header-title { font-size: 20px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.header-info { font-size: 12px; opacity: 0.9; }

/* Dashboard */
.dashboard { padding: 5px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 20px; }
.dashboard-card { padding: 10px 10px; border-radius: var(--sig-radius-lg); text-align: center; cursor: pointer; transition: box-shadow 0.18s ease, transform 0.18s ease; position: relative; overflow: hidden; box-shadow: var(--sig-shadow-card); }
.dashboard-card:hover { transform: translateY(-2px); box-shadow: var(--sig-shadow-dropdown); }
.dashboard-card .card-value { font-size: 28px; font-weight: bold; margin-bottom: 5px; color: white; }
.dashboard-card .card-label { font-size: 12px; color: rgba(255,255,255,0.9); text-transform: uppercase; }
.notification-badge { position: absolute; top: 5px; right: 5px; background: #f44336; color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: bold; }
.card-pendentes { background: #ff9800; } .card-analise { background: #ffc107; } .card-autorizacao { background: #ffeb3b; color: #333; } .card-rascunho { background: var(--color-bg-muted); color: #333; } .card-atraso { background: #f44336; } .card-eficacia { background: #4dd0e1; } .card-finalizadas { background: #333; }

/* Grid de Áreas */
/* areas-grid/area-card legado: estilos em dashboard.css (sig-abc-card) */

/* Lista de Ações */
.actions-list-container { padding: 0 10px; }
.actions-header { display: grid; grid-template-columns: 40px 1fr 60px; gap: 10px; padding: 10px; font-weight: bold; color: #666; font-size: 12px; border-bottom: 1px solid var(--sig-border-color); }
.action-item { display: grid; grid-template-columns: 40px 1fr 60px; align-items: center; gap: 10px; padding: 10px; border-bottom: 1px solid var(--sig-border-color-light); cursor: pointer; transition: background-color 0.2s; }
.action-item:hover { background-color: #f5f5f5; }
.action-icon { font-size: 22px; color: #666; text-align: center; }
.action-content .action-main-info { font-size: 13px; color: #333; }
.action-content .action-sub-info { font-size: 11px; color: #777; }
.action-badge-container { position: relative; }
.action-badge { background: #f44336; color: white; border-radius: 12px; padding: 2px 6px; font-size: 11px; font-weight: bold; display: inline-block; }

/* Menu Lateral */
.side-menu { position: fixed; left: -280px; top: 0; width: 280px; height: 100vh; background: var(--color-bg-white); box-shadow: var(--sig-shadow-dropdown); transition: left 0.3s; z-index: 200; overflow-y: auto; }
.side-menu.active { left: 0; }
.user-profile { background: var(--color-primary); padding: 30px 20px 20px; color: white; }
.user-avatar { width: 60px; height: 60px; background: white; border-radius: 50%; margin-bottom: 15px; display: flex; align-items: center; justify-content: center; color: #666; font-size: 30px; }
.user-name { font-size: 18px; font-weight: 500; margin-bottom: 5px; }
.user-role { font-size: 14px; opacity: 0.9; }
.menu-items { padding: 20px 0 0; }
.menu-separator { height: 1px; background: var(--sig-border-color-light); margin: 5px 20px; }
.menu-items-middle { padding: 0; }
.menu-items-bottom { padding: 0 0 20px; }
.menu-item { display: flex; align-items: center; padding: 15px 20px; color: var(--color-text-default); text-decoration: none; transition: background 0.2s; cursor: pointer; }
.menu-item:hover { background: var(--color-bg-muted); }
.menu-item.active { background: var(--color-primary-soft); color: var(--color-primary); border-left: 4px solid var(--color-primary); padding-left: 16px; }
.menu-icon { width: 30px; margin-right: 15px; font-size: 20px; display: flex; align-items: center; justify-content: center; color: var(--color-primary); }
.menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); opacity: 0; visibility: hidden; transition: all 0.3s; z-index: 150; }
.menu-overlay.active { opacity: 1; visibility: visible; }

/* Modal de Detalhes — tela cheia do app; volta = fecha */
.detail-modal {
	position: fixed;
	top: 0;
	left: 50%;
	right: auto;
	bottom: 0;
	width: 100%;
	max-width: 480px;
	height: 100%;
	height: 100dvh;
	margin: 0;
	border-radius: 0;
	background: #fff;
	box-shadow: var(--sig-shadow-dropdown);
	z-index: 400;
	overflow: hidden;
	overscroll-behavior: contain;
	display: flex;
	flex-direction: column;
	transform: translateX(calc(-50% + 100vw));
	visibility: hidden;
	pointer-events: none;
	transition: transform 0.28s ease-in-out, visibility 0.28s;
}
.detail-modal.active {
	transform: translateX(-50%);
	visibility: visible;
	pointer-events: auto;
}
.detail-header {
	background: var(--color-primary);
	color: white;
	padding: 14px 16px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: relative;
	z-index: 10;
	flex: 0 0 auto;
	min-height: 56px;
	box-sizing: border-box;
}
.detail-header span {
	flex: 1;
	text-align: center;
	font-size: 15px;
	font-weight: 600;
	padding: 0 8px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.close-btn {
	background: none;
	border: none;
	color: white;
	font-size: 24px;
	cursor: pointer;
	padding: 5px;
	flex: 0 0 auto;
}
.detail-header .close-btn,
.detail-header .close-btn i {
	color: #fff !important;
	opacity: 1;
}
.detail-content {
	padding: 0;
	background: #fff;
	box-sizing: border-box;
	flex: 1 1 auto;
	min-height: 0;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}
.detail-content .announcement-iframe-container {
	flex: 1 1 auto;
	height: auto;
	min-height: 0;
	margin: 0;
	border-radius: 0;
	overflow: hidden;
	background: #fff;
	border: none;
	box-shadow: none;
}
.detail-content .announcement-iframe {
	background: #fff;
	border: none;
	width: 100%;
	height: 100%;
}
.company-header { display: flex; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--sig-border-color); }
.company-logo { width: 50px; height: 50px; background: var(--color-primary-soft); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--color-primary); font-size: 20px; margin-right: 15px; }
.company-info h3 { font-size: 16px; margin-bottom: 5px; }
.company-info p { font-size: 12px; color: #666; }
.detail-section { margin-bottom: 20px; }
.section-title { font-size: 14px; font-weight: 600; color: #333; margin-bottom: 10px; padding: 8px; background: var(--color-bg-muted); border-left: 3px solid var(--color-primary); }
.detail-field { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--sig-border-color-light); }
.field-label { font-size: 13px; color: #666; }
.field-value { font-size: 13px; color: #333; font-weight: 500; text-align: right; }

/* Classes de utilidade */
.hidden { display: none !important; }

/* Botão voltar ao topo */
.back-to-top-btn {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 50px;
	height: 50px;
	background: var(--color-primary);
	color: white;
	border: none;
	border-radius: 50%;
	font-size: 20px;
	font-weight: bold;
	cursor: pointer;
	box-shadow: var(--sig-shadow-dropdown);
	z-index: 1000;
	transition: all 0.3s ease;
}

.back-to-top-btn:hover {
	background: var(--color-primary-hover);
	transform: translateY(-2px);
	box-shadow: var(--sig-shadow-dropdown);
}

.back-to-top-btn:active {
	transform: translateY(0);
}

/* Melhorias para navegação mobile */
.side-menu {
	position: fixed;
	left: -280px;
	top: 0;
	width: 280px;
	height: 100vh;
	background: white;
	box-shadow: 2px 0 10px rgba(0,0,0,0.1);
	transition: left 0.3s ease;
	z-index: 200;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch; /* Scroll suave no iOS */
}

.side-menu.active {
	left: 0;
}

/* Melhora a área de toque para elementos interativos */
.menu-item {
	display: flex;
	align-items: center;
	padding: 15px 20px;
	color: #333;
	text-decoration: none;
	transition: all 0.3s;
	cursor: pointer;
	min-height: 48px; /* Área de toque mínima recomendada */
	border-left: 4px solid transparent;
}

.menu-item:hover,
.menu-item:active {
	background: var(--color-bg-muted);
}

.menu-item.active {
	background: var(--color-primary-soft);
	color: var(--color-primary);
	border-left-color: var(--color-primary);
	padding-left: 16px;
}

/* Melhorias no overlay do menu */
.menu-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.5);
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
	z-index: 150;
	backdrop-filter: blur(2px); /* Efeito de desfoque no fundo */
}

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

/* Melhorias nos botões do cabeçalho */
.menu-btn, 
.back-btn {
	background: none;
	border: none;
	color: white;
	font-size: 24px;
	cursor: pointer;
	padding: 8px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.2s ease;
	min-height: 40px; /* Área de toque adequada */
}

.menu-btn:active,
.back-btn:active {
	background: rgba(255, 255, 255, 0.1);
}

/* Melhorias para cards e elementos tocáveis */
.dashboard-card,
.area-card,
.action-item {
	cursor: pointer;
	transition: all 0.2s ease;
	min-height: 48px; /* Área de toque mínima */
}

.dashboard-card:active,
.area-card:active {
	transform: scale(0.98);
}

.action-item:active {
	background-color: #e8f0fe;
}

/* Estilos globais para as páginas do dashboard */
.page-content {
	padding: 5px;
}

.dashboard-header {
	text-align: center;
	margin-bottom: 30px;
}

.dashboard-header h2 {
	color: #333;
	font-size: 24px;
	margin-bottom: 8px;
}

.dashboard-subtitle {
	color: #666;
	font-size: 16px;
	margin: 0;
}

/* Estilos para carregamento e erro */
.loading {
	text-align: center;
	padding: 40px 20px;
	color: #666;
}

.error {
	text-align: center;
	padding: 40px 20px;
	color: #f44336;
	background: #ffebee;
	border-radius: 8px;
	margin: 20px;
}

/* Ajustes para compatibilidade com as páginas HTML */
.page-content .notification-badge {
	position: absolute;
	top: -8px;
	right: -8px;
	background: #ff4444;
	color: white;
	border-radius: 50%;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: bold;
	box-shadow: 0 2px 4px rgba(0,0,0,0.2);
	z-index: 10;
}

.page-content .module-card .notification-badge {
	top: 5px;
	right: 5px;
	border-radius: 6px;
	background: #e53935;
	box-shadow: none;
}

.page-content .module-card,
.page-content .situation-card,
.page-content .area-card {
	cursor: pointer;
	transition: transform 0.2s, box-shadow 0.2s;
}

.page-content .module-card:hover,
.page-content .situation-card:hover,
.page-content .area-card:hover {
	transform: translateY(-2px);
}

/* Estilos para a página Sobre o App simplificada */
.update-info {
	background: var(--color-primary-soft);
	padding: 15px;
	border-radius: 6px;
	margin-bottom: 20px;
	border-left: 4px solid var(--color-primary);
}

.update-info p {
	margin: 0;
	color: #1565c0;
	font-size: 14px;
}

.update-status {
	margin-top: 15px;
	text-align: center;
}

.tips-content {
	display: flex;
	flex-direction: column;
	gap: 15px;
}

.tip-item {
	display: flex;
	align-items: flex-start;
	padding: 15px;
	background: white;
	border-radius: 8px;
	border: 1px solid var(--sig-border-color);
	box-shadow: var(--sig-shadow-card);
}

.tip-icon {
	font-size: 24px;
	margin-right: 15px;
	flex-shrink: 0;
	width: 40px;
	text-align: center;
}

.tip-text {
	flex: 1;
}

.tip-text strong {
	color: #333;
	display: block;
	margin-bottom: 5px;
	font-size: 14px;
}

.troubleshoot-content {
	text-align: center;
}

.troubleshoot-content p {
	margin-bottom: 20px;
	color: #666;
	font-size: 14px;
}

/* Responsividade */
@media (max-width: 480px) {
	.app-container { max-width: 100%; box-shadow: none; }
	.detail-modal {
		left: 0;
		width: 100%;
		max-width: none;
		transform: translateX(100%);
	}
	.detail-modal.active { transform: translateX(0); }
	
	.page-content {
		padding: 16px;
	}
	
	.dashboard-header h2 {
		font-size: 20px;
	}
	
	.dashboard-subtitle {
		font-size: 14px;
	}
	
	.tip-item {
		flex-direction: column;
		text-align: center;
	}
	
	.tip-icon {
		margin-right: 0;
		margin-bottom: 10px;
	}
}

/* Estilos institucionais (Sobre / Politica) — espelha formatAppContent legado */
.dynamic-content,
.institutional-body {
	padding: 0 6px 20px;
}

.dynamic-content p,
.institutional-body p {
	color: #333;
	line-height: 1.6;
	margin-bottom: 16px;
	font-size: 15px;
	font-weight: 400;
	text-align: justify;
}

.dynamic-content h1,
.dynamic-content h2,
.dynamic-content h3,
.dynamic-content h4,
.institutional-body h1,
.institutional-body h2,
.institutional-body h3,
.institutional-body h4 {
	color: #333;
	margin-top: 22px;
	margin-bottom: 12px;
	font-weight: 600;
	line-height: 1.3;
}

.dynamic-content h1,
.institutional-body h1 { font-size: 20px; }
.dynamic-content h2,
.institutional-body h2 { font-size: 17px; }
.dynamic-content h3,
.institutional-body h3 { font-size: 16px; }
.dynamic-content h4,
.institutional-body h4 { font-size: 15px; }

.dynamic-content ul,
.dynamic-content ol,
.institutional-body ul,
.institutional-body ol {
	margin: 0 0 16px 18px;
	padding-left: 4px;
}

.dynamic-content li,
.institutional-body li {
	color: #333;
	line-height: 1.5;
	margin-bottom: 8px;
	font-size: 15px;
	font-weight: 400;
}

.dynamic-content strong,
.dynamic-content b,
.institutional-body strong,
.institutional-body b {
	color: #333;
	font-weight: 600;
	font-size: inherit;
}

@media (max-width: 480px) {
	.dynamic-content p,
	.institutional-body p,
	.dynamic-content li,
	.institutional-body li {
		font-size: 14px;
		text-align: left;
	}
	.dynamic-content h2,
	.institutional-body h2 { font-size: 16px; }
}

/* Comunicado no modal (Versoes) - mesmo visual institucional do app */
.announcement-content {
	padding: 4px 10px 16px;
	max-height: calc(80vh - 90px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.announcement-meta {
	font-size: 13px;
	color: #666;
	margin: 0 0 14px;
	padding-bottom: 10px;
	border-bottom: 1px solid #eee;
}

.announcement-loading,
.announcement-error {
	padding: 40px 20px;
	text-align: center;
	color: #666;
}

.announcement-body span,
.announcement-body font {
	font-family: inherit !important;
	font-size: inherit !important;
	line-height: inherit !important;
	color: inherit !important;
}

.announcement-body img {
	max-width: 100%;
	height: auto;
	display: block;
	margin: 12px 0;
	border-radius: 4px;
}

.announcement-body a {
	color: var(--color-primary);
	text-decoration: underline;
	word-break: break-word;
}

.announcement-modal .modal-body {
	padding: 8px 12px 12px;
	overflow: hidden;
}

.announcement-modal .modal-header h3 {
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	padding-right: 8px;
}

/* Logos login */
.logo-dark { display: none; }

/* --- Dark mode (preferencia do sistema) --- */
@media (prefers-color-scheme: dark) {
	html, body {
		background: var(--color-bg-body);
		color: var(--color-text-default);
	}
	.app-container,
	.login-screen,
	.side-menu,
	.detail-modal,
	.detail-content,
	.detail-content .announcement-iframe-container {
		background: var(--color-bg-white);
	}
	.login-screen .logo-light { display: none; }
	.login-screen .logo-dark { display: block; }
	.welcome-text,
	.menu-item,
	.action-content .action-main-info,
	.field-value,
	.company-info h3,
	.section-title,
	.dynamic-content strong,
	.institutional-body strong {
		color: var(--color-text-default);
	}
	.login-screen p,
	.header-info,
	.action-content .action-sub-info,
	.field-label,
	.company-info p,
	.user-role,
	.announcement-meta,
	.announcement-loading,
	.announcement-error {
		color: var(--color-text-muted);
	}
	.form-input {
		background: var(--color-bg-muted);
		color: var(--color-text-default);
		border-color: var(--sig-border-color);
	}
	.menu-item:hover,
	.action-item:hover {
		background: var(--color-bg-muted);
	}
	.menu-item.active {
		background: var(--color-primary-soft);
		color: var(--color-primary);
	}
	.section-title,
	.tip-item,
	.update-info {
		background: var(--color-bg-muted);
		border-color: var(--sig-border-color);
	}
	.announcement-meta {
		border-bottom-color: var(--sig-border-color-light);
	}
}

.menu-icon i,
.menu-btn i,
.back-btn i,
.close-btn i,
.login-btn i,
.user-avatar i {
	line-height: 1;
}
.user-avatar {
	font-size: 22px;
}
.user-avatar i {
	color: var(--color-primary);
}
.login-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}


/* header brand midnight */
@media (prefers-color-scheme: dark) {
	.header,
	.user-profile,
	.detail-header {
		background: #051532;
	}
}

/* Dark mode refinements */
@media (prefers-color-scheme: dark) {
	.login-hint,
	.welcome-text {
		color: var(--color-text-default);
	}
	.form-label {
		color: #93c5fd;
	}
	.password-toggle {
		color: #93c5fd;
	}
	.side-menu .menu-item {
		color: var(--color-text-default);
	}
	.side-menu .menu-separator {
		background: var(--sig-border-color);
	}
	.user-avatar {
		background: rgba(255, 255, 255, 0.12);
	}
	.user-avatar i {
		color: #fff;
	}
	.update-info {
		background: var(--color-bg-muted);
		border-left-color: var(--color-primary);
	}
	.update-info p {
		color: var(--color-text-muted);
	}
	.page-content .module-card,
	.page-content .situation-card,
	.page-content .area-card {
		/* evita override claro residual */
	}
}
