/* Global Variables */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338ca;
    --danger: #ef4444;
    --success: #10b981;
    --background: #f3f4f6;
    --surface: #ffffff;
    --text-main: #111827;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background-color: var(--surface);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-nav {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-nav:hover {
    background-color: #f3f4f6;
    color: var(--primary);
}

.logout-btn:hover {
    background-color: #fee2e2;
    color: #ef4444;
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    /* Reduced padding for compact look */
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

/* Updated Form Grid for Horizontal Layout */
.form-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.input-group {
    flex: 1 1 150px;
    /* Allow items to grow/shrink, min 150px */
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

label {
    display: block;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 10px;
    margin-bottom: 0px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="file"],
select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    /* More compact */
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
    background-color: #fff;
    color: var(--text-main);
    box-sizing: border-box;
    height: 38px;
    /* Fixed height for alignment */
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Checkbox specific styles */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    padding: 10px;
    border-radius: 8px;
    background: #f9fafb;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

.checkbox-item input {
    width: auto;
    margin: 0;
    height: auto;
}

/* Checkbox Wrapper - Single Line Alignment */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.checkbox-wrapper input[type="checkbox"] {
    width: auto;
    margin: 0;
    height: auto;
}

.checkbox-wrapper label {
    margin-top: 0;
    /* Reset global margin-top */
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
}

/* Buttons */
button,
.btn {
    padding: 0.5rem 1rem;
    /* Compact buttons */
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
    height: 38px;
    /* Match input height */
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

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

.btn-secondary {
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: #f9fafb;
}

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

.btn-danger:hover {
    background-color: #fef2f2;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
}

.alert-error {
    background-color: #fee2e2;
    color: #b91c1c;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Force 2 columns */
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Custom File Upload */
.file-upload-wrapper {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
}

.file-upload-label {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background-color: #f9fafb;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.file-upload-label:hover {
    border-color: var(--primary);
    background-color: #eef2ff;
}

.file-upload-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 10;
}

.file-upload-icon {
    font-size: 2.5rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    transition: color 0.2s;
}

.file-upload-label:hover .file-upload-icon {
    color: var(--primary);
}

.file-upload-text {
    font-weight: 500;
    color: var(--text-main);
}

.file-upload-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.file-name-display {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--success);
    font-weight: 500;
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .navbar-user {
        width: 100%;
        justify-content: space-between;
        /* Space out logout and user info */
    }

    .container {
        padding: 0 1rem;
        margin: 1rem auto;
    }

    /* Form Adjustments */
    .form-grid {
        flex-direction: column;
        align-items: stretch;
    }

    .input-group {
        flex: 1 1 100%;
        width: 100%;
    }

    .actions {
        width: 100%;
        flex-direction: column;
        margin-top: 10px;
    }

    .actions .btn {
        width: 100%;
    }

    /* Dashboard Header Override */
    /* Target the inline styled div in dashboard */
    .container>div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem;
    }

    .container>div[style*="justify-content: space-between"]>div {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .container>div[style*="justify-content: space-between"] button,
    .container>div[style*="justify-content: space-between"] a {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    @media (max-width: 768px) {
        .navbar {
            flex-direction: column;
            gap: 1rem;
            padding: 1rem;
        }

        .navbar-user {
            width: 100%;
            justify-content: space-between;
            /* Space out logout and user info */
        }

        .container {
            padding: 0 1rem;
            margin: 1rem auto;
        }

        /* Form Adjustments */
        .form-grid {
            flex-direction: column;
            align-items: stretch;
        }

        .input-group {
            flex: 1 1 100%;
            width: 100%;
        }

        .actions {
            width: 100%;
            flex-direction: column;
            margin-top: 10px;
        }

        .actions .btn {
            width: 100%;
        }

        /* Dashboard Header Override */
        /* Target the inline styled div in dashboard */
        .container>div[style*="justify-content: space-between"] {
            flex-direction: column !important;
            align-items: flex-start !important;
            gap: 1rem;
        }

        .container>div[style*="justify-content: space-between"]>div {
            width: 100%;
            display: flex;
            flex-direction: column;
        }

        .container>div[style*="justify-content: space-between"] button,
        .container>div[style*="justify-content: space-between"] a {
            width: 100%;
            justify-content: center;
        }

        /* Card Header Override (Empleados/Ponches) */
        .card-header {
            flex-direction: column !important;
            align-items: stretch !important;
            gap: 1rem !important;
        }

        .card-header .search-container {
            width: 100%;
        }

        .search-input {
            max-width: 100% !important;
            width: 100% !important;
        }

        /* Ponches Filters adjustments */
        .filters-secondary {
            flex-direction: column;
            align-items: flex-start;
            gap: 1rem;
        }

        /* Tabs */
        .tabs {
            overflow-x: auto;
            white-space: nowrap;
            padding-bottom: 5px;
            -webkit-overflow-scrolling: touch;
        }

        /* Table Responsive Wrapper */
        .table-container {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
    }