/* Dashboard specific styles */

/* Debug panel */
.debug-panel {
        background: #f8f9fa;
        border: 2px solid #007bff;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 20px;
        font-family: monospace;
}

.debug-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 15px;
        padding-bottom: 10px;
        border-bottom: 1px solid #dee2e6;
}

.debug-header h4 {
        margin: 0;
        color: #007bff;
        font-size: 16px;
}

.debug-toggle,
.debug-btn {
        background: #007bff;
        color: white;
        border: none;
        padding: 6px 12px;
        border-radius: 4px;
        cursor: pointer;
        font-size: 12px;
        margin: 0 5px;
        transition: background 0.2s ease-in-out;
}

.debug-toggle:hover,
.debug-btn:hover {
        background: #0056b3;
}

.debug-controls {
        text-align: center;
        margin-bottom: 15px;
}

.debug-content {
        background: white;
        padding: 12px;
        border-radius: 4px;
        border: 1px solid #e9ecef;
}

.debug-item {
        display: flex;
        justify-content: space-between;
        padding: 5px 0;
        border-bottom: 1px solid #f8f9fa;
        font-size: 13px;
}

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

.debug-item strong {
        color: #495057;
        min-width: 120px;
}

.debug-item span {
        color: #6c757d;
        word-break: break-word;
        text-align: right;
        flex: 1;
        margin-left: 10px;
}

.debug-error {
        color: #dc3545 !important;
        font-weight: bold;
}

.loading-details {
        margin-top: 15px;
        color: #6c757d;
        font-style: italic;
}

/* Common states */
.loading-content {
        text-align: center;
        padding: 40px 20px;
}

.loader {
        color: var(--color-primary);
        font-size: 16px;
        padding: 20px;
}

.loader:before {
        content: "⌛";
        animation: spin 2s linear infinite;
        margin-right: 8px;
}

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

.error-content {
        text-align: center;
        padding: 40px 20px;
}

.error-message {
        background: #ffebee;
        border: 1px solid #ffcdd2;
        border-radius: 8px;
        padding: 20px;
        color: #c62828;
        max-width: 400px;
        margin: 0 auto;
}

.error-message h3 {
        margin-top: 0;
        color: #d32f2f;
}

.retry-btn {
        background: var(--color-primary);
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 14px;
        margin-top: 15px;
        transition: background 0.2s ease-in-out;
}

.retry-btn:hover {
        background: var(--color-primary-hover);
}

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

.dashboard-header h2 {
        color: var(--color-text-default, #333);
        margin-bottom: 8px;
}

.dashboard-subtitle {
        color: var(--color-text-muted, #666);
        font-size: 16px;
}

/* Modules */
.modules-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 20px;
        margin-top: 20px;
}

.module-card {
        position: relative;
        background: var(--color-bg-white, #fff);
        border-radius: 12px;
        padding: 24px;
        box-shadow: var(--sig-shadow-card, 0 1px 3px rgba(0, 0, 0, 0.08));
        cursor: pointer;
        transition: transform 0.18s ease, box-shadow 0.18s ease;
        border: 1px solid var(--sig-border-color-light, #e9ecef);
}

.module-card:hover {
        transform: translateY(-2px);
        box-shadow: var(--sig-shadow-dropdown, 0 4px 16px rgba(0, 0, 0, 0.12));
}

.module-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 48px;
        margin-bottom: 16px;
        text-align: center;
}

.module-icon i {
        font-size: 48px;
        color: inherit;
}

.module-icon-image {
        max-width: 100%;
        max-height: 48px;
        object-fit: contain;
}

.module-icon-emoji {
        font-size: 48px;
        line-height: 1;
        display: inline-block;
}

.module-icon-fallback {
        display: inline-block;
        font-size: 36px;
        color: #666;
}

.module-title {
        font-size: 18px;
        font-weight: bold;
        color: var(--color-text-default, #333);
        margin-bottom: 8px;
        text-align: center;
}

.module-description {
        font-size: 14px;
        color: var(--color-text-muted, #666);
        text-align: center;
        line-height: 1.4;
}

.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);
}

/* Dashboard inicial: pendencia dentro do card (estilo situacao/area) */
.module-card .notification-badge {
        top: 5px;
        right: 5px;
        left: auto;
        bottom: auto;
        inset: auto;
        width: 28px;
        height: 28px;
        min-width: 28px;
        padding: 0;
        border-radius: 6px;
        background: #e53935;
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        box-shadow: none;
        z-index: 3;
}

/* Situations/Areas — padrao identico ao ABC do SigSistem (abc.painel.css) */
.situations-grid,
.areas-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
	gap: 12px;
	margin-top: 14px;
}

.situation-card,
.area-card,
.sig-abc-card {
	/* Espelha sigsistem/abc.painel.css — accent = fundo solido de producao */
	--sig-abc-accent: #adb5bd;
	--sig-abc-bg: color-mix(in srgb, var(--sig-abc-accent) 10%, #fff);
	--sig-abc-bg-hover: color-mix(in srgb, var(--sig-abc-accent) 30%, #fff);
	position: relative;
	display: flex;
	flex-direction: column;
	min-height: 76px;
	padding: 8px 10px 8px 26px;
	background: var(--sig-abc-bg);
	border: 0 !important;
	border-radius: 10px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
	transition: background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
	cursor: pointer;
	box-sizing: border-box;
	overflow: hidden;
	text-align: left;
	color: #0f172a;
}

/* Trilho = cor solida (ex.: #CFCFC4 Em Rascunho). 8px padrao; 16px se .item-active */
.sig-abc-card::before,
.situation-card::before,
.area-card::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 8px;
	height: 100%;
	background: var(--sig-abc-accent);
	border-radius: 54px 0 0 54px;
	pointer-events: none;
	z-index: 1;
}

.sig-abc-card.item-active::before,
.situation-card.item-active::before,
.area-card.item-active::before {
	width: 16px;
}

.sig-abc-card.item-active,
.situation-card.item-active,
.area-card.item-active {
	background: color-mix(in srgb, var(--sig-abc-accent) 20%, #fff);
	box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
}

.sig-abc-card__rail {
	display: none;
}

.situation-card:hover,
.area-card:hover,
.sig-abc-card:hover {
	background: var(--sig-abc-bg-hover);
	box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
	transform: translateY(-2px);
}

.sig-abc-card__top {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 6px;
	position: relative;
	z-index: 2;
}

.sig-abc-card__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	position: relative;
	width: 24px;
	height: 24px;
	border-radius: 6px;
	background: color-mix(in srgb, var(--sig-abc-accent) 12%, #fff);
	color: var(--sig-abc-accent);
	font-size: 12px;
	line-height: 1;
	overflow: hidden;
}

/* Com pendencias: bolinha cobre o icone por completo */
.sig-abc-card__icon.has-pendency {
	background: #e53935;
	color: #fff;
	overflow: visible;
}

.sig-abc-card__icon .notification-badge,
.situation-card .sig-abc-card__icon .notification-badge {
	position: absolute;
	inset: 0;
	top: 0;
	right: 0;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
	min-width: 0;
	min-height: 0;
	margin: 0;
	border-radius: 6px;
	background: #e53935;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	box-shadow: none;
	z-index: 2;
}

.sig-abc-card__num,
.card-value,
.area-number {
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
	margin: 0;
	padding: 1px 0;
	flex: 1;
	min-width: 0;
	color: var(--sig-abc-num, #0f172a) !important;
	font-variant-numeric: tabular-nums;
	letter-spacing: -0.02em;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	text-transform: none;
	position: relative;
	z-index: 2;
}

.sig-abc-card__lbl,
.card-label,
.area-label {
	font-size: 12px;
	font-weight: 700;
	line-height: 1.2;
	margin-top: 4px;
	min-height: 0;
	flex: 1;
	color: var(--sig-abc-lbl, #64748b) !important;
	overflow: hidden;
	text-transform: none;
	position: relative;
	z-index: 2;
}

.area-card,
.sig-abc-card--compact {
	flex-direction: row;
	align-items: center;
	flex-wrap: wrap;
	gap: 4px 6px;
	min-height: 48px;
	padding: 6px 8px 6px 22px;
}

.area-card .sig-abc-card__num,
.area-card .area-number,
.sig-abc-card--compact .sig-abc-card__num {
	font-size: 18px;
	margin-top: 0;
	flex: 0 0 auto;
}

.area-card .sig-abc-card__lbl,
.area-card .area-label,
.sig-abc-card--compact .sig-abc-card__lbl {
	font-size: 11px;
	min-height: 0;
	margin-top: 0;
	flex: 1;
	min-width: 0;
}

.area-card .sig-abc-card__icon,
.sig-abc-card--compact .sig-abc-card__icon {
	margin-left: auto;
}

.situation-card .notification-badge,
.area-card .notification-badge {
	top: 4px;
	right: 4px;
	width: 22px;
	height: 22px;
	font-size: 10px;
	z-index: 3;
}

.situation-card .sig-abc-card__icon .notification-badge,
.area-card .sig-abc-card__icon .notification-badge {
	top: 0;
	right: 0;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 100%;
}

@media only screen and (max-width: 576px) {
	.situations-grid,
	.areas-grid {
		grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	}
	.sig-abc-card__num,
	.card-value {
		font-size: 22px;
	}
}

/* Occurrences */
.occurrences-container {
	background: white;
	border-radius: 6px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.1);
	margin-top: 20px;
	border: 1px solid #e9ecef;
	overflow: visible;
}

.table-responsive {
	width: 100%;
	overflow: visible;
}


/* Filtro dinamico da grade de ocorrencias */
.grid-filter-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 10px 12px;
	background: #f5f7fa;
	border: none;
	border-bottom: 1px solid #e9ecef;
	border-radius: 0;
	position: sticky;
	top: 66px; /* abaixo do .header sticky do app, com folga visual */
	z-index: 40;
	box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.grid-filter-label {
	color: #051532;
	opacity: 0.7;
	flex-shrink: 0;
}
.grid-filter-input {
	flex: 1;
	min-width: 0;
	border: none;
	background: transparent;
	font-size: 14px;
	color: #222;
	outline: none;
	padding: 4px 0;
}
.grid-filter-input::placeholder {
	color: #8892a0;
}
.grid-filter-empty {
	text-align: center;
	padding: 20px 12px;
	color: #666;
	font-size: 13px;
	background: #fafafa;
	border-bottom: 1px solid #e9ecef;
	flex-shrink: 0;
}
.grid-summary-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 8px 10px;
	padding: 8px 10px;
	background: #fff;
	border-top: 1px solid #e9ecef;
	font-size: 11px;
	color: #495057;
	line-height: 1.3;
	flex-shrink: 0;
}
.grid-summary-stats {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px 8px;
	min-width: 0;
}
.grid-summary-item strong {
	font-weight: 700;
	color: #051532;
}
.grid-summary-sep {
	width: 1px;
	height: 11px;
	background: #ced4da;
	flex-shrink: 0;
}
.grid-pager {
	display: flex;
	gap: 6px;
	flex-shrink: 0;
}
.grid-pager-btn {
	border: 1px solid #ced4da;
	background: #f8f9fa;
	color: #051532;
	border-radius: 6px;
	padding: 5px 10px;
	font-size: 11px;
	font-weight: 600;
	cursor: pointer;
}
.grid-pager-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}
.grid-pager-btn:not(:disabled):active {
	background: #e9ecef;
}
.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.occurrences-table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        background: white;
}

.occurrences-table thead {
        background: #f8f9fa;
}

.header-cell {
        padding: 10px 6px;
        text-align: center;
        font-size: 12px;
        font-weight: bold;
        color: #495057;
        border-right: 1px solid #e9ecef;
        border-bottom: 1px solid #e9ecef;
        position: sticky;
        top: 110px; /* .header + folga (~66) + filtro (~44) */
        z-index: 35;
        background: #f8f9fa;
}

.header-cell:last-child {
        border-right: none;
}

.table-row {
        border-bottom: 1px solid #e9ecef;
        transition: background-color 0.2s ease;
}

.table-row:nth-child(even) {
        background: #f0f8ff;
}

.table-row:nth-child(odd) {
        background: white;
}

.table-row:hover {
        background: var(--color-primary-soft) !important;
}

.table-cell {
        padding: 10px 6px;
        text-align: center;
        font-size: 13px;
        color: #495057;
        border-right: 1px solid #e9ecef;
        position: relative;
}

.table-cell:last-child {
        border-right: none;
}

.file-icon {
        font-size: 18px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-right: 4px;
}

.file-icon i {
        font-size: 18px;
        color: inherit;
}

.status-badge,
.pendency-dot {
        position: absolute;
        top: 6px;
        right: 6px;
        width: 8px;
        height: 8px;
        background: #e53935;
        border-radius: 50%;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, 0.9);
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
        font-size: 0;
        line-height: 0;
        color: transparent;
        overflow: hidden;
        pointer-events: none;
}

/* Bolinha via CSS na linha - some ao remover .has-pendency ou com .pendency-seen */
.table-row.has-pendency td:last-child {
        position: relative;
}
.table-row.has-pendency td:last-child::after {
        content: "";
        position: absolute;
        top: 6px;
        right: 6px;
        width: 8px;
        height: 8px;
        background: #e53935;
        border-radius: 50%;
        border: 1px solid rgba(255, 255, 255, 0.9);
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
        pointer-events: none;
}
.table-row.pendency-seen td:last-child::after,
.table-row.pendency-seen .pendency-dot,
.table-row.pendency-seen .status-badge {
        display: none !important;
        content: none !important;
        width: 0 !important;
        height: 0 !important;
        opacity: 0 !important;
}

/* Modal */
.announcement-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1000;
        display: none;
}

.modal-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
}

.modal-content {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: white;
        border-radius: 8px;
        max-width: 90%;
        max-height: 80%;
        overflow: hidden;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        z-index: 1001;
}

.modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 20px;
        border-bottom: 1px solid #eee;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1;
}

.modal-header h3 {
        margin: 0;
        color: #333;
}

.modal-body {
        padding: 5px;
        line-height: 1.6;
}

.close-btn {
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        color: #666;
        padding: 0;
        width: 30px;
        height: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
}

.close-btn:hover {
        color: #333;
}

.announcement-iframe-container {
        position: relative;
        width: 100%;
        height: calc(80vh - 120px);
        min-height: 400px;
}

.announcement-iframe {
        width: 100%;
        height: 100%;
        border: none;
        border-radius: 4px;
        background: white;
}

.iframe-loading {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
        z-index: 1;
}

.iframe-fallback {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f8f9fa;
        border-radius: 4px;
}

.fallback-content {
        text-align: center;
        padding: 40px 20px;
        max-width: 400px;
}

.fallback-content h3 {
        color: #666;
        margin-bottom: 15px;
        font-size: 18px;
}

.fallback-content p {
        color: #888;
        margin-bottom: 25px;
        line-height: 1.5;
}

.fallback-btn {
        background: var(--color-primary);
        color: white;
        border: none;
        padding: 12px 20px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 14px;
        margin: 0 5px;
        transition: background 0.2s ease-in-out;
}

.fallback-btn:hover {
        background: var(--color-primary-hover);
}

.fallback-btn.secondary {
        background: #f5f5f5;
        color: #666;
        border: 1px solid #ddd;
}

.fallback-btn.secondary:hover {
        background: #e8e8e8;
}

/* Responsive tweaks */
@media (max-width: 768px) {
        .areas-grid {
                grid-template-columns: repeat(2, 1fr);
        }

        .occurrences-table {
                width: 100%;
                font-size: 10px;
        }

        .header-cell,
        .table-cell {
                padding: 4px 3px;
                font-size: 10px;
        }

        .status-badge,
        .pendency-dot,
        .table-row.has-pendency td:last-child::after {
                top: 4px;
                right: 4px;
                width: 7px;
                height: 7px;
        }

        .file-icon {
                font-size: 14px;
        }

        .modal-content {
                max-width: calc(100% - 40px);
                max-height: calc(100% - 60px);
                min-width: 280px;
                min-height: 300px;
                top: 30px;
                left: 20px;
                right: 20px;
                bottom: 30px;
                transform: none;
        }

        .announcement-iframe-container {
                height: calc(100vh - 200px);
                min-height: 250px;
        }
}

/* --- Dark mode (app) --- */
@media (prefers-color-scheme: dark) {
	.dashboard-header h2,
	.module-title,
	.page-content h2,
	.page-content h3 {
		color: var(--color-text-default);
	}
	.dashboard-subtitle,
	.module-description,
	.module-icon-fallback {
		color: var(--color-text-muted);
	}
	.error-message {
		background: #3a1c1c;
		border-color: #5c2b2b;
		color: #f5c2c2;
	}
	.error-message h3 {
		color: #ff8a80;
	}
	.situation-card,
	.area-card,
	.sig-abc-card {
		--sig-abc-bg: color-mix(in srgb, var(--sig-abc-accent) 14%, #1e1e1e);
		--sig-abc-bg-hover: color-mix(in srgb, var(--sig-abc-accent) 28%, #1e1e1e);
		--sig-abc-num: #e9ecef;
		--sig-abc-lbl: #adb5bd;
		background: var(--sig-abc-bg);
		box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
		color: #e9ecef;
	}
	.situation-card:hover,
	.area-card:hover,
	.sig-abc-card:hover {
		background: var(--sig-abc-bg-hover);
		box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
	}
	.sig-abc-card__num,
	.card-value,
	.area-number {
		color: var(--sig-abc-num) !important;
	}
	.sig-abc-card__lbl,
	.card-label,
	.area-label {
		color: var(--sig-abc-lbl) !important;
	}
	.sig-abc-card__icon {
		background: color-mix(in srgb, var(--sig-abc-accent) 22%, transparent);
		color: var(--sig-abc-accent);
	}
	.module-card {
		background: var(--color-bg-white);
		border-color: var(--sig-border-color);
	}
	.occurrences-container,
	.occurrences-table,
	.occurrences-table thead {
		background: var(--color-bg-white);
		color: var(--color-text-default);
	}
	.occurrences-table thead {
		background: var(--color-bg-muted);
		border-bottom-color: var(--sig-border-color);
	}
	.header-cell,
	.occurrences-table td {
		color: var(--color-text-default);
		border-color: var(--sig-border-color-light);
	}
	.grid-filter-bar {
		background: var(--color-bg-muted);
		border-bottom-color: var(--sig-border-color);
	}
	.header-cell {
		background: var(--color-bg-muted);
	}
}
