/* ==========================================================================
   CONFIGURAÇÕES GERAIS & VARIÁVEIS
   Definição de cores globais, tipografia e reset básico.
   ========================================================================== */
:root {
    --primary-blue: #007bff;
    --secondary-blue: #0054ad;
    --light-gray: #f8f9fa;
    --border-color: #dee2e6;
    --text-dark: #333;
    --green: #28a746ad;
    --primary-red: #dc3545;
    --secondary-red: #8d252f;
    --orange: #ff9900;
}

/* Estilização da barra de rolagem (Chrome, Edge e Safari) */
::-webkit-scrollbar { 
    width: 10px; 
    height: 10px; 
}

::-webkit-scrollbar-track { 
    background: #e9ecef; 
    border-radius: 10px; 
}

::-webkit-scrollbar-thumb { 
    background-color: var(--primary-blue); 
    border-radius: 10px; 
    border: 2px solid #e9ecef; 
}

::-webkit-scrollbar-thumb:hover { 
    background-color: var(--secondary-blue); 
}

/* Configurações de layout do corpo da página */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ==========================================================================
   HEADER & NAVBAR
   Logotipo, link do dashboard e perfil do usuário.
   ========================================================================== */
header {
    background-color: #fff;
    padding: 10px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    position: relative;
}

.logo {
    color: var(--primary-blue);
    font-weight: bold;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 5em;
}

.header-nav { 
    display: flex; 
    align-items: center; 
    margin: 0 5em; 
}

.dashboard-link a {
    text-decoration: none;
    color: #555;
    margin: 0 5em;
    transition: transform 0.2s ease, color 0.2s ease;
    display: inline-block;
}

.dashboard-link a:hover { 
    color: var(--primary-blue);
    transform: scale(1.05); 
}

.user-profile {
    cursor: pointer;
    font-size: 1.5rem;
    color: #555;
    transition: transform 0.2s ease, color 0.2s ease;
}

.user-profile:hover { 
    color: var(--primary-blue);
    transform: scale(1.1); 
}

/* ==========================================================================
   DROPDOWN MENU (PERFIL DO USUÁRIO)
   Menu suspenso para Alterar Senha e Logout.
   ========================================================================== */
.user-menu {
    position: absolute;
    right: 40px;
    top: 60px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    display: none;
    z-index: 100;
    width: 150px;
}

/* Estado ativo do menu controlado via JS */
.user-menu.active { 
    display: block; 
    animation: fadeDown 0.2s ease; 
}

.user-menu div, .user-menu span {
    padding: 10px 15px;
    font-size: 0.9rem;
    cursor: pointer;
    display: block;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.user-menu div:hover { 
    background-color: #f1f1f1; 
    transform: translateX(3px); 
}

.logout { 
    color: var(--primary-red) !important; 
    font-weight: bold; 
}

/* ==========================================================================
   CONTEÚDO PRINCIPAL
   Contêiner centralizado e botão de novo apontamento.
   ========================================================================== */
main {
    padding: 0 40px 40px 40px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.controllers { 
    display: flex;
    justify-content: space-between; 
    margin-bottom: 20px;
}

.add-track-btn {
    padding: 8px 25px;
    color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s ease;
}

.add-track-btn.closed { 
    background-color: var(--primary-blue); 
}

.add-track-btn.closed:hover { 
    background-color: var(--secondary-blue); 
}

/* ==========================================================================
   FILTROS (SEMANA, MÊS, ANO)
   Botões de filtragem de data.
   ========================================================================== */
.filters { 
    display: flex;
    gap: 10px; 
}

.filter-btn {
    padding: 8px 25px;
    border: 1px solid var(--border-color);
    background: #e9ecef;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s ease;
}

.filter-btn.active {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    cursor: default;
}

.filter-btn:not(.active):hover { 
    transform: scale(1.05); 
    border-color: var(--primary-blue); 
}

#tracksCounter { 
    align-self: center; 
    color: #888; 
    font-size: 0.9rem; 
}

/* ==========================================================================
   TABELA DE DADOS
   Estilização das linhas, colunas e estados (Status).
   ========================================================================== */
.table-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    overflow-x: auto;
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    text-align: left; 
}

th { 
    color: #666; 
    font-weight: 500; 
    padding: 12px 20px; 
    border-bottom: 1px solid #eee; 
}

td { 
    padding: 14px 20px; 
    font-size: 0.85rem; 
    border-bottom: 1px solid #f9f9f9; 
}

td a {
    text-decoration: none;
    color: var(--primary-blue);
}

/* Estilização das Badges de Status na Tabela */
.status {
    padding: 4px 12px;
    border-radius: 12px;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}
.status.opened { 
    background-color: var(--green); 
}

.status.paused { 
    background-color: var(--primary-blue); 
}

.status.finished { 
    background-color: var(--orange); 
}

/* Ícones de Ações (Play, Pause, Finish, Edit) */
.actions-wrapper { 
    display: flex; 
    align-items: center; 
    gap: 14px; 
}

.actions i { 
    cursor: pointer;
    transition: 0.15s ease; 
}

.actions i.desactived { 
    cursor: not-allowed; 
    opacity: 0.5;
}

.actions i:not(.desactived):hover { 
    transform: scale(1.2); 
}

.actions .fa-play:not(.desactived):hover { 
    color: var(--green); 
}

.actions .fa-flag-checkered:hover { 
    color: var(--primary-red); 
}

.actions .fa-pen-to-square:hover, 
.actions .fa-pause:hover { 
    color: var(--primary-blue); 
}

/* ==========================================================================
   MODAIS (GENÉRICO & RESET SENHA)
   Estrutura de overlay e cartões modais.
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-card {
    background: white;
    width: 90%;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: fadeIn 0.3s ease-out;
}

.close-modal {
    position: absolute;
    top: 15px; right: 15px;
    cursor: pointer;
    color: #999;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.close-modal:hover { 
    color: var(--primary-red); 
}

/* Diferenciação de largura entre modais */
#forgotModal .modal-card {
    max-width: 400px; 
    padding: 30px;
}

#trackModal .modal-card {
    max-width: 550px; 
    padding: 30px;
}

/* Estilização de Formulários dentro dos Modais */
.modal-card .input-group { 
    text-align: left; 
    margin-bottom: 20px; 
    position: relative; 
}

.modal-card .input-group label { 
    display: block; 
    font-size: 0.85rem; 
    color: #555; 
    margin-bottom: 5px; 
    font-weight: 500; 
}

.modal-card .input-group i { 
    position: absolute; 
    left: 15px; 
    top: 36px; 
    color: #aaa; 
}

.modal-card input:not([type="submit"]), 
.modal-select, .status-select-custom {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: 0.3s;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.modal-card input:focus { 
    border-color: var(--primary-blue); 
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1); 
}

#forgotForm input { 
    padding-left: 40px; 
}

.action-btn {
    width: 100%;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}
.action-btn:hover { 
    background-color: #0056b3; 
    transform: translateY(-1px); 
}

/* ==========================================================================
   MODAL ESPECÍFICO: APONTAMENTO (TIMETRACK)
   Cabeçalho destacado e campos lado a lado.
   ========================================================================== */
.modal-header-highlight {
    background-color: #f8faff;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #e0e7ff;
    border-left: 6px solid var(--primary-blue);
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 15px;
}

.modal-header-highlight label {
    font-size: 0.65rem;
    text-transform: uppercase;
    color: #8898aa;
    font-weight: 700;
    margin-bottom: 2px;
}

.modal-header-highlight h3 { 
    margin: 0; 
    font-size: 1.1rem; 
    color: var(--text-dark); 
}

.modal-header-highlight p { 
    margin: 0; 
    font-size: 0.95rem; 
    color: #525f7f; 
}

.row-group { 
    display: flex; 
    gap: 15px; 
    margin-bottom: 15px; 
}

.row-group .input-group { 
    flex: 1; 
    margin-bottom: 0; 
}

.datetime-row { 
    display: flex; 
    gap: 5px; 
}

/* Status Select Customizado com cores dinâmicas via :has() */
.status-select-custom {
    font-weight: bold;
    color: #fff;
    appearance: none;
    background-color: #ccc;
    text-align: center;
    background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 14px;
    padding-right: 28px;
}

.status-select-custom:has(option[value="1"]:checked) { 
    background-color: var(--green); 
}

.status-select-custom:has(option[value="3"]:checked) { 
    background-color: var(--primary-blue); 
}

.status-select-custom:has(option[value="2"]:checked) { 
    background-color: var(--orange); 
}

/* ==========================================================================
   ALERTAS CUSTOMIZADOS
   Sistema de notificações laterais (Toasts).
   ========================================================================== */
.custom-alert {
    position: fixed;
    top: 20px; right: -450px;
    background: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    display: flex;
    gap: 15px;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9999;
    border-left: 5px solid var(--primary-red);
    max-width: 350px;
}

.custom-alert.show { 
    right: 20px; 
}

.custom-alert.success { 
    border-left-color: #2ecc71; 
}

.custom-alert.success i { 
    color: #2ecc71; 
}

.custom-alert i { 
    color: var(--primary-red); 
    font-size: 1.2rem; 
}

.custom-alert .title { 
    font-weight: bold; 
    display: block; 
    font-size: 0.9rem; 
}

.custom-alert .desc { 
    color: #666; 
    font-size: 0.8rem; 
    line-height: 1.4; 
}

/* ==========================================================================
   FOOTER, ANIMAÇÕES & RESPONSIVIDADE
   Roda-pé, keyframes e ajustes mobile.
   ========================================================================== */
footer {
    text-align: center;
    padding: 20px;
    background: #eee;
    font-size: 0.9rem;
    color: #666;
    box-shadow: 0 5px 15px rgba(0,0,0,0.25);
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 480px) {
    .modal-header-highlight { grid-template-columns: 1fr; }
    .row-group { flex-direction: column; }
}

/* Ajustes de data e hora para não quebrar em telas menores */
.datetime-row {
    display: flex;
    gap: 5px;
    width: 100%;
    box-sizing: border-box;
}

.datetime-row input {
    flex: 1;
    min-width: 0; 
    width: 100%;
    padding: 10px 5px !important; 
    font-size: 0.85rem; 
}

.input-group {
    min-width: 0;
    flex: 1;
}

/* ==========================================================================
   FLATPICKR (CALENDÁRIO RANGE)
   Customização do plugin de seleção de datas.
   ========================================================================== */
.filter-input {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    width: 200px;
    background: #fff url('https://cdn.jsdelivr.net/npm/daterangepicker/calendar.png') no-repeat right 8px center;
    background-size: 16px;
}

.range-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

#range-picker-btn {
    display: flex;
    align-items: center;
    white-space: nowrap;
    background: #fff; 
}

/* Customização visual do calendário Flatpickr */
.flatpickr-calendar {
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
    border-radius: 12px !important; 
}

.flatpickr-day.selected, 
.flatpickr-day.startRange, 
.flatpickr-day.endRange {
    background: var(--primary-blue) !important;
    border-color: var(--primary-blue) !important;
}

.flatpickr-day.inRange {
    background: #eef6ff !important; 
    box-shadow: -5px 0 0 #eef6ff, 5px 0 0 #eef6ff !important;
    color: var(--secondary-blue) !important;
}

.flatpickr-day:hover {
    background: var(--light-gray) !important;
}

.flatpickr-months .flatpickr-month {
    color: var(--text-dark) !important;
    fill: var(--text-dark) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    font-weight: bold !important;
}

/* Estado ativo do botão Range Picker */
#range-picker-btn.active {
    background-color: #007bff; 
    color: white;
    cursor: pointer !important; 
}