
/* 1. Variáveis de Cores e Estilos Base (ATUALIZADAS) */
:root {
    --bg-sidebar: #0E163B;      
    --bg-sidebar-hover: #1e293b;
    --bg-main: #f8fafc;         
    --color-primary: #3b66f5;   /* Azul base para gráficos e textos */
    --color-accent: #F3E947; 
    --text-main: #0f172a;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    
    /* Nova variável para o gradiente do botão */
    --btn-gradient: linear-gradient(90deg, #3b66f5 0%, #4facfe 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    display: flex;
    height: 100vh;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden; /* Evita scroll na página toda, o scroll será no main-content */
}

/* =========================================
    2. SIDEBAR (Menu Lateral)
    ========================================= */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}

/* Logotipo */
.logo-area {
    display: flex;
    align-items: center;
    padding: 0 24px;
    margin-bottom: 40px;
}
.logo-icon {
    background-color: var(--color-accent);
    color: var(--bg-sidebar);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 18px;
    margin-right: 12px;
}
.logo-text h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}
.logo-text span {
    font-size: 11px;
    color: #94a3b8;
    letter-spacing: 1px;
}

/* Navegação */
.nav-links {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}
.nav-item:hover {
    background-color: var(--bg-sidebar-hover);
}
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
    border-left: 4px solid var(--color-accent);
}
.nav-item i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* Badges Amarelos (Números no menu) */
.badge-nav {
    background-color: var(--color-accent);
    color: var(--bg-sidebar);
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: auto;
}

/* Status do Sistema (Rodapé lateral) */
.system-status {
    margin: 24px;
    padding: 15px;
    background-color: rgba(255,255,255,0.03);
    border-radius: 12px;
    font-size: 12px;
    color: #94a3b8;
}
.system-status .dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    margin-right: 6px;
}

/* =========================================
    3. ÁREA PRINCIPAL E TOPBAR
    ========================================= */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px 10px 40px;
    margin-bottom: 20px;
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border-color); 
}

/* Barra de pesquisa */
.search-bar {
    background-color: #f1f5f9;
    border-radius: 30px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    width: 350px;
    border: 1px solid var(--border-color);
}
.search-bar input {
    border: none;
    background: transparent;
    outline: none;
    margin-left: 10px;
    width: 100%;
    font-size: 14px;
    color: var(--text-main);
}

/* Perfil de Utilizador */
.user-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}
.notification-icon {
    position: relative;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
}
.notification-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background-color: #ef4444;
    border-radius: 50%;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-text {
    text-align: right;
}
.user-text h4 {
    font-size: 14px;
    font-weight: 600;
}
.user-text p {
    font-size: 12px;
    color: var(--text-muted);
}
.user-avatar {
    background-color: var(--color-primary);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
}

/* =========================================
    4. CONTEÚDO DO DASHBOARD
    ========================================= */
.content {
    padding: 0 40px 40px 40px;
}

/* Cabeçalho do conteúdo */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
}
.page-title span.tag {
    background-color: #eff6ff;
    color: var(--color-primary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}
.page-title h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 5px;
}
.page-title p {
    color: var(--text-muted);
    font-size: 14px;
}
.header-actions {
    display: flex;
    gap: 15px;
}
.btn-outline {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 30px;
    color: var(--text-main);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
}

/* Atualização do Botão Principal com Gradiente */
.btn-primary {
    padding: 10px 24px;
    background: var(--btn-gradient); /* Aplica o gradiente aqui */
    border: none;
    border-radius: 30px;
    color: white;
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease; /* Animação suave */
    box-shadow: 0 4px 10px rgba(59, 102, 245, 0.2); /* Sombra subtil azul */
}

/* Efeito quando passas o rato por cima do botão */
.btn-primary:hover {
    box-shadow: 0 6px 15px rgba(59, 102, 245, 0.4);
    transform: translateY(-2px); /* Levanta o botão ligeiramente */
}

/* Grelha de KPIs (Cartões) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}
.kpi-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
    position: relative;
}
.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    margin-bottom: 20px;
}
/* Cores de fundo para ícones dos cartões */
.icon-blue { background: #eff6ff; color: #3b82f6; }
.icon-yellow { background: #fefce8; color: #eab308; }
.icon-purple { background: #f5f3ff; color: #8b5cf6; }

.kpi-card .arrow-link {
    position: absolute;
    top: 24px;
    right: 24px;
    color: #cbd5e1;
    font-size: 12px;
    cursor: pointer;
}
.kpi-card h3 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 5px;
}
.kpi-card p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.kpi-trend {
    font-size: 13px;
    font-weight: 500;
}
.trend-blue { color: #3b82f6; }
.trend-red { color: #ef4444; }

/* Secção dos Gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* O gráfico de linhas ocupa o dobro do espaço */
    gap: 20px;
    margin-bottom: 30px;
}
.chart-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.chart-title h4 {
    font-size: 16px;
    font-weight: 600;
}
.chart-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Secção Inferior (Tabelas/Listas) */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
/* Adaptação simples das listas da base do ecrã */
.list-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

/* =========================================
   5. TABELAS E LISTAGENS (Estilo ZugIT)
   ========================================= */
.table-container {
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    padding: 24px;
    overflow-x: auto;
}

.zug-table {
    width: 100%;
    border-collapse: collapse;
}

.zug-table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.zug-table td {
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.zug-table tr:last-child td { border-bottom: none; }
.zug-table tr:hover td { background-color: #f8fafc; cursor: default; }

/* Componente de Colaborador na Tabela */
.user-cell { display: flex; align-items: center; gap: 15px; }
.user-avatar-small {
    background-color: #eff6ff;
    color: var(--color-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
}
.user-details h5 { font-size: 14px; font-weight: 600; color: var(--text-main); margin-bottom: 2px; }
.user-details p { font-size: 13px; color: var(--text-muted); }

/* Badges de Estado */
.badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.badge.ativo { background-color: #ecfdf5; color: #10b981; }
.badge.inativo { background-color: #fef2f2; color: #ef4444; }

/* Botões de Ação na Tabela */
.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 5px 10px;
    transition: 0.2s;
}
.action-btn:hover { color: var(--color-primary); }

/* =========================================
   6. MODALS (Pop-ups)
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 21, 42, 0.6); /* Fundo escuro semi-transparente */
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    border-radius: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    transition: all 0.3s ease;
    overflow: hidden;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 18px; font-weight: 600; margin: 0; }
.btn-close {
    background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer;
}
.btn-close:hover { color: var(--text-main); }

.modal-body { padding: 25px; }

/* Para colocar os campos lado a lado no modal */
.form-row { display: flex; gap: 15px; margin-bottom: 20px; }
.form-row .form-group { flex: 1; margin-bottom: 0; }

.modal-footer {
    padding: 20px 25px;
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* =========================================
   7. ESTILOS DE FORMULÁRIOS (Inputs Premium)
   ========================================= */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

/* O Segredo do Input Moderno */
.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-main);
    background-color: #ffffff;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box; /* Impede que o padding estrague a largura */
}

/* Efeito quando o utilizador clica no campo (Focus) */
.form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(59, 102, 245, 0.1); /* Um anel azul suave e brilhante */
    background-color: #fcfdff;
}

/* Estilo específico para dropdowns (Select) para remover a seta rude do browser */
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Injeta uma seta SVG moderna e minimalista usando CSS */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 40px; /* Dá espaço para a seta não sobrepor o texto */
    cursor: pointer;
}

/* Badges de Estado de Equipamentos */
.badge.stock { background-color: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.badge.atribuido { background-color: #eff6ff; color: #3b66f5; border: 1px solid #bfdbfe; }
.badge.manutencao { background-color: #fef2f2; color: #ef4444; border: 1px solid #fecaca; }
.badge.abatido { background-color: #f1f5f9; color: #64748b; border: 1px solid #cbd5e1; }

/* Texto de Garantia */
.text-garantia { font-size: 12px; font-weight: 600; }
.garantia-ok { color: #64748b; }
.garantia-alerta { color: #eab308; } /* Amarelo/Laranja para alertas */
.garantia-expirada { color: #ef4444; } /* Vermelho */

.menu-toggle { display: none; background: none; border: none; font-size: 24px; color: var(--text-main); cursor: pointer; }
/* =========================================
   8. RESPONSIVIDADE MOBILE (Smartphones)
   ========================================= */
@media (max-width: 768px) {
    /* Esconde a sidebar fora do ecrã por defeito */
    .sidebar {
        position: fixed;
        left: -250px; /* Largura da tua sidebar */
        top: 0;
        height: 100vh;
        z-index: 9999;
        transition: left 0.3s ease;
    }
    
    /* Classe que o JS vai adicionar para mostrar a sidebar */
    .sidebar.open { left: 0; }
    
    /* Ajusta a área principal */
    .main-content { margin-left: 0 !important; width: 100%; padding: 15px; }
    
    /* Tabelas com scroll horizontal para não quebrarem o layout */
    .table-responsive { overflow-x: auto; display: block; width: 100%; }

    .menu-toggle { display: block; margin-bottom: 15px; }
    
    /* Classe para mostrar a barra quando clicarmos num botão de menu (Hamburger) */
    .sidebar.active {
        left: 0;
    }

    /* O conteúdo principal passa a ocupar 100% do ecrã */
    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }

    /* Ajustes para o topo não ficar apertado */
    .topbar {
        padding: 15px 20px;
    }
    
    .search-bar {
        width: 60%; /* Encolhe a barra de pesquisa no telemóvel */
    }
}

/* Badges de Estado de Pedidos (Helpdesk) */
.badge.pendente { background-color: #fef9c3; color: #ca8a04; border: 1px solid #fef08a; } /* Amarelo */
.badge.analise { background-color: #e0e7ff; color: #4f46e5; border: 1px solid #c7d2fe; } /* Roxo/Índigo */
.badge.concluido { background-color: #dcfce7; color: #16a34a; border: 1px solid #bbf7d0; } /* Verde */
.badge.cancelado { background-color: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; } /* Cinza */

.nav-item {
    display: flex;
    align-items: center;
    position: relative;
    padding: 12px 20px;
    text-decoration: none;
    color: #64748b;
    border-radius: 12px;
    margin-bottom: 5px;
}

.nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.badge-count {
    background: #ef4444; /* Vermelho para Pedidos */
    color: white;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: auto; /* Empurra para a direita */
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    .sidebar span, .sidebar .badge-count {
        display: none; /* Esconde texto em mobile se necessário */
    }
}