/* =============================================
   Intranet RGC — Estilos Globais
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary:   #0d0d17;
    --bg-secondary: #141724;
    --bg-card:      #1a1f35;
    --bg-card-hover:#1f2540;
    --border:       #2a2f4a;
    --border-light: #353b5a;
    --text-primary: #f1f5f9;
    --text-secondary:#94a3b8;
    --text-muted:   #64748b;
    --accent:       #3872fa;
    --accent-hover: #2b61c2;
    --accent-glow:  rgba(56,114,250,0.25);
    --success:      #2a9d8f;
    --danger:       #ef4444;
    --warning:      #d9851f;
    --sidebar-w:    240px;
    --shadow:       0 4px 24px rgba(0,0,0,0.4);
}

/* ── Light mode ─────────────────────────── */
[data-theme="light"] {
    --bg-primary:   #f0f2f8;
    --bg-secondary: #ffffff;
    --bg-card:      #ffffff;
    --bg-card-hover:#f5f7ff;
    --border:       #dde1f0;
    --border-light: #c8cfe6;
    --text-primary: #0f1121;
    --text-secondary:#4a5568;
    --text-muted:   #8a94a6;
    --accent:       #3872fa;
    --accent-hover: #2b61c2;
    --accent-glow:  rgba(56,114,250,0.15);
    --success:      #2a9d8f;
    --danger:       #ef4444;
    --warning:      #d9851f;
    --shadow:       0 4px 24px rgba(0,0,0,0.08);
}

/* ── Botão theme toggle ──────────────────── */
.theme-toggle {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
    flex-shrink: 0;
    padding: 0;
}
.theme-toggle svg { display: block; pointer-events: none; }
.theme-toggle:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
    color: var(--accent);
}
/* Variante menor para dentro do login card */
.theme-toggle-sm {
    width: 30px; height: 30px;
    border-radius: 6px;
}

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

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Transição suave ao trocar tema */
body.theme-transitioning,
body.theme-transitioning *,
body.theme-transitioning *::before,
body.theme-transitioning *::after {
    transition:
        background-color 0.35s ease,
        color 0.35s ease,
        border-color 0.35s ease,
        box-shadow 0.35s ease !important;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Botões ──────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 7px 14px; font-size: 12px; width: auto; }

/* ── Inputs ──────────────────────────────── */
.input-group { position: relative; margin-bottom: 20px; }
.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}
.input-group input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-group input::placeholder { color: var(--text-muted); }
.input-wrapper {
    position: relative;
}
.input-wrapper input {
    padding-right: 44px;
}
.input-toggle-pass {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
.input-toggle-pass:hover { color: var(--text-secondary); }

/* ── Alert ───────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-danger  { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(42,157,143,0.15); border: 1px solid rgba(42,157,143,0.3); color: #6ee7b7; }

/* ── Badge ───────────────────────────────── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: rgba(42,157,143,0.2); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,0.2); color: var(--danger); }
.badge-accent  { background: rgba(56,114,250,0.2); color: var(--accent); }

/* ══════════════════════════════════════════
   LOGIN
   ══════════════════════════════════════════ */
.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}
.login-bg::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(56,114,250,0.12) 0%, transparent 70%);
    top: -100px; right: -100px;
    pointer-events: none;
}
.login-bg::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(42,157,143,0.08) 0%, transparent 70%);
    bottom: -80px; left: -80px;
    pointer-events: none;
}
.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo img { height: 100px; object-fit: contain; transition: filter 0.35s ease; }
.sidebar-logo img { transition: filter 0.35s ease; }

/* Logo branca some no fundo claro — inverte para ficar escura */
[data-theme="light"] .login-logo img,
[data-theme="light"] .sidebar-logo img {
    filter: brightness(0) saturate(0) invert(0.15);
}
.login-logo .logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
}
.login-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}
.login-step { transition: opacity 0.25s, transform 0.25s; }
.login-step.hidden { display: none; }
.login-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 20px;
    padding: 0;
}
.login-back:hover { color: var(--text-primary); }
.login-user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}
.login-user-chip span { font-weight: 500; color: var(--text-primary); }

/* ══════════════════════════════════════════
   LAYOUT PRINCIPAL (DASHBOARD + ADMIN)
   ══════════════════════════════════════════ */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s;
}
.sidebar-logo {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: center;
    align-items: center;
}
.sidebar-logo img { height: 64px; width: 100%; max-width: 160px; object-fit: contain; }
.sidebar-logo .logo-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}
.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 12px 20px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-item:hover { background: rgba(56,114,250,0.08); color: var(--text-primary); }
.nav-item.active { background: rgba(56,114,250,0.12); color: var(--accent); border-left-color: var(--accent); }
.nav-item .icon { font-size: 18px; width: 20px; text-align: center; }
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.sidebar-avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px;
    color: var(--text-muted);
}

/* Main */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.topbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}
.topbar-search input {
    width: 100%;
    padding: 9px 16px 9px 38px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.topbar-search input:focus { border-color: var(--accent); }
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 14px;
}
.topbar-spacer { flex: 1; }

/* Content */
.content { padding: 32px; flex: 1; }
.page-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}
.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 28px;
}

/* ── App Cards (Dashboard) ─────────────────── */
.section-block { margin-bottom: 40px; }
.section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.app-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}
.app-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-color, var(--accent));
    opacity: 0;
    transition: opacity 0.2s;
}
.app-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    color: var(--text-primary);
}
.app-card:hover::before { opacity: 1; }
.app-icon {
    width: 56px; height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    background: var(--card-color, var(--accent));
    background: linear-gradient(135deg, var(--card-color, var(--accent)), rgba(0,0,0,0.2));
}
.app-icon img { width: 36px; height: 36px; object-fit: contain; }
.app-name {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}
.app-desc {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.4;
}
.app-card.hidden { display: none; }

/* ── Tables (Admin) ──────────────────────── */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}
.table-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.table-header h3 { font-size: 16px; font-weight: 600; }
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    padding: 12px 20px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border);
}
td {
    padding: 14px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(42,47,74,0.5);
    vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(56,114,250,0.04); }
.td-name { font-weight: 600; color: var(--text-primary); }
.td-actions { display: flex; gap: 8px; }
.table-search {
    padding: 8px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    outline: none;
    width: 220px;
}
.table-search:focus { border-color: var(--accent); }
.table-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Modal ───────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 24px;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}
.modal-close {
    position: absolute;
    top: 16px; right: 20px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
}

/* ── Stats cards (admin dashboard) ──────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    background: rgba(56,114,250,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Toggle switch ───────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-light);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: #fff;
    left: 3px; top: 3px;
    transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Responsive ──────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .content { padding: 20px; }
    .apps-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Spinner ─────────────────────────────── */
.spinner {
    width: 20px; height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Select ──────────────────────────────── */
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}
select:focus { border-color: var(--accent); }
select option { background: var(--bg-card); }

textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    outline: none;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s;
}
textarea:focus { border-color: var(--accent); }

/* ── Acesso Remoto: seção azul + sub-itens ── */
.nav-section-title.accent {
    color: var(--accent);
    opacity: 1;
}
.nav-item-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    user-select: none;
}
.nav-item-toggle:hover { background: rgba(56,114,250,0.08); color: var(--text-primary); }
.nav-item-toggle .chevron {
    margin-left: auto;
    transition: transform 0.2s;
    color: var(--text-muted);
    flex-shrink: 0;
}
.nav-item-toggle.open .chevron { transform: rotate(180deg); }
.nav-subitems {
    background: rgba(56,114,250,0.06);
    border-left: 3px solid var(--accent);
    margin: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}
.nav-subitems.open { max-height: 200px; }
.nav-subitem {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px 9px 36px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}
.nav-subitem:hover { background: rgba(56,114,250,0.1); color: var(--accent); }
.nav-subitem .os-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(56,114,250,0.15);
    color: var(--accent);
    margin-left: auto;
    white-space: nowrap;
    line-height: 1;
}

/* ── Configurações: SMTP inputs desabilitados ── */
input:disabled, select:disabled, textarea:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}
