/* =====================================================================
   RH Multiempresa - Estilos base do layout administrativo
   Tema claro/escuro via CSS variables (atributo data-theme no <html>)
   ===================================================================== */

:root[data-theme="light"] {
    --bg-body: #f4f6f9;
    --bg-surface: #ffffff;
    --bg-sidebar: #1f2937;
    --bg-sidebar-hover: #374151;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-inverse: #f9fafb;
    --border-color: #e5e7eb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
    --bg-body: #111827;
    --bg-surface: #1f2937;
    --bg-sidebar: #0b1120;
    --bg-sidebar-hover: #1f2937;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-inverse: #f9fafb;
    --border-color: #374151;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    transition: background-color 0.2s ease, color 0.2s ease;
}

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

/* ---------- Layout geral ---------- */
.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: 60px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: var(--shadow);
}

.app-topbar-title {
    font-weight: 600;
    font-size: 1.1rem;
    flex: 1;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-user-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
}

.btn-icon:hover {
    background-color: var(--bg-body);
}

.app-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    background-color: var(--bg-sidebar);
    color: var(--text-inverse);
    transition: margin-left 0.25s ease, width 0.25s ease, padding 0.25s ease;
}

.app-sidebar.collapsed {
    width: 80px;
}

.app-sidebar.collapsed .app-sidebar-brand {
    justify-content: center;
    padding: 20px 8px;
}

.app-sidebar.collapsed .app-sidebar-brand span,
.app-sidebar.collapsed .nav-label {
    display: none;
}

.app-sidebar.collapsed .app-sidebar-nav a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.app-sidebar.collapsed .app-sidebar-nav a .nav-icon {
    margin-right: 0;
}

.app-sidebar.collapsed .app-sidebar-nav a:hover,
.app-sidebar.collapsed .app-sidebar-nav a.active {
    text-align: center;
}

.app-sidebar-brand {
    padding: 20px 16px;
    font-weight: 700;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-sidebar-brand-logo {
    display: block;
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.app-sidebar-brand-icon {
    font-size: 1.25rem;
    color: #60a5fa;
}

.app-sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.app-sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(249, 250, 251, 0.85);
    font-size: 0.95rem;
}

.app-sidebar-nav a:hover,
.app-sidebar-nav a.active {
    background-color: var(--bg-sidebar-hover);
    color: #ffffff;
}

.nav-icon {
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    opacity: 0.9;
}

.app-sidebar-nav a.active .nav-icon,
.app-sidebar-nav a:hover .nav-icon {
    opacity: 1;
}

/* ---------- Conteudo ---------- */
.app-content {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    color: var(--text-primary);
}

.stat-card {
    padding: 20px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.chart-card {
    min-height: 340px;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.chart-card > h2,
.chart-card > p {
    flex-shrink: 0;
}

.chart-container {
    position: relative;
    height: 260px;
    flex: 1 1 auto;
    width: 100%;
}

.chart-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 2rem;
    color: var(--text-secondary);
    background-color: var(--bg-surface);
    border-radius: 8px;
}

.table {
    color: var(--text-primary);
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, #000000 0%, #111111 45%, #1a1a1a 100%);
}

.login-page-panel {
    flex: 1;
    display: none;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    color: #f8fafc;
    background: linear-gradient(180deg, #121212 0%, #0a0a0a 60%, #070707 100%);
    box-shadow: inset 0 0 60px rgba(255, 255, 255, 0.03), inset 0 0 120px rgba(0, 0, 0, 0.45), 0 0 50px rgba(0, 0, 0, 0.35);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.login-page-panel h2,
.login-page-panel p,
.login-features,
.login-features li {
    display: none;
}

.login-page-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    background: #000;
    font-style: italic;
}

.login-theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.login-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 36px;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 18px;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: 0;
    font-size: 0.92rem;
}

.login-input-group {
    position: relative;
}

.login-input-group .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1rem;
    pointer-events: none;
}

.login-input-group .form-control {
    padding-left: 42px;
    height: 46px;
    border-radius: 10px;
}

.login-card .btn-primary {
    height: 46px;
    border-radius: 10px;
    font-weight: 600;
    margin-top: 4px;
    background-color: #000;
    border-color: #000;
    color: #fff;
}

.login-card .btn-primary:hover,
.login-card .btn-primary:focus {
    background-color: #111;
    border-color: #111;
    color: #fff;
}

.login-footer-note {
    text-align: center;
    margin-top: 20px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

@media (min-width: 992px) {
    .login-page-panel {
        display: flex;
        max-width: 52%;
    }

    .login-page-form {
        background: var(--bg-body);
        border-top-left-radius: 28px;
        border-bottom-left-radius: 28px;
        box-shadow: -12px 0 40px rgba(0, 0, 0, 0.15);
    }
}

@media (max-width: 991px) {
    .login-page {
        background: var(--bg-body);
    }

    .login-page-form {
        width: 100%;
    }

    .login-theme-toggle {
        background: var(--bg-surface);
        border-color: var(--border-color);
        color: var(--text-primary);
    }
}

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-body);
    padding: 16px;
}

.form-control,
.form-select {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* ---------- Responsivo ---------- */
@media (max-width: 768px) {
    .app-sidebar {
        position: fixed;
        top: 60px;
        bottom: 0;
        left: 0;
        z-index: 30;
        margin-left: -240px;
        box-shadow: var(--shadow);
    }

    .app-sidebar.open {
        margin-left: 0;
    }

    .app-content {
        padding: 16px;
    }
}
