:root {
    --bg: #0b1220;
    --bg-soft: #111a2e;
    --card: #ffffff;
    --text: #182235;
    --muted: #6b7280;
    --border: #dbe3ef;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --success-bg: #d1fae5;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --warning: #a16207;
    --warning-bg: #fef3c7;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.10);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top, rgba(37, 99, 235, 0.18), transparent 28%),
        linear-gradient(180deg, #f4f7fb 0%, #eef3f8 100%);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(17, 26, 46, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.2px;
    font-size: 1.05rem;
}

.nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.nav a {
    color: #dbe7ff;
    padding: 8px 12px;
    border-radius: 999px;
    transition: 0.18s ease;
    font-size: 0.95rem;
}

.nav a:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #fff;
}

.nav a.active {
    background: #fff;
    color: var(--bg);
    font-weight: 700;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px 40px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 18px;
}

.card h1,
.card h2,
.card h3,
.card p {
    margin-top: 0;
}

.subtitle {
    color: var(--muted);
    margin-top: 6px;
    margin-bottom: 0;
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.button-link,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 10px 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
    font-size: 0.95rem;
}

.button-link {
    background: var(--primary);
    color: #fff;
}

.button-link:hover,
button:hover,
input[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.button-link.secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.button-link.danger {
    background: var(--danger);
    color: #fff;
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 11px 12px;
    font-size: 0.96rem;
    background: #fff;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(37, 99, 235, 0.75);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 0.95rem;
}

.alert.error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(185, 28, 28, 0.18);
}

.alert.success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(5, 150, 105, 0.18);
}

.alert.warning {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(161, 98, 7, 0.18);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
}

th, td {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

th {
    background: #f7f9fc;
    font-size: 0.9rem;
}

tr:hover td {
    background: #fafcff;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
}

.badge.online {
    background: var(--success-bg);
    color: var(--success);
}

.badge.offline {
    background: var(--danger-bg);
    color: var(--danger);
}

#search-clp {
    margin-bottom: 12px;
}

#clp-status-info {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 14px;
}

.clp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}

.clp-card {
    background: linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
    transition: 0.18s ease;
    display: block;
}

.clp-card:hover {
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.14);
}

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

.clp-card h3 {
    font-size: 1rem;
    line-height: 1.25;
    margin: 0;
}

.clp-card p {
    color: var(--muted);
    font-size: 0.88rem;
    margin: 0;
    line-height: 1.35;
}

.status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.74rem;
    font-weight: 800;
    white-space: nowrap;
}

.status.online {
    background: var(--success-bg);
    color: var(--success);
}

.status.offline {
    background: var(--danger-bg);
    color: var(--danger);
}

.hidden {
    display: none !important;
}

@media (max-width: 720px) {
    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
    }

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

    .page {
        padding: 18px 14px 30px;
    }
}


/* Estilos para o campo de senha com ícone de olho */
.password-container {
    position: relative;
    width: 100%;
}

.password-container input[type="password"],
.password-container input[type="text"] {
    width: 100%;
    padding-right: 44px; /* espaço para o ícone dentro do campo */
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    height: 100%;
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--muted);
    font-size: 1.05rem;
    z-index: 2;
}

.password-toggle:hover {
    color: var(--text);
}

/* Para links de CLP desabilitados na dashboard */
.clp-card.disabled-link {
    opacity: 0.6;
    pointer-events: none; /* Desabilita cliques */
    cursor: not-allowed;
}

.clp-card .permission-badge {
    font-size: 0.75em;
    color: #888;
    margin-top: 5px;
}

.card-actions {
    display: flex;
    justify-content: flex-end; /* Alinha o badge à direita */
    margin-top: 12px; /* Espaçamento acima do badge */
    width: 100%; /* Garante que o div ocupe toda a largura do card */
}

.drive-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: 0.2s ease;
    user-select: none;
}

.drive-badge i {
    font-size: 1rem;
}

.drive-badge-disabled {
    background: #eef2f7;
    color: #6b7280;
    border: 1px solid #d1d5db;
    cursor: not-allowed;
    opacity: 0.75;
}

.drive-badge-disabled:hover {
    opacity: 0.9;
    transform: none; /* Garante que não haja efeito de hover */
}

/* Estilos das abas */
.tabs-nav {
    display: flex;
    gap: 4px;
    margin: 16px 0 8px;
    border-bottom: 2px solid var(--border, #333);
}
.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 0.95em;
    border-bottom: 3px solid transparent;
    transition: opacity 0.15s, border-color 0.15s;
}
.tab-btn:hover {
    opacity: 0.85;
}
.tab-btn.active {
    opacity: 1;
    border-bottom-color: var(--primary); /* Usando a variável --primary do seu :root */
    font-weight: bold;
}
/* Use 'hidden' para ocultar o conteúdo da aba, para melhor acessibilidade e controle */
.tab-content[hidden] {
    display: none !important;
}

/* Estilos de tabela genéricos (alguns já existem, mas vamos garantir que os específicos estejam aqui) */
/* O bloco 'table-wrap' e 'table' já existem no seu style.css, então vamos focar nos específicos */

/* Estilos específicos da tabela de usuários (col-id, col-user, etc.) */
/* Note: Se você já tem regras para 'table' e 'th, td' no seu style.css,
   certifique-se de que estas regras mais específicas não entrem em conflito ou as sobrescrevam adequadamente. */
.table-wrap table {
    min-width: 860px; /* Mantido do admin.html original */
    table-layout: fixed;
}
.table-wrap thead th {
    position: sticky;
    top: 0;
    background: var(--card); /* Usando a variável --card do seu :root */
    z-index: 1;
    white-space: nowrap;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}
.table-wrap tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border); /* Ajustado para usar --border */
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.col-id     { width: 48px; }
.col-user   { width: 200px; }
.col-name   { width: 180px; }
.col-group  { width: 100px; }
.col-status { width: 90px; }
.col-seen   { width: 160px; }
.col-ip     { width: 120px; }
.col-action { width: 160px; }
/* Os estilos para .badge, .badge.online, .badge.offline já existem no seu style.css,
   então não precisam ser duplicados aqui. */
.badge.never   { background-color: #adb5bd; color: #333; } /* Adicionado, se não existir */


/* Estilos de formulário e switches (copiados de admin_user_permissions.html) */
.disabled-row {
    opacity: 0.5;
    cursor: not-allowed;
}
.permission-select {
    min-width: 180px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border); /* Usando a variável --border */
    background: var(--card); /* Usando a variável --card */
}
.security-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px 24px;
    margin: 16px 0 24px;
    padding: 16px;
    border: 1px solid var(--border); /* Usando a variável --border */
    border-radius: var(--radius); /* Usando a variável --radius */
}
.switch-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.switch-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}
.field-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.field-row input[type="number"] {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border); /* Usando a variável --border */
    background: var(--card); /* Usando a variável --card */
    max-width: 220px;
}
.field-row.read-only {
    justify-content: center;
    color: var(--muted); /* Usando a variável --muted */
}

.form-actions-bottom {
    display: flex;
    justify-content: space-between; /* Alinha o primeiro item à esquerda e o último à direita */
    align-items: center;
    margin-top: 20px; /* Espaçamento acima dos botões */
    gap: 10px; /* Espaçamento entre os botões, se houver mais de um */
}


/* ======================================= base.html ======================================= */
	.topbar-inner {
		box-sizing: border-box;
		width: 100%;
		max-width: 1100px;
		margin: 0 auto;
		padding: 28px 24px 16px;

		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: flex-start;
		gap: 18px;
	}

	.topbar .brand {
		display: block;
		align-self: center;
		margin: 0 !important;
		text-align: center;
	}

	/* Segunda linha: boas-vindas + navegação */
	.topbar-user-row {
		display: flex;
		align-items: center;
		justify-content: center;
		gap: 28px;
		width: 100%;
	}

	/* Texto de boas-vindas e ícone */
	.user-summary {
		display: flex;
		align-items: center;
		gap: 12px;
		white-space: nowrap;
	}

	.welcome-message {
		color: #d1d5db;
		font-size: 16px;
		line-height: 1.2;
	}

	.topbar .user-profile-link {
		display: inline-flex;
		align-items: center;
		justify-content: center;

		color: #cbd5e1;
		font-size: 30px;
		line-height: 1;
		text-decoration: none;
		transition: color 0.2s ease, transform 0.2s ease;
	}

	.topbar .user-profile-link:hover {
		color: #ffffff;
		transform: scale(1.08);
	}

	/* Navegação na mesma linha do usuário */
	.topbar-user-row .nav {
		display: flex;
		align-items: center;
		justify-content: center;

		width: auto;
		margin: 0;
		gap: 8px;

		/* Impede a regra antiga de ocupar todo o espaço */
		flex: 0 0 auto !important;
	}

	.topbar-user-row .nav a {
		display: inline-flex;
		align-items: center;
		white-space: nowrap;
	}

	/* Ajuste para telas menores */
	@media (max-width: 720px) {
		.topbar-inner {
			padding: 22px 16px 14px;
		}

		.topbar-user-row {
			flex-wrap: wrap;
			gap: 14px;
		}

		.welcome-message {
			font-size: 14px;
		}
	}
/* ======================================= base.html ======================================= */