:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --secondary: #64748b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-light: #64748b;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent body scroll */
}

/* --- UTILITÁRIOS --- */
.hidden {
    display: none !important;
}

.visible {
    display: flex !important;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

/* --- HEADER --- */
header {
    background: var(--card-bg);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -1px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* --- TELAS --- */
section {
    animation: fadeIn 0.5s ease-in-out;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* LOGIN */
#login-screen {
    background: white;
    /* height: 100vh; removed to allow footer */
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid #e2e8f0;
}

.login-card h2 {
    margin-bottom: 20px;
    color: var(--primary);
}

.input-group {
    margin-bottom: 15px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: var(--text-light);
}

.input-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
    transition: border 0.3s;
}

.input-group input:focus {
    border-color: var(--primary);
}

.public-link {
    margin-top: 15px;
    display: block;
    font-size: 0.9rem;
    color: var(--text-light);
    cursor: pointer;
    text-decoration: underline;
}

/* DASHBOARD (A ESCOLHA) */
#dashboard-screen h2 {
    margin-bottom: 40px;
    font-weight: 300;
    font-size: 2rem;
}

.cards-container {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

.card-choice {
    background: var(--card-bg);
    width: 300px;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow);
    border: 1px solid #f1f5f9;
    position: relative;
    overflow: hidden;
}

.card-choice:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.card-choice .icon {
    font-size: 4rem;
    margin-bottom: 20px;
    display: block;
}

.card-choice h3 {
    color: var(--primary-dark);
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.card-choice p {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.5;
}

.card-header-color {
    height: 10px;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: linear-gradient(90deg, var(--primary), #60a5fa);
}

/* MODULO FUNCIONÁRIOS */
.module-container {
    width: 100%;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    overflow: hidden;
    /* Prevent body scroll */
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Tabela */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex: 1;
    /* Allow table to take space */
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background-color: #f1f5f9;
    color: var(--text-main);
    font-weight: 600;
}

.photo-thumb {
    width: 40px;
    height: 40px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border-left: 5px solid var(--primary);
    position: relative;
    margin-bottom: 15px;
}

.meeting-card.externa {
    border-left-color: #ef4444;
}

.meeting-card.interna {
    border-left-color: #3b82f6;
}

.meeting-time {
    font-weight: bold;
    color: var(--text-main);
    font-size: 1.1rem;
}

.meeting-title {
    margin: 5px 0;
    color: var(--text-light);
}

.meeting-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    background: #e2e8f0;
    margin-top: 5px;
}

/* MODAIS / FORMULÁRIOS */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

/* Robust centering for Employee Modal */
#employee-modal .modal-content {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 90vw !important;
    height: 95vh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #94a3b8;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.full-width {
    grid-column: span 2;
}

textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    resize: vertical;
    min-height: 80px;
}

select {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* CALENDÁRIO VISUAL */
.calendar-wrapper {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 0;
    flex: 1;
    /* Fill remaining vertical space */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header h3 {
    font-size: 1.2rem;
    color: var(--text-main);
    text-transform: capitalize;
}

.calendar-nav-btn {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-main);
    transition: 0.2s;
}

.calendar-nav-btn:hover {
    background: #e2e8f0;
    color: var(--text-light);
    padding-bottom: 10px;
}

.calendar-grid-view {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: 1fr;
    /* Rows will share available height */
    gap: 5px;
    /* Reduced gap to save space */
    text-align: center;
    flex: 1;
    /* Fill remaining vertical space */
    overflow-y: hidden;
    /* Prevent scrollbars */
    min-height: 0;
    /* Important for flex child shrinkage */
}

.day-label {
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.day-cell {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    position: relative;
    transition: 0.2s;
    border: 1px solid transparent;
}

.day-cell:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.day-cell.selected {
    background: var(--primary) !important;
    color: white;
    box-shadow: var(--shadow);
}

.day-cell.today {
    border: 1px solid var(--primary);
    color: var(--primary);
}

.day-cell.selected.today {
    border: 1px solid var(--primary);
    color: white;
}

.day-cell .dots-container {
    display: flex;
    gap: 2px;
    position: absolute;
    bottom: 5px;
    justify-content: center;
    width: 100%;
    z-index: 10;
    pointer-events: none;
    /* Let clicks pass through to cell */
}

.day-cell .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.dot.interna {
    background: #3b82f6;
}

.dot.externa {
    background: #ef4444;
}

.pending-box {
    background: #fff7ed;
    border: 1px solid #fdba74;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.pending-box h4 {
    color: #c2410c;
    margin-bottom: 10px;
}

.pending-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 10px;
}

/* TASKS BOARD */
.task-board {
    display: flex;
    gap: 20px;
    height: 100%;
    overflow-x: auto;
    padding-bottom: 20px;
    flex: 1;
}

.task-column {
    flex: 1;
    min-width: 300px;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.column-header {
    margin-bottom: 15px;
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.count-badge {
    background: #cbd5e1;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
}

.task-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.task-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: grab;
    transition: transform 0.2s;
    border-left: 4px solid #cbd5e1;
}

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

.task-priority {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 5px;
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
}

.priority-high {
    background: #fee2e2;
    color: #ef4444;
    border-left: 4px solid #ef4444;
}

.priority-medium {
    background: #fef3c7;
    color: #d97706;
    border-left: 4px solid #d97706;
}

.priority-low {
    background: #e0f2fe;
    color: #0369a1;
    border-left: 4px solid #0369a1;
}

.task-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 5px;
}

footer {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-size: 0.8rem;
    margin-top: auto;
    border-top: 1px solid #e2e8f0;
    width: 100%;
}

@media print {

    /* Hide everything by default */
    body>* {
        display: none !important;
    }

    /* Only show the employee modal */
    #employee-modal {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        background: white !important;
        z-index: 9999 !important;
    }

    /* Reset modal content positioning for print */
    #employee-modal .modal-content {
        position: static !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        overflow: visible !important;
    }

    /* Hide buttons and interactive elements */
    button,
    .btn,
    .close-modal,
    label[for="emp-photo"],
    label[for="emp-docs"],
    .input-group span {
        display: none !important;
    }

    /* Ensure textareas expand */
    textarea {
        resize: none;
        border: none;
        border-bottom: 1px solid #000;
    }

    /* Ensure inputs allow text visibility */
    input,
    select {
        border: none !important;
        border-bottom: 1px solid #ccc !important;
        background: transparent !important;
        -webkit-appearance: none;
        padding: 5px 0 !important;
    }
}

/* Colaborador Afastado */
.row-afastado {
    background-color: #fef2f2 !important;
    border-left: 4px solid #ef4444;
}

.row-afastado td {
    color: #b91c1c;
}

/* FORCED GRID LAYOUTS */
.grid-4-cols {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
}

.grid-3-cols {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
}

/* RESPONSIVE: Collapse only on very small screens */
@media (max-width: 600px) {

    .grid-4-cols,
    .grid-3-cols {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 400px) {

    .grid-4-cols,
    .grid-3-cols {
        grid-template-columns: 1fr !important;
    }
}

/* MODAL WIDTH FIX */
.modal-lg {
    max-width: 900px !important;
    width: 95vw !important;
}

/* CIRCULAR PROGRESS */
.progress-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.75rem;
    box-shadow: inset 0 0 0 1px #e2e8f0;
    margin: 0 auto;
    /* Center in cell */
}

.progress-circle::before {
    content: "";
    position: absolute;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: white;
    z-index: 1;
    /* Ensure white center is above gradient */
}

.progress-value {
    position: relative;
    z-index: 2;
    /* Text must be on top of everything */
}

/* TABLE COLUMNS CUSTOMIZATION */
#employees-table th:nth-child(1),
#employees-table td:nth-child(1) {
    width: 50%;
    text-align: left;
}

#employees-table th:nth-child(2),
#employees-table td:nth-child(2) {
    width: 15%;
    text-align: center;
}

#employees-table th:nth-child(3),
#employees-table td:nth-child(3) {
    width: 15%;
    text-align: center;
}

#employees-table th:nth-child(4),
#employees-table td:nth-child(4) {
    width: 7%;
    text-align: center;
}

#employees-table th:nth-child(5),
#employees-table td:nth-child(5) {
    width: 13%;
    text-align: right;
}

/* ACTION ICONS & TOOLTIPS */
.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    position: relative;
    color: #64748b;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    color: var(--primary);
}

.action-btn.delete-btn:hover {
    color: #ef4444;
}

.action-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
}

/* Tooltip Implementation */
.action-btn[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    right: 0;
    background: #334155;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    margin-bottom: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}