/* =====================================================================
   Coopop SaaS — Estilos do Tenant Admin
   Cor primária: #127E4B (verde Coopop) — personalizada por tenant via --brand-primary
   ===================================================================== */

/* =====================================================================
   TELAS DE AUTH (login, recuperar, nova_senha, bloqueado) — ETAPA 08
   ===================================================================== */

body.tenant-auth-layout {
    background: linear-gradient(135deg, #F7FAF8 0%, #E6F4EC 100%);
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.tenant-auth-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(105, 92, 254, .15);
}

.tenant-auth-brand {
    text-align: center;
    margin-bottom: 28px;
}
.tenant-auth-brand .logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark, #0A4D30) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    margin-bottom: 14px;
}
.tenant-auth-brand .logo-custom {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    object-fit: cover;
    margin-bottom: 14px;
}
.tenant-auth-brand h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #0A2A1C;
    margin: 0 0 2px;
}
.tenant-auth-brand .subtitle {
    font-size: 12px;
    color: #6c757d;
}

.tenant-auth-card .form-label,
.tenant-layout .form-label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 6px;
}
.tenant-auth-card .form-control,
.tenant-auth-card .form-select,
.tenant-layout .form-control,
.tenant-layout .form-select {
    font-size: 14px;
    height: 42px;
    border-radius: 8px;
    border: 1px solid #E8E8E8;
}
.tenant-auth-card .form-control:focus,
.tenant-auth-card .form-select:focus,
.tenant-layout .form-control:focus,
.tenant-layout .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(105, 92, 254, .15);
}
.tenant-auth-card .btn-primary,
.tenant-layout .btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    height: 44px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 14px;
}
.tenant-auth-card .btn-primary:hover,
.tenant-layout .btn-primary:hover {
    background: var(--brand-primary-hover, #0E6640);
    border-color: var(--brand-primary-hover, #0E6640);
}
.tenant-auth-card .form-text,
.tenant-layout .form-text {
    font-size: 11.5px;
    color: #6c757d;
}
.tenant-auth-card .alert {
    font-size: 13px;
    border-radius: 8px;
}

.tenant-auth-footer {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    color: #9CA3AF;
}

/* Dashboard placeholder (legado do ETAPA 08) */
.tenant-placeholder {
    max-width: 800px;
    margin: 40px auto;
    padding: 32px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(105, 92, 254, .1);
}
.tenant-placeholder h1 { color: var(--brand-primary); margin: 0 0 4px; }
.tenant-placeholder .pill {
    display: inline-block;
    background: #E6F4EC;
    color: var(--brand-primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 6px;
    margin-bottom: 6px;
}
.tenant-placeholder .info-box {
    background: #E6F4EC;
    border-left: 4px solid var(--brand-primary);
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 13px;
    margin: 20px 0;
}

/* =====================================================================
   LAYOUT INTERNO — ETAPA 09
   Navbar topo (56px) + Sidebar esquerda (260px) + conteúdo
   ===================================================================== */

body.tenant-layout {
    background: var(--body-bg, #F4F6F9);
    margin: 0;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary, #333);
}

/* --------- NAVBAR --------- */
.t-navbar {
    background: #fff;
    height: var(--navbar-height, 56px);
    border-bottom: 1px solid var(--border, #E8E8E8);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .03);
}
.t-navbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.t-sidebar-toggle {
    background: transparent;
    border: none;
    padding: 8px;
    border-radius: 6px;
    color: #555;
    cursor: pointer;
    font-size: 15px;
}
.t-sidebar-toggle:hover {
    background: #F4F6F9;
    color: var(--brand-primary);
}
.t-navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}
.t-navbar-logo {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark, #0A4D30) 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.t-navbar-logo-custom {
    width: 32px; height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.t-navbar-name {
    font-weight: 600;
    color: #0A2A1C;
    font-size: 14px;
    line-height: 1;
}

.t-navbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}
.t-navbar-btn {
    background: transparent;
    border: 1px solid var(--border, #E8E8E8);
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    color: #6c757d;
    font-size: 13px;
    position: relative;
    transition: all .15s;
}
.t-navbar-btn:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}
.t-navbar-btn .badge-dot {
    position: absolute;
    top: -4px; right: -4px;
    background: #DC2626;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border-radius: 10px;
    padding: 2px 5px;
    min-width: 16px;
    line-height: 1;
    border: 2px solid #fff;
}

.t-navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 1px solid var(--border, #E8E8E8);
    border-radius: 10px;
    padding: 4px 10px 4px 4px;
    cursor: pointer;
    transition: all .15s;
}
.t-navbar-user:hover {
    border-color: var(--brand-primary);
}
.t-navbar-avatar {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark, #0A4D30));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 11px;
    flex-shrink: 0;
}
.t-navbar-user-info { line-height: 1.2; text-align: left; }
.t-navbar-user-name {
    font-size: 12.5px;
    font-weight: 500;
    color: #374151;
}
.t-navbar-user-role {
    font-size: 10.5px;
    color: #9CA3AF;
}

/* --------- SIDEBAR --------- */
.t-sidebar {
    position: fixed;
    top: var(--navbar-height, 56px);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width, 260px);
    background: #fff;
    border-right: 1px solid var(--border, #E8E8E8);
    z-index: 50;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width .25s ease, transform .25s ease;
}
.t-sidebar::-webkit-scrollbar { width: 6px; }
.t-sidebar::-webkit-scrollbar-thumb { background: #E8E8E8; border-radius: 3px; }

.t-sidebar-section {
    font-size: 10px;
    font-weight: 700;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 16px 20px 6px;
}

/* Seção colapsável (botão clicável) */
button.t-sidebar-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color .15s ease;
}
button.t-sidebar-section:hover {
    color: #6B7280;
}
.t-section-chevron {
    font-size: 9px;
    transition: transform .2s ease;
    opacity: .5;
}
button.t-sidebar-section.fechado .t-section-chevron {
    transform: rotate(-90deg);
}
.t-section-group {
    /* wrapper só para alternar display */
}
/* Quando sidebar recolhida, esconde o chevron e o label — fica só divisor */
body.tenant-layout.sidebar-closed .t-sidebar button.t-sidebar-section {
    padding: 6px 0;
    justify-content: center;
}
body.tenant-layout.sidebar-closed .t-sidebar .t-section-label,
body.tenant-layout.sidebar-closed .t-sidebar .t-section-chevron {
    display: none;
}

.t-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    margin: 2px 10px;
    border-radius: 8px;
    color: #555;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s;
    position: relative;
}
.t-sidebar-item i.icon {
    width: 18px;
    text-align: center;
    font-size: 14px;
    color: #9CA3AF;
    transition: color .15s;
}
.t-sidebar-item:hover {
    background: #E6F4EC;
    color: var(--brand-primary);
}
.t-sidebar-item:hover i.icon {
    color: var(--brand-primary);
}
.t-sidebar-item.active {
    background: var(--brand-primary);
    color: #fff;
    font-weight: 600;
}
.t-sidebar-item.active i.icon {
    color: #fff;
}
.t-sidebar-item .badge {
    margin-left: auto;
    background: #DC2626;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

.t-sidebar-bottom {
    padding: 16px 20px;
    border-top: 1px solid var(--border, #E8E8E8);
    font-size: 11px;
    color: #9CA3AF;
}

/* Sidebar colapsada (opcional via JS) */
body.tenant-layout.sidebar-closed .t-sidebar {
    width: var(--sidebar-collapsed, 78px);
}
body.tenant-layout.sidebar-closed .t-sidebar .t-sidebar-section,
body.tenant-layout.sidebar-closed .t-sidebar .t-sidebar-item span,
body.tenant-layout.sidebar-closed .t-sidebar .t-sidebar-bottom {
    display: none;
}
body.tenant-layout.sidebar-closed .t-sidebar .t-sidebar-item {
    justify-content: center;
    padding: 10px;
    margin: 2px 8px;
}
body.tenant-layout.sidebar-closed .t-main {
    margin-left: var(--sidebar-collapsed, 78px);
}

/* --------- MAIN CONTENT --------- */
.t-main {
    margin-top: var(--navbar-height, 56px);
    margin-left: var(--sidebar-width, 260px);
    padding: 24px;
    min-height: calc(100vh - var(--navbar-height, 56px));
    transition: margin-left .25s ease;
}

/* Responsivo: sidebar vira off-canvas em mobile */
@media (max-width: 900px) {
    .t-sidebar { transform: translateX(-100%); }
    body.tenant-layout.sidebar-open .t-sidebar { transform: translateX(0); }
    .t-main { margin-left: 0; }
    .t-navbar-user-info { display: none; }
}

/* --------- BREADCRUMB --------- */
.t-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #9CA3AF;
    margin-bottom: 16px;
}
.t-breadcrumb a {
    color: #9CA3AF;
    text-decoration: none;
}
.t-breadcrumb a:hover {
    color: var(--brand-primary);
}
.t-breadcrumb .sep { color: #D1D5DB; }
.t-breadcrumb .current {
    color: #374151;
    font-weight: 500;
}

/* --------- CARDS / KPIs --------- */
.t-kpi {
    background: #fff;
    border: 1px solid var(--border, #E8E8E8);
    border-radius: 12px;
    padding: 18px;
    transition: box-shadow .15s, transform .15s;
}
.t-kpi:hover {
    box-shadow: 0 4px 16px rgba(105, 92, 254, .08);
    transform: translateY(-1px);
}
.t-kpi-label {
    font-size: 11px;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 6px;
    display: flex; align-items: center; gap: 6px;
}
.t-kpi-label i { font-size: 12px; }
.t-kpi-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #0A2A1C;
    line-height: 1.2;
}
.t-kpi-delta {
    font-size: 11px;
    margin-top: 4px;
    color: #6c757d;
    min-height: 14px;
}

.t-card {
    background: #fff;
    border: 1px solid var(--border, #E8E8E8);
    border-radius: 12px;
    overflow: hidden;
}
.t-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border, #E8E8E8);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.t-card-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0A2A1C;
}
.t-card-body { padding: 20px; }

/* Banner mascarado (para ETAPA 25) */
.t-mascarado-banner {
    background: #DC2626;
    color: #fff;
    padding: 8px 20px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
}
.t-mascarado-banner + .t-navbar { top: 36px; }
.t-mascarado-banner + .t-navbar + .t-sidebar { top: calc(36px + var(--navbar-height, 56px)); }
.t-mascarado-banner a { color: #fff; font-weight: 700; text-decoration: underline; }

/* =====================================================================
   DARK MODE
   ===================================================================== */
body.tenant-layout.dark-mode {
    background: #151521;
    color: #B5B5C3;
}
body.tenant-layout.dark-mode .t-navbar,
body.tenant-layout.dark-mode .t-sidebar,
body.tenant-layout.dark-mode .t-kpi,
body.tenant-layout.dark-mode .t-card {
    background: #1E1E2D;
    border-color: #2D2D3F;
}
body.tenant-layout.dark-mode .t-sidebar-item {
    color: #B5B5C3;
}
body.tenant-layout.dark-mode .t-sidebar-item i.icon { color: #6B7280; }
body.tenant-layout.dark-mode .t-sidebar-item:hover {
    background: rgba(105, 92, 254, .15);
    color: #fff;
}
body.tenant-layout.dark-mode .t-sidebar-item:hover i.icon { color: #fff; }
body.tenant-layout.dark-mode .t-navbar-name,
body.tenant-layout.dark-mode .t-kpi-value,
body.tenant-layout.dark-mode .t-card-header h3,
body.tenant-layout.dark-mode .t-breadcrumb .current {
    color: #E5E7EB;
}
body.tenant-layout.dark-mode .t-navbar-btn,
body.tenant-layout.dark-mode .t-navbar-user {
    border-color: #2D2D3F;
    color: #B5B5C3;
}
body.tenant-layout.dark-mode .t-sidebar-bottom,
body.tenant-layout.dark-mode .t-card-header {
    border-color: #2D2D3F;
}

/* ==================================================================
   Badges no sidebar (pendências por módulo)
   ================================================================== */
.t-sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}
.t-sidebar-badge {
    margin-left: auto;
    background: #EF4444;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: 0;
    box-shadow: 0 1px 3px rgba(239, 68, 68, .3);
}
.t-sidebar-item.active .t-sidebar-badge {
    background: #fff;
    color: var(--brand-primary, #127E4B);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .15);
}
/* Quando sidebar recolhida, esconde o texto e empurra badge para canto */
body.tenant-layout.sidebar-closed .t-sidebar-badge {
    position: absolute;
    top: 2px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    font-size: 9px;
    padding: 0 4px;
    margin-left: 0;
}

/* ==================================================================
   Sino de notificações
   ================================================================== */
.t-bell { position: relative; }
.t-bell-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #EF4444;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(239, 68, 68, .4);
    border: 1.5px solid #fff;
}
.t-bell-ativo .fa-bell {
    animation: bellRing 2.5s ease-in-out infinite;
    transform-origin: top center;
}
@keyframes bellRing {
    0%, 90%, 100% { transform: rotate(0); }
    92% { transform: rotate(15deg); }
    94% { transform: rotate(-15deg); }
    96% { transform: rotate(10deg); }
    98% { transform: rotate(-5deg); }
}

/* Dropdown de notificações */
.t-notif-drop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-height: 520px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #E8E8E8;
    border-radius: 12px;
    z-index: 1040;
}
.t-notif-header {
    padding: 14px 16px;
    border-bottom: 1px solid #F0F0F5;
    font-weight: 600;
    font-size: 14px;
    color: #0A2A1C;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.t-notif-count {
    background: #EF4444;
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.t-notif-section + .t-notif-section {
    border-top: 1px solid #F0F0F5;
}
.t-notif-section-title {
    padding: 10px 16px 4px;
    font-size: 11px;
    color: #6B7280;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: .05em;
}
.t-notif-item {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    align-items: center;
    text-decoration: none;
    color: inherit;
    transition: background .12s ease;
    border-left: 3px solid transparent;
}
.t-notif-item:hover {
    background: #FAFAFF;
    border-left-color: var(--brand-primary, #127E4B);
}
.t-notif-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}
.t-notif-body { flex: 1; min-width: 0; }
.t-notif-title {
    font-size: 13px;
    font-weight: 500;
    color: #0A2A1C;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.t-notif-desc {
    font-size: 11px;
    color: #6B7280;
    margin-top: 2px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.t-notif-meta {
    font-size: 11px;
    color: #6B7280;
    margin-top: 2px;
}
.t-notif-arrow {
    font-size: 11px;
    color: #9CA3AF;
    flex-shrink: 0;
}
.t-notif-empty {
    padding: 32px 20px;
    text-align: center;
    color: #9CA3AF;
    font-size: 13px;
}

/* Dark mode do sino */
body.tenant-layout.dark-mode .t-notif-drop {
    background: #1F1F2E;
    border-color: #2D2D3F;
}
body.tenant-layout.dark-mode .t-notif-header,
body.tenant-layout.dark-mode .t-notif-title { color: #E5E7EB; }
body.tenant-layout.dark-mode .t-notif-item:hover { background: #2A2A3E; }
body.tenant-layout.dark-mode .t-notif-section + .t-notif-section,
body.tenant-layout.dark-mode .t-notif-header {
    border-color: #2D2D3F;
}
