/* Estilos do Sidebar com Toggle */
:root{
    --app-topbar-height: 44px;
    --app-sidebar-width: 280px;
    --app-sidebar-width-collapsed: 72px;
}

.sidebar{
    display: flex;
    flex-direction: column;
    overflow: visible; /* deixa dropdowns saírem do container */
}

.sidebar-header{
    flex: 0 0 auto;
}

.sidebar-scroll{
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: visible;
    -webkit-overflow-scrolling: touch;
}

.app-topbar{
    height: var(--app-topbar-height);
    z-index: 1005;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    background: rgba(248, 249, 250, 0.96);
    border-bottom: 1px solid rgba(15, 23, 42, 0.10);
    backdrop-filter: blur(8px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

/* Topbar global fixo, colado no sidebar */
.app-topbar--global{
    position: fixed;
    top: 0;
    left: var(--app-sidebar-current-width, var(--app-sidebar-width));
    right: 0;
}

/* Empurrar apenas o conteúdo (não o sidebar) */
.has-topbar .main-content{
    padding-top: calc(var(--app-topbar-height) + 1.5rem) !important; /* 1.5rem = p-4 padrão */
}

/* Em telas pequenas, topbar ocupa largura toda */
@media (max-width: 768px){
    .app-topbar--global{ left: 0; }
}

/* Quando sidebar estiver recolhido (desktop), ajustar left */
@media (min-width: 769px){
    body.sidebar-collapsed{
        --app-sidebar-current-width: var(--app-sidebar-width-collapsed);
    }
    body:not(.sidebar-collapsed){
        --app-sidebar-current-width: var(--app-sidebar-width);
    }
}

.app-topbar__menu{
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.04);
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.app-topbar__menu:hover{
    background: rgba(15, 23, 42, 0.07);
}

.app-topbar__title{
    color: #0f172a;
    font-weight: 800;
    letter-spacing: .2px;
    font-size: 0.98rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 78vw;
}

.app-topbar__titleSub{
    color: #64748b;
    font-weight: 700;
    margin-left: 6px;
}

.app-topbar__spacer{
    flex: 1;
}

.app-topbar__actions{
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-topbar__badge{
    max-width: 38vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar { 
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #1d4ed8 100%); 
    min-height: 100vh; 
    transition: all 0.3s ease;
    position: relative;
    z-index: 1004; /* acima do conteúdo, abaixo da topbar (1005) */
    overflow: visible; /* rolagem fica no .sidebar-scroll */
}

.sidebar.collapsed { 
    width: 60px !important; 
    min-width: 60px;
}

.sidebar.collapsed .sidebar-header,
.sidebar.collapsed .sidebar-scroll{
    padding-left: 8px !important;
    padding-right: 8px !important;
}

.sidebar .nav-link { 
    display: flex;
    align-items: center;
    gap: 10px;
    color: white; 
    padding: 1rem; 
    border-radius: 10px; 
    margin: 0.25rem 0; 
    transition: all 0.3s ease;
}

.sidebar .nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .sidebar-meta {
    display: none !important;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.9rem 0.75rem;
}

.sidebar.collapsed .nav-label {
    display: none;
}

.sidebar.collapsed .nav-link i {
    min-width: 0;
    font-size: 1.15rem;
}

.sidebar .nav-link:hover { 
    background: rgba(255,255,255,0.1); 
    color: white; 
}

.sidebar .nav-link.sidebar-logout{
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    border: 1px solid rgba(255,255,255,0.18);
    color: #fff;
}

.sidebar .nav-link.sidebar-logout:hover{
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.sidebar .nav-link.active { 
    background: rgba(255,255,255,0.2); 
}

.sidebar-footer{
    text-align: center;
    line-height: 1.35;
}

.sidebar-footer > div{
    margin-left: auto;
    margin-right: auto;
}

.sidebar .nav-link i { 
    min-width: 20px; 
    text-align: center; 
}

/* botão do menu agora fica no topbar */

.main-content { 
    transition: all 0.3s ease; 
    flex: 1;
    min-width: 0;
}

.main-content.expanded { 
    margin-left: 0; 
}

/* Estilos gerais */
.card { 
    border: none; 
    border-radius: 15px; 
    box-shadow: 0 5px 15px rgba(0,0,0,0.1); 
}

.stat-card { 
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%); 
    color: white; 
    min-height: 120px; /* reduz altura para caber 4+ cards em linha */
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card.success { 
    background: linear-gradient(135deg, #059669 0%, #10b981 100%); 
}

.stat-card.warning { 
    background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%); 
}

.stat-card.danger { 
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%); 
}

.stat-card.reopened {
    background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%);
}

.btn-new-ticket { 
    background: linear-gradient(135deg, #059669 0%, #10b981 100%); 
    border: none; 
}

.btn-pegar { 
    background: linear-gradient(135deg, #059669 0%, #10b981 100%); 
    border: none; 
}

.btn-pegar:hover { 
    background: linear-gradient(135deg, #10b981 0%, #059669 100%); 
}

/* Botão "Ver Ticket" na tela Todos os Tickets - azul com o mesmo efeito do btn-pegar */
.btn-ver {
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
    border: none;
}

.btn-ver:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.ticket-card { 
    border-left: 4px solid #3b82f6; 
}

.ticket-card.alta { 
    border-left-color: #dc2626; 
}

.ticket-card.critica { 
    border-left-color: #7c2d12; 
}

.ticket-card.media { 
    border-left-color: #d97706; 
}

.ticket-card.baixa { 
    border-left-color: #059669; 
}

.user-avatar { 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%); 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: white; 
    font-weight: bold; 
}

.status-badge { 
    font-size: 0.8em; 
}

.chart-container { 
    position: relative; 
    height: 300px; 
}

.timeline { 
    position: relative; 
    padding-left: 30px; 
}

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

.timeline-item { 
    position: relative; 
    margin-bottom: 20px; 
}

.timeline-item::before { 
    content: ''; 
    position: absolute; 
    left: -22px; 
    top: 5px; 
    width: 12px; 
    height: 12px; 
    border-radius: 50%; 
    background: #3b82f6; 
}

.timeline-item.sistema::before { 
    background: #6b7280; 
}

.timeline-item.usuario::before { 
    background: #059669; 
}

.timeline-item.operador::before { 
    background: #d97706; 
}

.message-card { 
    border-left: 4px solid #3b82f6; 
}

.message-card.sistema { 
    border-left-color: #6b7280; 
}

.message-card.usuario { 
    border-left-color: #059669; 
}

.message-card.operador { 
    border-left-color: #d97706; 
}

/* Responsividade (mobile) */
@media (max-width: 768px) {
    .sidebar {
        min-height: auto;
        max-height: calc(100vh - var(--app-topbar-height));
        height: calc(100vh - var(--app-topbar-height));
        overflow: visible; /* rolagem fica no .sidebar-scroll */
    }

    .sidebar.collapsed {
        width: 100% !important;
        min-width: 0;
    }

    .sidebar .nav-link {
        padding: 0.75rem;
        border-radius: 12px;
    }

    .main-content {
        padding: 1rem !important;
    }

    .main-content h2 {
        font-size: 1.35rem;
    }

    .card {
        border-radius: 12px;
    }
}

/* Desktop/tablet: sidebar fixo enquanto a página rola */
@media (min-width: 769px) {
    /* Forçar layout por largura fixa (não depender do grid do Bootstrap) */
    .sidebar{
        flex: 0 0 var(--app-sidebar-width) !important;
        width: var(--app-sidebar-width) !important;
        max-width: var(--app-sidebar-width) !important;
    }

    .sidebar.collapsed{
        flex: 0 0 var(--app-sidebar-width-collapsed) !important;
        width: var(--app-sidebar-width-collapsed) !important;
        max-width: var(--app-sidebar-width-collapsed) !important;
        min-width: var(--app-sidebar-width-collapsed) !important;
    }

    .main-content{
        flex: 1 1 auto;
        width: auto !important;
        max-width: none !important;
    }

    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow: visible; /* rolagem fica no .sidebar-scroll */
    }
}

/* Evitar overflow horizontal em mídias */
img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}
