/* ========================================================================== */
/* 1. GLOBAL STYLES & VARIABLES */
/* ========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap");

:root {
    --primary-color: #3b82f6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --dark-color: #1f2937;
    --text-color-light: #6b7280;
    --white-color: #ffffff;
    --border-color: #e5e7eb;
    --border-radius: 12px;
    --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --box-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition-speed: 0.2s;
    
    --sidebar-width-collapsed: 80px;
    --sidebar-width-expanded: 260px;
    --header-height: 60px;
}

/* Reset Básico */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========================================================================== */
/* 2. LAYOUT PRINCIPAL (WRAPPER & SIDEBAR) */
/* ========================================================================== */

/* Sidebar Fixa */
#sidebar_id {
    background: #111827;
    width: var(--sidebar-width-collapsed);
    height: calc(100% - var(--header-height));
    position: fixed; 
    top: var(--header-height); 
    left: 0; 
    z-index: 1002;
    overflow-y: auto;
}

/* Sidebar Menu Items */
#sidebar_id .sidebar__user-avatar {
    padding: 15px 5px;
    text-align: center;
    border-bottom: 1px solid #444;
}
#sidebar_id .sidebar__user-avatar img {
    width: 50px; height: 50px; border-radius: 50%; border: 2px solid #fff; object-fit: cover;
}
#sidebar_id .sidebar__menu {
    display: flex; flex-direction: column; align-items: center; padding-top: 10px;
}
#sidebar_id .sidebar__link {
    width: 55px; height: 45px; color: #8aa4af; display: flex; align-items: center;
    justify-content: center; margin: 2px auto; text-decoration: none;
    position: relative; border-radius: 8px; transition: background-color 0.2s;
}
#sidebar_id .sidebar__link:hover { background-color: #2c3b41; color: #fff; }
#sidebar_id .sidebar__link i { font-size: 22px; transition: all 0.2s; }
#sidebar_id .sidebar__link .NavMenuUser { display: none; }

/* Navbar Fixa */
nav#navbar_id {
    background-color: #1f2937;
    height: var(--header-height);
    color: white;
    position: fixed; 
    top: 0; 
    width: 100%; 
    z-index: 1000;
    display: flex; 
    justify-content: space-between; /* Ajustado para distribuir elementos */
    align-items: center; 
    padding: 0 0px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Ajustes Navbar internos */
.header-logo { display: flex; align-items: center; justify-content: center; height: 100%; padding-left: 15px; }
.header-logo a { display: flex; align-items: center; text-decoration: none; position: static; width: auto; }
nav#navbar_id .navebar__rigth { display: flex; align-items: center; gap: 15px; position: relative; padding-right: 20px; }
nav#navbar_id .cabecario_img_login { border-radius: 50%; width: 40px; height: 40px; border: 2px solid #fff; object-fit: cover; }
nav#navbar_id .grid_global_User_empresa { display: flex; flex-direction: column; align-items: flex-start; }
nav#navbar_id .LoginUser { font-weight: 700; margin: 0; color: white; font-size: 0.9rem; }
nav#navbar_id .empresa_razao_social_login { font-size: 12px; color: #ccc; }
nav#navbar_id .header-online-status { display: flex; align-items: center; gap: 5px; font-size: 12px; color: #2ecc71; }
nav#navbar_id .header-online-status .fa-circle { font-size: 10px; }
#header-user-trigger { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 10px; border-radius: 8px; transition: background-color 0.2s; background-color: rgba(255, 255, 255, 0.05); }
#header-user-trigger:hover { background-color: rgba(255, 255, 255, 0.15); }
.header-separator { width: 1px; height: 35px; background-color: rgba(255, 255, 255, 0.15); }
.user-name-online-wrapper { display: flex; align-items: center; gap: 10px; }
#header-user-trigger .header-chevron { color: #ccc; font-size: 16px; margin-left: 5px; transition: transform 0.2s ease; }

/* ISOLAMENTO TOTAL DA CLASSE .user-list-page-wrapper 
   Usa !important para sobrescrever qualquer CSS externo conflitante.
*/
.user-list-page-wrapper {
    /* Posição e Margem Top: Garante que comece EXATAMENTE abaixo do header */
    margin-top: var(--header-height) !important;
    
    /* Padding Top: ZERADO forçosamente para encostar o conteúdo */
    padding-top: 0 !important;
    
    /* Margens laterais */
    margin-left: var(--sidebar-width-collapsed) !important;
    margin-right: 0 !important;
    margin-bottom: 0 !important;

    /* Paddings laterais/inferior (ajustável conforme gosto, mas Top é 0) */
    padding-right: 2rem;
    padding-bottom: 2rem;
    padding-left: 2rem;

    /* Comportamento */
    box-sizing: border-box !important;
    width: auto; 
    max-width: 100%;
    position: relative;
    display: block;
}

/* Mantendo suporte para o ID legado caso ainda seja usado */
#app-main-content {
    margin-top: var(--header-height) !important;
    padding-top: 0 !important;
    margin-left: var(--sidebar-width-collapsed) !important;
    box-sizing: border-box !important;
    width: auto;
    max-width: 100%;
}

/* SEGURANÇA EXTRA: Garante que o título ou primeiro elemento não empurre para baixo */
.user-list-page-wrapper > h1:first-child,
.user-list-page-wrapper > div:first-child,
#app-main-content > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* ========================================================================== */
/* 3. PAGE HEADER & CONTROLS */
/* ========================================================================== */
.page-header {
    display: flex; flex-direction: column; gap: 1.5rem; padding: 1.5rem;
    background-color: var(--white-color); border-radius: var(--border-radius);
    border: 1px solid rgba(0,0,0,0.02); margin-bottom: 2rem;
    box-shadow: var(--box-shadow);
    /* Garante que se for o primeiro elemento, encoste no topo */
    margin-top: 0 !important;
}

.header-top-row, .header-bottom-row {
    display: flex; flex-wrap: wrap; align-items: center;
    justify-content: space-between; width: 100%; gap: 1rem;
}

.search-title {
    font-size: 1.5rem; font-weight: 800; color: #111827; margin: 0; letter-spacing: -0.025em;
}

/* Stats */
.header-stats {
    display: flex; align-items: center; gap: 1.5rem;
    background: #f9fafb; padding: 0.5rem 1rem; border-radius: 8px;
    flex-wrap: wrap; 
}
.stat-item {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 0.85rem; font-weight: 600; color: var(--text-color-light);
}
.stat-item::before { content: ''; display: block; width: 8px; height: 8px; border-radius: 50%; }
.stat-item--active::before { background-color: var(--success-color); }
.stat-item--blocked::before { background-color: var(--danger-color); }
.stat-item .stat-count { color: var(--dark-color); font-weight: 800; }

/* Controls */
.header-left-controls { display: flex; align-items: center; gap: 1rem; flex-grow: 1; flex-wrap: wrap; }
.dropdown-filter { display: flex; align-items: center; gap: 0.75rem; }
.dropdown-filter label { font-weight: 600; color: #374151; font-size: 0.9rem; }
#status-filter-select {
    padding: 0.6rem 2.5rem 0.6rem 1rem; font-size: 0.9rem;
    border-radius: 8px; border: 1px solid var(--border-color);
    background-color: #fff; cursor: pointer; color: #374151; font-weight: 500;
}

/* Search */
.search-form-wrapper {
    position: relative; display: flex; align-items: center;
    background-color: #fff; border: 1px solid var(--border-color);
    border-radius: 8px; min-width: 320px; transition: all var(--transition-speed);
}
.search-form-wrapper:focus-within {
    border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.search-icon { position: absolute; left: 12px; color: #9ca3af; font-size: 0.9rem; }
#cards_usuario_inpult_busca {
    width: 100%; border: none; background: transparent;
    padding: 0.7rem 0.7rem 0.7rem 2.5rem; font-size: 0.95rem; outline: none; color: var(--dark-color);
}

/* Header Buttons */
.Conteiner_cards_user_controles { display: flex; gap: 0.75rem; }
.Conteiner_cards_user_controles > span {
    display: inline-flex; align-items: center; gap: 0.6rem; cursor: pointer;
    font-weight: 600; font-size: 0.9rem; padding: 0.6rem 1.2rem;
    border: 1px solid var(--border-color); border-radius: 8px;
    background: #fff; color: #374151; transition: all 0.2s;
}
.Conteiner_cards_user_controles > span:hover { background-color: #f9fafb; transform: translateY(-1px); }
#cards_new_user {
    background-color: var(--primary-color) !important; border-color: var(--primary-color) !important; color: white !important;
}
#cards_new_user:hover { background-color: #2563eb !important; }

/* Header Icons */
.Conteiner_cards_user_controles > span::before { font-family: FontAwesome; font-weight: normal; }
#cards_new_user::before { content: '\f067'; }
#cards_exporta_user::before { content: '\f019'; }
#cards_permicoes_user::before { content: '\f132'; }

/* ========================================================================== */
/* 4. CARD GRID SYSTEM */
/* ========================================================================== */
.conteiner_card_geraneral_user {
    display: grid;
    /* ATUALIZADO: Força 3 colunas em telas grandes, dividindo o espaço igualmente (1fr) */
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem; 
    padding-bottom: 2rem;
}

.card-wrapper {
    display: flex; flex-direction: column; background: var(--white-color);
    border-radius: var(--border-radius); box-shadow: var(--box-shadow);
    border: 1px solid rgba(255,255,255,0.5); overflow: hidden;
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; height: 100%;
}
.card-wrapper:hover { 
    transform: translateY(-5px);
    box-shadow: var(--box-shadow-hover) !important;
    z-index: 2; 
}

/* Status Bar */
.card_color_user {
    position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
    background: var(--success-color); z-index: 2;
    border-top-right-radius: 4px; border-bottom-right-radius: 4px;
}
.card-wrapper.status-bloqueado .card_color_user { background: var(--danger-color); }

/* Card Content */
.card_user {
    position: relative; display: flex; flex-direction: column;
    padding: 1.25rem 1.25rem 0.5rem 2rem; flex-grow: 1;
}
.box_codigo_avatar { display: flex; flex-direction: column; flex-grow: 1; }

.card_user_online_selec {
    display: flex; align-items: center; gap: 1.25rem; margin-bottom: 1.25rem;
}
.imgsrcuser {
    width: 68px; height: 68px; border-radius: 18px; object-fit: cover;
    border: 1px solid rgba(0,0,0,0.05); box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}
.NomeXEmailCardsUser { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.card_name_user span {
    font-size: 1.125rem; font-weight: 800; color: #111827;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.card_listuser_emails span {
    font-size: 0.875rem; color: #6b7280; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}

/* Footer Info */
.card_footer_info {
    margin-top: auto; padding-top: 1.25rem; border-top: 1px solid antiquewhite;
    display: flex; justify-content: space-between; align-items: center;
}
.card_bloquio_user {
    display: inline-flex; align-items: center; gap: 0.5rem;
    font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: 0.05em;
    background-color: #ecfdf5; color: #059669;
}
.card-wrapper.status-bloqueado .card_bloquio_user { background-color: #fef2f2; color: #dc2626; }
.card_avatar_user img { display: none; } 

.card_codigo_user { text-align: right; }
.title_cad_codigo { font-size: 0.65rem; text-transform: uppercase; color: #9ca3af; font-weight: 700; }
h3.card_text_cod { font-size: 1rem; color: #374151; margin: 0; font-family: 'Inter', monospace; }

/* ========================================================================== */
/* 5. BUTTON ACTION BAR */
/* ========================================================================== */
.butoes_form_list_user {
    display: flex;
    background-color: #f9fafb;
    border-top: 1px solid #e5e7eb;
    height: 52px;
    padding: 0 0.5rem;
    gap: 0.5rem;
    align-items: center;
}

.butoes_form_list_user > a,
.butoes_form_list_user > form,
.butoes_form_list_user > button {
    flex: 1; display: flex; justify-content: center; align-items: center;
    height: 36px; margin: 0; border: none; text-decoration: none;
}

.butoes_form_list_user button {
    flex: 1; height: 100%; background: transparent; border: none;
    color: #6b7280; cursor: pointer; font-size: 0.85rem; font-weight: 600;
    font-family: 'Inter', sans-serif; display: flex; align-items: center;
    justify-content: center; gap: 8px; border-radius: 6px; transition: all 0.2s ease;
}

.butoes_form_list_user button i { font-size: 1.1em; opacity: 0.8; }

.butoes_form_list_user > a:hover button,
.butoes_form_list_user > form:hover button {
    background-color: #e0e7ff; color: var(--primary-color); opacity: 1;
}
.butoes_form_list_user > a:hover button i,
.butoes_form_list_user > form:hover button i { opacity: 1; }

/* ========================================================================== */
/* 6. RESPONSIVIDADE & SCROLLBAR */
/* ========================================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }

/* --- 1440px / NOTEBOOKS --- */
@media (max-width: 1440px) {
    .conteiner_card_geraneral_user {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* --- 1024px / TABLETS LANDSCAPE --- */
@media (max-width: 1024px) {
    .conteiner_card_geraneral_user {
        grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
        gap: 1.5rem;
    }
}

/* --- TABLETS PORTRAIT (max 992px) --- */
@media (max-width: 992px) {
    .header-bottom-row { flex-direction: column; align-items: stretch; }
    .header-left-controls, .header-right-controls { flex-direction: column; width: 100%; }
    .search-form-wrapper { width: 100%; min-width: auto; }
    .Conteiner_cards_user_controles { width: 100%; flex-wrap: wrap; }
    .Conteiner_cards_user_controles > span { flex: 1 1 auto; justify-content: center; }
    
    .conteiner_card_geraneral_user {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 1.5rem;
    }
}

/* --- MOBILE (max 768px) --- */
@media (max-width: 768px) {
    /* Oculta Sidebar */
    #sidebar_id { display: none; }
    #secondary-menu { display: none; }

    /* Força isolamento também no mobile */
    .user-list-page-wrapper, #app-main-content {
        margin-left: 0 !important; 
        margin-top: var(--header-height) !important;
        padding-top: 0 !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        width: 100%;
    }
    
    nav#navbar_id { width: 100%; padding: 0 10px; }
    
    .page-header { padding: 1rem; }
    .header-stats { flex-direction: column; align-items: flex-start; }
}

/* --- MOBILE PEQUENO (max 480px) --- */
@media (max-width: 480px) {
    .Conteiner_cards_user_controles { flex-direction: column; }
    /* Mobile pequeno também com padding zero no topo */
    .user-list-page-wrapper, #app-main-content { padding: 0 0.5rem 0.5rem 0.5rem !important; }
    .conteiner_card_geraneral_user { grid-template-columns: 1fr; }
    
    nav#navbar_id .header-online-status { display: none; }
    nav#navbar_id .cabecario_img_login { display: none; }
}