/* Equipa Multidisciplinar - Registo de Processos — frontoffice autónomo */

:root {
	--gip-primary: #2563eb;
	--gip-primary-dark: #1d4ed8;
	--gip-bg: #f4f5f7;
	--gip-card: #ffffff;
	--gip-border: #e2e4e9;
	--gip-text: #1f2430;
	--gip-text-muted: #6b7280;
	--gip-radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body.gip-app {
	margin: 0;
	background: var(--gip-bg);
	color: var(--gip-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	-webkit-tap-highlight-color: transparent;
}

a { color: var(--gip-primary); }

.gip-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* Topbar */
.gip-topbar {
	display: flex;
	align-items: center;
	gap: 24px;
	background: #fff;
	border-bottom: 1px solid var(--gip-border);
	padding: 0 24px;
	padding-top: env(safe-area-inset-top, 0px);
	padding-left: calc(24px + env(safe-area-inset-left, 0px));
	padding-right: calc(24px + env(safe-area-inset-right, 0px));
	min-height: 60px;
	position: sticky;
	top: 0;
	z-index: 30;
}

/* Hambúrguer (só aparece em ecrãs pequenos — ver media query) */
.gip-nav-toggle-input { display: none; }

.gip-nav-burger {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 40px;
	height: 40px;
	cursor: pointer;
	flex-shrink: 0;
}

.gip-nav-burger span {
	display: block;
	height: 2px;
	width: 100%;
	background: var(--gip-text);
	border-radius: 2px;
	transition: transform 0.15s ease, opacity 0.15s ease;
}

.gip-nav-toggle-input:checked ~ .gip-nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.gip-nav-toggle-input:checked ~ .gip-nav-burger span:nth-child(2) { opacity: 0; }
.gip-nav-toggle-input:checked ~ .gip-nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.gip-topbar-brand {
	font-weight: 700;
	font-size: 17px;
	display: flex;
	align-items: center;
	gap: 8px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.gip-logo-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--gip-primary);
	display: inline-block;
}

.gip-logo-dot-warn { background: #d97706; }

.gip-brand-logo {
	max-height: 32px;
	max-width: 160px;
	display: block;
}

.gip-nav {
	display: flex;
	gap: 4px;
	flex: 1;
}

.gip-nav a {
	text-decoration: none;
	color: var(--gip-text-muted);
	padding: 8px 14px;
	border-radius: 8px;
	font-weight: 500;
	font-size: 14px;
}

.gip-nav a:hover { background: var(--gip-bg); color: var(--gip-text); }
.gip-nav a.is-active { background: #eaf0fe; color: var(--gip-primary-dark); }

.gip-topbar-user {
	display: flex;
	align-items: center;
	gap: 10px;
	font-size: 13px;
	color: var(--gip-text-muted);
	white-space: nowrap;
}

/* Main */
.gip-main {
	flex: 1;
	width: 100%;
	max-width: 1100px;
	margin: 0 auto;
	padding: 28px 24px 60px;
}

.gip-page-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 20px;
	flex-wrap: wrap;
}

.gip-page-head h1 { font-size: 22px; margin: 0; }
.gip-page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gip-muted { color: var(--gip-text-muted); font-weight: 400; font-size: 16px; }

.gip-section-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin: 28px 0 12px;
}

.gip-section-head h2 { font-size: 16px; margin: 0; }

.gip-processo-summary { margin-bottom: 10px; }

.gip-summary-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: 14px 20px;
}

.gip-summary-grid > div { display: flex; flex-direction: column; gap: 2px; }

.gip-summary-label {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--gip-text-muted);
}

.gip-summary-obs {
	margin: 16px 0 0;
	padding-top: 14px;
	border-top: 1px solid var(--gip-border);
	font-size: 14px;
}

.gip-indicadores-card { margin-bottom: 20px; }

.gip-indicador-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 10px 0;
	border-bottom: 1px solid var(--gip-border);
}

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

.gip-indicador-label { font-size: 14px; }

.gip-indicador-meta {
	display: block;
	font-size: 12px;
	color: var(--gip-text-muted);
}

.gip-report-subtable th,
.gip-report-subtable td { font-size: 13px; padding: 7px 6px; }

.gip-mapa-tecnico-fixo {
	display: inline-flex;
	align-items: center;
	padding: 8px 14px;
	border: 1px solid var(--gip-border);
	border-radius: 8px;
	background: var(--gip-bg);
	font-weight: 600;
	font-size: 14px;
}

/* Sessões */
.gip-sessoes-totais { margin-bottom: 20px; }

.gip-stats-number-sm {
	display: block;
	font-size: 22px;
	font-weight: 700;
	color: var(--gip-primary);
	margin-top: 2px;
}

.gip-badge-sessao-realizada { background: #d7f0da; color: #1e5c2a; }
.gip-badge-sessao-falta { background: #fde8e8; color: #9b1c1c; }
.gip-badge-sessao-cancelada { background: #f0f0f1; color: #646970; }

/* Avaliações — grelha de indicadores */
.gip-avaliacao-area { margin-bottom: 24px; }
.gip-avaliacao-area h3 { font-size: 14px; margin: 0 0 8px; }

.gip-avaliacao-table {
	width: 100%;
	border-collapse: collapse;
	background: var(--gip-card);
	border: 1px solid var(--gip-border);
	border-radius: 8px;
	overflow: hidden;
}

.gip-avaliacao-table th,
.gip-avaliacao-table td {
	border-bottom: 1px solid var(--gip-border);
	padding: 8px 6px;
	font-size: 13px;
	text-align: center;
}

.gip-avaliacao-table th {
	background: #fafbfc;
	font-weight: 600;
	color: var(--gip-text-muted);
	font-size: 11px;
	text-transform: uppercase;
}

.gip-avaliacao-label {
	text-align: left !important;
	min-width: 180px;
	position: sticky;
	left: 0;
	background: var(--gip-card);
	z-index: 1;
}
.gip-avaliacao-table thead th:first-child {
	position: sticky;
	left: 0;
	z-index: 2;
	background: #fafbfc;
}
.gip-avaliacao-radio { width: 38px; }
.gip-avaliacao-radio label { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-size: 11px; color: var(--gip-text-muted); padding: 4px 0; }
.gip-avaliacao-obs { width: 100%; min-width: 160px; padding: 6px 8px; border: 1px solid var(--gip-border); border-radius: 6px; font-size: 13px; }

input[type="radio"],
input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* Técnicos — grelha de checkboxes de Agrupamentos */
.gip-checkbox-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
	gap: 8px 16px;
}

.gip-footer {
	text-align: center;
	font-size: 12px;
	color: var(--gip-text-muted);
	padding: 16px;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 10px;
}

.gip-footer-images {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 24px;
	flex-wrap: wrap;
}

.gip-footer-image {
	max-height: 50px;
	max-width: 200px;
}

/* Buttons */
.gip-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 9px 16px;
	border-radius: 8px;
	border: 1px solid var(--gip-border);
	background: #fff;
	color: var(--gip-text);
	text-decoration: none;
	cursor: pointer;
	font-size: 14px;
	font-weight: 500;
	line-height: 1.2;
}

.gip-btn:hover { background: var(--gip-bg); }

.gip-btn-primary {
	background: var(--gip-primary);
	border-color: var(--gip-primary);
	color: #fff;
}

.gip-btn-primary:hover { background: var(--gip-primary-dark); }

.gip-btn-ghost { background: transparent; }
.gip-btn-sm { padding: 5px 10px; font-size: 12px; }

/* Notices */
.gip-notice {
	background: #ecfdf3;
	border: 1px solid #bbf0cf;
	color: #15713f;
	padding: 10px 14px;
	border-radius: 8px;
	margin-bottom: 18px;
	font-size: 14px;
}

.gip-notice-error {
	background: #fef2f2;
	border-color: #fecaca;
	color: #b91c1c;
}

.gip-help-text { color: var(--gip-text-muted); font-size: 13px; }

/* Filter form */
.gip-filter-form {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 18px;
}

.gip-filter-form input[type="text"],
.gip-filter-form select {
	padding: 8px 10px;
	border: 1px solid var(--gip-border);
	border-radius: 8px;
	font-size: 14px;
	background: #fff;
}

/* Table */
.gip-table-wrap {
	overflow-x: auto;
	background: var(--gip-card);
	border: 1px solid var(--gip-border);
	border-radius: var(--gip-radius);
}

.gip-table {
	width: 100%;
	border-collapse: collapse;
}

.gip-table th,
.gip-table td {
	text-align: left;
	padding: 12px 14px;
	border-bottom: 1px solid var(--gip-border);
	font-size: 14px;
}

.gip-table th {
	background: #fafbfc;
	font-weight: 600;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--gip-text-muted);
}

.gip-table tr:last-child td { border-bottom: none; }

.gip-badge {
	display: inline-block;
	padding: 3px 10px;
	border-radius: 12px;
	font-size: 12px;
	font-weight: 600;
	background: #f0f0f1;
	color: #3c434a;
}

.gip-badge-ativo { background: #d7f0da; color: #1e5c2a; }
.gip-badge-nao_ativo { background: #f0f0f1; color: #646970; }
.gip-badge-resolvido { background: #d6e4f0; color: #1a4a73; }
.gip-badge-reencaminhado { background: #f5e6c8; color: #7a5a10; }

/* Pagination */
.gip-pagination {
	margin-top: 16px;
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.gip-pagination a {
	padding: 6px 11px;
	border: 1px solid var(--gip-border);
	border-radius: 8px;
	text-decoration: none;
	color: var(--gip-text);
	background: #fff;
	font-size: 13px;
}

.gip-pagination a.current {
	background: var(--gip-primary);
	border-color: var(--gip-primary);
	color: #fff;
}

/* Card / form */
.gip-card {
	background: var(--gip-card);
	border: 1px solid var(--gip-border);
	border-radius: var(--gip-radius);
	padding: 24px;
}

.gip-form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 16px 20px;
}

.gip-field-full { grid-column: 1 / -1; }

.gip-form-section-title {
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--gip-text-muted);
	margin: 26px 0 14px;
	padding-top: 18px;
	border-top: 1px solid var(--gip-border);
}

.gip-referenciacao-detalhe {
	margin-top: 14px;
	padding-top: 14px;
	border-top: 1px solid var(--gip-border);
}

.gip-referenciacao-detalhe p { margin: 0 0 8px; font-size: 14px; }
.gip-referenciacao-detalhe p:last-child { margin-bottom: 0; }
.gip-field-checkbox { grid-column: 1 / -1; }

.gip-field-hint {
	margin: 6px 0 0;
	font-size: 12px;
	color: var(--gip-text-muted);
}

.gip-field label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 6px;
	color: var(--gip-text-muted);
}

.gip-field input[type="text"],
.gip-field input[type="password"],
.gip-field input[type="date"],
.gip-field input[type="file"],
.gip-field select,
.gip-field textarea {
	width: 100%;
	padding: 9px 11px;
	border: 1px solid var(--gip-border);
	border-radius: 8px;
	font-size: 14px;
	font-family: inherit;
	background: #fff;
}

.gip-field textarea { resize: vertical; }

.gip-form-actions {
	margin-top: 22px;
	display: flex;
	gap: 10px;
}

/* Stats */
.gip-stats-total {
	background: var(--gip-card);
	border: 1px solid var(--gip-border);
	border-radius: var(--gip-radius);
	padding: 20px 24px;
	margin-bottom: 20px;
	display: flex;
	align-items: baseline;
	gap: 10px;
}

.gip-stats-number { font-size: 32px; font-weight: 700; color: var(--gip-primary); }

.gip-stats-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
	gap: 18px;
}

.gip-card h2 {
	margin-top: 0;
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--gip-text-muted);
}

.gip-stats-table { width: 100%; border-collapse: collapse; }
.gip-stats-table td { padding: 7px 0; border-bottom: 1px solid var(--gip-border); font-size: 14px; }
.gip-stats-table tr:last-child td { border-bottom: none; }
.gip-stats-count { text-align: right; font-weight: 600; }

.gip-bar-row {
	display: grid;
	grid-template-columns: 45% 1fr 32px;
	align-items: center;
	gap: 8px;
	margin-bottom: 10px;
	font-size: 13px;
}

.gip-bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.gip-bar-track {
	background: var(--gip-bg);
	border-radius: 4px;
	height: 10px;
	overflow: hidden;
}

.gip-bar-fill { display: block; height: 100%; background: var(--gip-primary); }
.gip-bar-count { text-align: right; font-weight: 600; }

/* Login / denied */
.gip-app-center {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100vh;
	padding: calc(20px + env(safe-area-inset-top, 0px)) calc(20px + env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) calc(20px + env(safe-area-inset-left, 0px));
}

.gip-card-center {
	background: var(--gip-card);
	border: 1px solid var(--gip-border);
	border-radius: var(--gip-radius);
	padding: 40px;
	max-width: 420px;
	width: 100%;
	text-align: center;
}

.gip-brand-lg {
	font-weight: 700;
	font-size: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-bottom: 18px;
}

.gip-card-center h1 { font-size: 19px; margin: 0 0 10px; }
.gip-card-center p { color: var(--gip-text-muted); margin-bottom: 22px; }

.gip-login-card { max-width: 400px; }
.gip-login-logo { max-height: 56px; max-width: 220px; margin: 0 auto; }

.gip-login-form { text-align: left; margin-top: 18px; }
.gip-login-form .gip-field { margin-bottom: 16px; }
.gip-login-remember { margin-bottom: 18px !important; }
.gip-login-remember label { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--gip-text); }
.gip-login-submit { width: 100%; justify-content: center; }

.gip-login-lost { margin: 18px 0 0; font-size: 13px; }

.gip-login-footer-images {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 18px;
	margin-top: 26px;
	padding-top: 20px;
	border-top: 1px solid var(--gip-border);
}

.gip-login-footer-images img { max-height: 40px; max-width: 140px; }

/* Definições */
.gip-settings-card { margin-bottom: 18px; }
.gip-settings-card h2 { margin-top: 0; font-size: 15px; text-transform: none; letter-spacing: normal; color: var(--gip-text); }
.gip-settings-textarea {
	width: 100%;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 13px;
	padding: 10px 12px;
	border: 1px solid var(--gip-border);
	border-radius: 8px;
	resize: vertical;
}

.gip-logo-preview {
	display: flex;
	align-items: center;
	gap: 14px;
	background: var(--gip-bg);
	border: 1px solid var(--gip-border);
	border-radius: 8px;
	padding: 10px 12px;
	margin-bottom: 10px;
}

.gip-logo-preview img { max-height: 48px; max-width: 160px; }

.gip-inline-checkbox {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	color: var(--gip-text-muted);
	font-weight: 400;
}

/* Relatório individual (ecrã + impressão) */
.gip-report-toolbar {
	max-width: 720px;
	margin: 20px auto 0;
	padding: 0 20px;
	display: flex;
	justify-content: space-between;
	gap: 10px;
}

.gip-report-sheet {
	max-width: 720px;
	margin: 20px auto 60px;
	background: #fff;
	border: 1px solid var(--gip-border);
	border-radius: var(--gip-radius);
	padding: 40px;
}

.gip-report-header {
	display: flex;
	align-items: center;
	gap: 18px;
	border-bottom: 2px solid var(--gip-text);
	padding-bottom: 18px;
	margin-bottom: 22px;
}

.gip-report-logo { max-height: 60px; max-width: 180px; }
.gip-report-header-text h1 { font-size: 19px; margin: 0 0 4px; }
.gip-report-header-text p { margin: 0; color: var(--gip-text-muted); font-size: 13px; }

.gip-report-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.gip-report-table th,
.gip-report-table td {
	text-align: left;
	padding: 9px 4px;
	border-bottom: 1px solid var(--gip-border);
	font-size: 14px;
	vertical-align: top;
}
.gip-report-table th { width: 220px; color: var(--gip-text-muted); font-weight: 600; }

.gip-report-section h2 {
	font-size: 13px;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: var(--gip-text-muted);
	margin-bottom: 8px;
}

.gip-report-observacoes { white-space: pre-line; }

.gip-report-footer {
	margin-top: 30px;
	padding-top: 14px;
	border-top: 1px solid var(--gip-border);
	font-size: 12px;
	color: var(--gip-text-muted);
	text-align: center;
}

.gip-report-footer p { margin: 0; }

.gip-report-footer-images {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 24px;
	flex-wrap: wrap;
	margin-bottom: 10px;
}

.gip-report-footer-image {
	max-height: 50px;
	max-width: 180px;
}

@media print {
	.gip-no-print { display: none !important; }
	body.gip-report-body { background: #fff; }
	.gip-report-sheet { border: none; margin: 0; padding: 0; max-width: none; }
	/* Qualquer ecrã normal da app (não só o relatório individual): esconder navegação ao imprimir. */
	.gip-topbar, .gip-footer, .gip-filter-form, .gip-page-head-actions, .gip-form-actions { display: none !important; }
	.gip-main { max-width: none; padding: 0; }
}

/* Responsive — telemóvel e tablet */
@media (max-width: 900px) {
	.gip-topbar { padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); gap: 10px; }
	.gip-topbar-brand { flex: 1; min-width: 0; font-size: 15px; }
	.gip-brand-logo { max-height: 28px; }

	.gip-nav-burger { display: flex; }

	/* O menu passa a um painel que desliza a partir do topo, só visível quando o hambúrguer é aberto. */
	.gip-nav {
		display: none;
		flex-direction: column;
		gap: 2px;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		background: #fff;
		border-bottom: 1px solid var(--gip-border);
		box-shadow: 0 12px 20px rgba(17, 24, 39, 0.08);
		padding: 8px;
		padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
		max-height: calc(100vh - 60px);
		overflow-y: auto;
		z-index: 25;
	}

	.gip-nav-toggle-input:checked ~ .gip-nav { display: flex; }

	.gip-nav a { padding: 13px 14px; font-size: 15px; }

	.gip-topbar-user span { display: none; }

	.gip-main { padding: 18px 16px 50px; }

	.gip-form-grid { grid-template-columns: 1fr; }

	/* Alvos de toque maiores e sem zoom automático do iOS ao focar campos (que exige >=16px). */
	.gip-btn { min-height: 44px; }
	.gip-field input[type="text"],
	.gip-field input[type="password"],
	.gip-field input[type="date"],
	.gip-field input[type="time"],
	.gip-field input[type="number"],
	.gip-field input[type="file"],
	.gip-field select,
	.gip-field textarea,
	.gip-filter-form input[type="text"],
	.gip-filter-form select,
	.gip-login-form input {
		font-size: 16px;
	}

	/* Filtros empilhados a toda a largura — mais fáceis de usar com o dedo. */
	.gip-filter-form { flex-direction: column; align-items: stretch; }
	.gip-filter-form input,
	.gip-filter-form select,
	.gip-filter-form button,
	.gip-filter-form label { width: 100%; }
	.gip-filter-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--gip-text-muted); }

	.gip-page-head-actions { width: 100%; }
	.gip-page-head-actions .gip-btn { flex: 1; justify-content: center; }

	.gip-summary-grid,
	.gip-stats-grid,
	.gip-checkbox-grid { grid-template-columns: 1fr; }

	.gip-report-sheet { padding: 24px 18px; margin: 12px auto 40px; }
	.gip-report-toolbar { padding: 0 16px; }
	.gip-report-header { flex-direction: column; align-items: flex-start; gap: 10px; }

	.gip-card-center { padding: 28px 22px; }

	.gip-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }

	/* Tabelas: em vez de scroll horizontal, cada linha passa a um pequeno cartão. */
	.gip-table thead { display: none; }
	.gip-table, .gip-table tbody, .gip-table tr, .gip-table td { display: block; width: 100%; }
	.gip-table tr { border-bottom: 1px solid var(--gip-border); padding: 10px 14px; }
	.gip-table td { border: none; padding: 6px 0; }
	.gip-table td::before {
		content: attr(data-label);
		display: block;
		font-weight: 600;
		font-size: 11px;
		text-transform: uppercase;
		color: var(--gip-text-muted);
	}
}

@media (max-width: 480px) {
	.gip-page-head { flex-direction: column; align-items: flex-start; }
	.gip-page-head-actions { flex-direction: column; }
	.gip-form-actions { flex-direction: column; }
	.gip-form-actions .gip-btn { width: 100%; justify-content: center; }
	.gip-indicador-row { flex-direction: column; align-items: flex-start; gap: 6px; }
}
