/* CCM Afiliados - Custom Styles */

/* Animation for cards */
.card {
    transition: all 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Material cards hover effect */
.card.border:hover {
    border-color: var(--primary-color) !important;
    box-shadow: 0 8px 16px rgba(255, 198, 41, 0.15);
}

.card.border:hover .card-img-top {
    transform: scale(1.05);
}

.card .card-img-top {
    transition: transform 0.3s ease;
}

/* Badges no material */
.card .position-absolute .badge {
    backdrop-filter: blur(8px);
    font-weight: 500;
}

/* Botões dos materiais */
.card-footer .btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.card-footer .btn-outline-secondary {
    border-color: #E2E8F0;
    color: #64748B;
}

.card-footer .btn-outline-secondary:hover {
    background-color: #F8FAFC;
    border-color: #CBD5E1;
    color: #475569;
}

/* Funil de Conversão */
.conversion-funnel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.funnel-step {
    min-width: 80px;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.funnel-step span {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.funnel-step:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive funnel */
@media (max-width: 767px) {
    .funnel-step {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Cards de métrica em mobile */
    .metric-card h3 {
        font-size: 1.5rem;
    }
    
    /* Link de afiliado em mobile */
    .input-group .form-control {
        font-size: 0.75rem;
    }
    
    /* Ajustar layout de materiais */
    .row.g-3 > div[class*="col-"] {
        padding: 0.5rem;
    }
}

/* Badge styles */
.badge.bg-success {
    background-color: #22C55E !important;
}

.badge.bg-warning {
    background-color: #F59E0B !important;
}

.badge.bg-danger {
    background-color: #EF4444 !important;
}

.badge.bg-info {
    background-color: #3B82F6 !important;
}

.badge.bg-secondary {
    background-color: #64748B !important;
}

/* Status indicators */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.status-indicator.success {
    background-color: #22C55E;
}

.status-indicator.warning {
    background-color: #F59E0B;
}

.status-indicator.danger {
    background-color: #EF4444;
}

/* Growth indicators */
.growth-indicator {
    display: inline-flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.growth-indicator.positive {
    color: #166534;
    background-color: #F0FDF4;
}

.growth-indicator.negative {
    color: #991B1B;
    background-color: #FEF2F2;
}

.growth-indicator i {
    margin-right: 4px;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state i {
    font-size: 4rem;
    color: #CBD5E1;
    margin-bottom: 1rem;
}

.empty-state h4 {
    color: #64748B;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #94A3B8;
}

/* Level badge */
.level-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #FFF9E6 0%, #FFFBEB 100%);
    border: 2px solid #FFC629;
    border-radius: 8px;
    font-weight: 600;
    color: #0F172A;
}

.level-badge i {
    font-size: 1.25rem;
    margin-right: 0.5rem;
    color: #FFC629;
}

/* Progress circle */
.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.progress-circle svg {
    transform: rotate(-90deg);
}

.progress-circle-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 700;
    color: #0F172A;
}

/* Stats card */
.stats-card {
    position: relative;
    overflow: hidden;
}

.stats-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #E2E8F0;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -2.375rem;
    top: 0.5rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #FFC629;
    border: 2px solid white;
    box-shadow: 0 0 0 2px #E2E8F0;
}

/* Accordion Modern */
.accordion-button {
    background-color: transparent;
    box-shadow: none;
    border: none;
    color: var(--text-primary);
}

.accordion-button:not(.collapsed) {
    background-color: #F8FAFC;
    color: var(--text-primary);
}

.accordion-button:focus {
    box-shadow: none;
    border: none;
}

.accordion-button::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23FFC629'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.accordion-button:not(.collapsed)::after {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23FFC629'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

.accordion-body {
    border-top: 1px solid #E2E8F0;
}

/* Nível Cards - Moderno e Clean */
.nivel-card-modern {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    border-radius: 16px !important;
}

.nivel-card-modern:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1) !important;
}

.nivel-card-header {
    transition: all 0.3s ease;
    border-radius: 16px 16px 0 0 !important;
}

.nivel-icon-wrapper {
    transition: transform 0.3s ease;
}

.nivel-card-modern:hover .nivel-icon-wrapper {
    transform: scale(1.1) rotate(5deg);
}

.form-control-modern {
    transition: all 0.2s ease;
}

.form-control-modern:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(255, 198, 41, 0.15) !important;
    outline: none;
}

.btn-save-modern {
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-save-modern:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    filter: brightness(1.1);
}

.btn-save-modern:active {
    transform: translateY(0);
}

/* Nível Cards - Responsivo */
@media (max-width: 991px) {
    .nivel-card-mobile {
        margin-bottom: 1rem;
    }
    
    .nivel-card-modern {
        margin-bottom: 1.5rem;
    }
}

/* Hover suave para cards de nível */
.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

/* Tabela de níveis - Mobile */
@media (max-width: 768px) {
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.875rem;
    }
    
    .table th:first-child,
    .table td:first-child {
        position: sticky;
        left: 0;
        background: white;
        z-index: 1;
    }
}

/* Badge de nível atual */
.badge.bg-primary-custom {
    animation: subtlePulse 2s ease-in-out infinite;
}

@keyframes subtlePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

/* Banner de Impersonation */
.impersonate-banner {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1045;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-bottom: 3px solid #ffc107;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.impersonate-banner .btn-light {
    background: white;
    color: #667eea;
    border: none;
    transition: all 0.2s ease;
}

.impersonate-banner .btn-light:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.impersonate-banner .btn-light:active {
    transform: translateY(0);
}

/* Ajustar navbar quando impersonating */
.impersonate-banner + .navbar {
    top: 0 !important;
}

/* Responsivo do banner */
@media (max-width: 767px) {
    .impersonate-banner {
        font-size: 0.85rem;
    }
    
    .impersonate-banner .d-flex {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    
    .impersonate-banner .btn-light {
        width: 100%;
    }
}

/* Page Loader */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 250, 252, 0.98);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1030;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.page-loader.show {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.loader-content {
    text-align: center;
    animation: fadeInLoader 0.3s ease-out;
}

@keyframes fadeInLoader {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.spinner {
    position: relative;
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-top-color: #FFC629;
    border-radius: 50%;
    animation: spinRing 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner-ring:nth-child(1) {
    animation-delay: -0.45s;
    border-top-color: #FFC629;
}

.spinner-ring:nth-child(2) {
    animation-delay: -0.3s;
    border-top-color: #FFD55A;
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
}

.spinner-ring:nth-child(3) {
    animation-delay: -0.15s;
    border-top-color: #FFB800;
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
}

@keyframes spinRing {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loader-text {
    color: #0F172A;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Feature card */
.feature-card {
    text-align: center;
    padding: 2rem;
    height: 100%;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
}

.feature-card i {
    font-size: 3rem;
    color: #FFC629;
    margin-bottom: 1rem;
}

.feature-card h5 {
    font-weight: 600;
    margin-bottom: 1rem;
    color: #0F172A;
}

.feature-card p {
    color: #64748B;
    margin-bottom: 0;
}

/* Data table enhancement */
.data-table {
    font-size: 0.875rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tr {
    border-bottom: 1px solid #E2E8F0;
}

.data-table tr:last-child {
    border-bottom: none;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(90deg, #F1F5F9 25%, #E2E8F0 50%, #F1F5F9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Tooltip custom */
.tooltip-custom {
    position: relative;
    cursor: help;
}

.tooltip-custom:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: #0F172A;
    color: white;
    font-size: 0.75rem;
    white-space: nowrap;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

/* Sidebar Overlay para Mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    display: none;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Sidebar Mobile Header */
.sidebar-mobile-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.sidebar-mobile-header .btn-link {
    text-decoration: none;
}

.sidebar-mobile-header .btn-link:hover {
    opacity: 0.7;
}

/* Sidebar User Info */
.sidebar-user-info {
    background: white;
    position: sticky;
    top: 0;
    z-index: 5;
}

.sidebar-user-info:hover {
    background: #F8FAFC;
}

@media (max-width: 767px) {
    .sidebar-user-info {
        position: static;
    }
}

/* Botão de logout no sidebar */
.sidebar .btn-outline-danger {
    border-color: #FCA5A5;
    color: #DC2626;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sidebar .btn-outline-danger:hover {
    background-color: #FEF2F2;
    border-color: #EF4444;
    color: #DC2626;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.1);
}

/* Separador do logout */
.sidebar .nav-item.mt-3 {
    margin-top: 1.5rem !important;
}

/* Botão de toggle do menu mobile */
#sidebarToggle {
    border: none;
    background: none;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

#sidebarToggle:hover {
    background: var(--bg-primary);
}

#sidebarToggle:focus {
    outline: none;
    box-shadow: none;
}

/* Centralizar navbar no mobile */
@media (max-width: 767px) {
    .navbar {
        padding: 0.75rem 1rem;
    }
    
    .navbar .container-fluid {
        position: relative;
        justify-content: center;
        padding: 0;
    }
    
    .navbar-brand {
        position: relative;
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
    }
    
    #sidebarToggle {
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
    }
}

/* Esconder badge Admin em telas muito pequenas */
@media (max-width: 400px) {
    .navbar-brand .badge {
        display: none;
    }
    
    .navbar-brand {
        font-size: 0.9rem;
    }
}

/* Responsive improvements */
@media (max-width: 767px) {
    .sidebar {
        position: fixed !important;
        top: 0;
        left: -280px;
        width: 280px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.25s ease-out;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding-top: 0;
        will-change: left;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    /* Links clicáveis no mobile */
    .sidebar .nav-link {
        cursor: pointer;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .sidebar .nav-link:active {
        background-color: var(--bg-primary);
    }
    
    /* Adicionar logo no topo do sidebar mobile */
    .sidebar .position-sticky {
        padding-top: 0;
    }
    
    .metric-card h3 {
        font-size: 1.5rem;
    }
    
    /* Sidebar nav links no mobile */
    .sidebar .nav-link {
        font-size: 0.95rem;
        padding: 1rem 1.5rem;
    }
    
    .sidebar .nav-link i {
        font-size: 1.25rem;
    }
    
    /* Cards de métricas em 2 colunas no mobile */
    .metric-card {
        padding: 1rem;
    }
    
    .metric-card i {
        font-size: 1.5rem;
    }
    
    .metric-card h3 {
        font-size: 1.25rem;
    }
    
    .metric-card p {
        font-size: 0.75rem;
    }
    
    /* Ajustar main content no mobile */
    main.col-md-10 {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem !important;
    }
    
    /* Mostrar overlay no mobile */
    .sidebar-overlay {
        display: block !important;
    }
    
    /* Ajustar cards no mobile */
    .card {
        margin-bottom: 1rem;
    }
    
    .card-header {
        padding: 1rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Tabelas responsivas */
    .table {
        font-size: 0.8rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem;
    }
}

@media (min-width: 768px) {
    /* Garantir que sidebar está sempre visível no desktop */
    .sidebar {
        position: relative !important;
        left: 0 !important;
        display: block !important;
    }
    
    /* Esconder overlay em desktop */
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Esconder header mobile no desktop */
    .sidebar-mobile-header {
        display: none !important;
    }
}

/* Touch optimization para mobile */
@media (max-width: 767px) {
    .sidebar * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    .sidebar .nav-link {
        touch-action: manipulation;
    }
}

/* Card header suave para afiliados pendentes */
.card-header.bg-warning {
    background-color: #FEF3C7 !important;
    border-bottom: 1px solid #FDE68A;
    color: #92400E !important;
}

.card-header.bg-warning h5 {
    color: #92400E !important;
}

.card-header.bg-warning i {
    color: #D97706 !important;
}

/* Print styles */
@media print {
    .navbar,
    .sidebar,
    .btn,
    .alert {
        display: none;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #E2E8F0;
    }
}

/* Modal Customization */
.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Rodapé global (não fixo) */
.site-footer {
    background: transparent;
}

.site-footer-inner {
    background: transparent;
}

/* Espaço do rodapé alinhado à sidebar (mesmo fundo + borda direita) */
.site-footer-sidebar-spacer {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
}

/* Footer em páginas com sidebar é alinhado via grid (col-md-2/col-md-10) no HTML */

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 12px 12px 0 0;
}

.modal-header.bg-primary-custom {
    background-color: #FFFBF0 !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid #FFE9A3;
}

.modal-header.bg-primary {
    background-color: #3B82F6 !important;
    color: white !important;
    border-bottom: none;
}

.modal-header.bg-warning {
    background-color: #F59E0B !important;
    color: white !important;
    border-bottom: none;
}

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 0 0 12px 12px;
}

.modal-header .btn-close {
    padding: 0.5rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
}

.modal-header .btn-close-white {
    filter: brightness(0) invert(1);
}

/* Garantir que loader não interfira com modais */
body.modal-open .page-loader,
.modal-open .page-loader,
body:has(.modal.show) .page-loader {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    z-index: 1020 !important;
    pointer-events: none !important;
}

/* Garantir que loader nunca fique acima de modais */
.page-loader {
    z-index: 1030 !important;
}

.modal {
    z-index: 1050 !important;
}

.modal-backdrop {
    z-index: 1040 !important;
}

/* Prevenir piscar ao abrir modal */
.modal.fade {
    transition: opacity 0.15s linear;
}

.modal.fade:not(.show) {
    opacity: 0;
}

.modal.fade.show {
    opacity: 1;
}

/* Garantir que modais sempre tenham prioridade */
.modal {
    z-index: 1055 !important;
}

.modal-backdrop {
    z-index: 1050 !important;
}

/* Prevenir qualquer interferência visual */
.modal.show {
    display: block !important;
}

.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}

